SlideShare a Scribd company logo
PYTHON FOR K8 API
TESTING
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
INTRODUCTION
• About the topic
• Testing Kubernetes resources using python.
• Testing Architecture
Python Script
Kubernetes-client
Python compiler
Kube config
Kubernetes control
plane
API Server
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
PYTHON SETUP
• Python CLI commands
• Version
• path
• Python virtual environment
• Activate virtual env
• Deactivate Virtual env
• Pip install
• Install thirds party libraries
• Install libraries from text file
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
PYTHON PEP8
• Docstrings
• Linting
• https://peps.python.org/pep-0008/
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
PYTHON UNIT TEST ESSENTIALS
• Decorator
• It’s a wrapper to a function
• Unit test
• Test case for each function
• Pytest
• Third party tool for executing test case
• Stestr
• Third party tool for executing test case as a batch file
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
MOCKING IN UNIT TESTS
• Mocks
• It allows you to replace parts of your system under test with mock objects
and make assertions about how they have been used
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
EXAMPLE FOR MOCKING
• values = {'a': 1, 'b': 2, 'c': 3}
• def side_effect(arg):
• ... return values[arg]
• mock.side_effect = side_effect
• mock('a'), mock('b'), mock('c') (1, 2, 3)
• mock.side_effect = [5, 4, 3, 2, 1]
• mock(), mock(), mock()
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
PYTHON KUBERNETES ESSENTIALS
• Yaml parser
• Kube-config
• Kubernetes-client
• proxy setup
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
INTRODUCTION TO WHY KUBERNETES API
TESTING
• To make sure your new deployments are up and running
• Could be that your APIs are behind a VPN or a firewall or you need a special kind of authentication
• Differences in the various environments
• Changes in APIs due to ongoing API development and the necessity to test multiple versions.
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
CONTEXT
• To get the current context
• To know on which cluster the context is
• kubectl config get-contexts
• config.list_kube_config_contexts()
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
NODES
• To check the nodes states
• listing the nodes
• Describe the nodes
• Parse the required parameter of node output
• Node selector
• state
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
RBAC ROLES
• Permissions for namespaced resources
• To list the roles
• To create the roles
• kubectl get rolebindings
• client.RbacAuthorizationV1Api()
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
CLUSTER ROLES
• Permissions at cluster level
• We test the clusterrole bindings associated with the namespace.
• kubectl get clusterroles
• list_cluster_role()
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
NODE CERTIFICATES VALIDITY
• By default, kubeadm generates all the certificates needed for a cluster to run. You can override this behaviour by
providing your own certificates.
• kubeadm certs check-expiration
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
NAMESPACES
• To get list of all namespaces in cluster
• We test our list of namespaces are present in the cluster
• Kubectl get ns
• list_namespace()
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
SERVICES
• A service is a method for exposing a network application that is running as one or more pods in your
cluster as an api
• We test our namespace services are present in the namespace.
• Check the endpoints are available
• We do not guarantee that svc is functionally running.
• Kubectl get svc
• list_service_for_all_namespaces
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
PODS
• A Pod is a group of one or more containers.
• We test the pods are present and running state
• Kubectl get pods
• list_pod_for_all_namespaces
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
POD REPLICA
• Replicaset will be indicating how many Pods it should be maintaining.
• We test pod replicas present and matching with our count
• Kubectl get pods
• V1ReplicaSet
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
AGE OF PODS
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
CONFIGMAP
• A ConfigMap is an API object used to store non-confidential data in key-value pairs
• We test the presence of configmap
• We test the data inside the configmap
• Kubectl get configmap
• list_namespaced_config_map
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
DEPLOYMENT
• Deployment is controller of pods
• We test the deployment is present in the given namespace.
• Kubectl get deploy
• list_deployment_for_all_namespaces
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
DEPLOYMENT SPECS
• Specs are the other configurations related to the kind
• We test the images names and selector in the deployments are as expected
• Pythonic code to traverse the deployment output
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
SECRETS
• A Secret is an object that contains a small amount of sensitive data such as a password
• We test the presence of secret in the namespace
• We can’t decrypt the secret so we cant guarantee the data behind
• Kubectl get secrets
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
VOLUMES
• A volume is a directory, possibly with some data in it, which is accessible to the containers in a pod.
• Kubectl get pvc
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
STATEFULSET
• StatefulSet manages Pods that are based on an identical container spec
• We test the presence of statefullset in the namespace
• Kubectl get sts
2023 © Visualpath All Rights Reserved. | Designed By Visualpath

More Related Content

Similar to kubernetes_python_api_testing.pptx

20191201 kubernetes managed weblogic revival - part 2
20191201 kubernetes managed weblogic revival - part 220191201 kubernetes managed weblogic revival - part 2
20191201 kubernetes managed weblogic revival - part 2
makker_nl
 
Kubernetes on aws
Kubernetes on awsKubernetes on aws
Kubernetes on aws
Yousun Jeong
 
The Kubernetes WebLogic revival (part 2)
The Kubernetes WebLogic revival (part 2)The Kubernetes WebLogic revival (part 2)
The Kubernetes WebLogic revival (part 2)
Simon Haslam
 
Developing Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containersDeveloping Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB201904_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
Kumton Suttiraksiri
 
BYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFiBYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFi
DataWorks Summit
 
Setup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes FederationSetup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes Federation
inwin stack
 
Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.
Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.
Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.
Opcito Technologies
 
Admission controllers - PSP, OPA, Kyverno and more!
Admission controllers - PSP, OPA, Kyverno and more!Admission controllers - PSP, OPA, Kyverno and more!
Admission controllers - PSP, OPA, Kyverno and more!
SebastienSEYMARC
 
Developing Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containersDeveloping Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
Introduction to Virtual Kubelet
Introduction to Virtual KubeletIntroduction to Virtual Kubelet
Introduction to Virtual Kubelet
Mitchell Pronschinske
 
[Spark Summit 2017 NA] Apache Spark on Kubernetes
[Spark Summit 2017 NA] Apache Spark on Kubernetes[Spark Summit 2017 NA] Apache Spark on Kubernetes
[Spark Summit 2017 NA] Apache Spark on Kubernetes
Timothy Chen
 
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueCloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
ShapeBlue
 
An Introduction to Kubernetes and Continuous Delivery Fundamentals
An Introduction to Kubernetes and Continuous Delivery FundamentalsAn Introduction to Kubernetes and Continuous Delivery Fundamentals
An Introduction to Kubernetes and Continuous Delivery Fundamentals
All Things Open
 
Using Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the CloudUsing Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the Cloud
Andrew Kennedy
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
Bob Killen
 
AKS
AKSAKS
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Amazon Web Services Korea
 
Clocker, Calico and Docker
Clocker, Calico and DockerClocker, Calico and Docker
Clocker, Calico and Docker
Andrew Kennedy
 
Why Kubernetes as a container orchestrator is a right choice for running spar...
Why Kubernetes as a container orchestrator is a right choice for running spar...Why Kubernetes as a container orchestrator is a right choice for running spar...
Why Kubernetes as a container orchestrator is a right choice for running spar...
DataWorks Summit
 

Similar to kubernetes_python_api_testing.pptx (20)

20191201 kubernetes managed weblogic revival - part 2
20191201 kubernetes managed weblogic revival - part 220191201 kubernetes managed weblogic revival - part 2
20191201 kubernetes managed weblogic revival - part 2
 
Kubernetes on aws
Kubernetes on awsKubernetes on aws
Kubernetes on aws
 
The Kubernetes WebLogic revival (part 2)
The Kubernetes WebLogic revival (part 2)The Kubernetes WebLogic revival (part 2)
The Kubernetes WebLogic revival (part 2)
 
Developing Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containersDeveloping Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containers
 
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB201904_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
 
BYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFiBYOP: Custom Processor Development with Apache NiFi
BYOP: Custom Processor Development with Apache NiFi
 
Setup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes FederationSetup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes Federation
 
Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.
Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.
Securing & Monitoring Your K8s Cluster with RBAC and Prometheus”.
 
Admission controllers - PSP, OPA, Kyverno and more!
Admission controllers - PSP, OPA, Kyverno and more!Admission controllers - PSP, OPA, Kyverno and more!
Admission controllers - PSP, OPA, Kyverno and more!
 
Developing Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containersDeveloping Java based microservices ready for the world of containers
Developing Java based microservices ready for the world of containers
 
Introduction to Virtual Kubelet
Introduction to Virtual KubeletIntroduction to Virtual Kubelet
Introduction to Virtual Kubelet
 
[Spark Summit 2017 NA] Apache Spark on Kubernetes
[Spark Summit 2017 NA] Apache Spark on Kubernetes[Spark Summit 2017 NA] Apache Spark on Kubernetes
[Spark Summit 2017 NA] Apache Spark on Kubernetes
 
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueCloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
 
An Introduction to Kubernetes and Continuous Delivery Fundamentals
An Introduction to Kubernetes and Continuous Delivery FundamentalsAn Introduction to Kubernetes and Continuous Delivery Fundamentals
An Introduction to Kubernetes and Continuous Delivery Fundamentals
 
Using Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the CloudUsing Clocker with Project Calico - Running Production Workloads in the Cloud
Using Clocker with Project Calico - Running Production Workloads in the Cloud
 
Introduction to Kubernetes Workshop
Introduction to Kubernetes WorkshopIntroduction to Kubernetes Workshop
Introduction to Kubernetes Workshop
 
AKS
AKSAKS
AKS
 
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
Kubernetes/ EKS - 김광영 (AWS 솔루션즈 아키텍트)
 
Clocker, Calico and Docker
Clocker, Calico and DockerClocker, Calico and Docker
Clocker, Calico and Docker
 
Why Kubernetes as a container orchestrator is a right choice for running spar...
Why Kubernetes as a container orchestrator is a right choice for running spar...Why Kubernetes as a container orchestrator is a right choice for running spar...
Why Kubernetes as a container orchestrator is a right choice for running spar...
 

Recently uploaded

Set off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptxSet off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptx
HARSHITHV26
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
KaiNexus
 
BeMetals Presentation_May_22_2024 .pdf
BeMetals Presentation_May_22_2024   .pdfBeMetals Presentation_May_22_2024   .pdf
BeMetals Presentation_May_22_2024 .pdf
DerekIwanaka1
 
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdfMeas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
dylandmeas
 
Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
YourLegal Accounting
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
Operational Excellence Consulting
 
What are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdfWhat are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdf
HumanResourceDimensi1
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
tanyjahb
 
The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...
awaisafdar
 
The-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic managementThe-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic management
Bojamma2
 
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
BBPMedia1
 
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptxCADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
fakeloginn69
 
Role of Remote Sensing and Monitoring in Mining
Role of Remote Sensing and Monitoring in MiningRole of Remote Sensing and Monitoring in Mining
Role of Remote Sensing and Monitoring in Mining
Naaraayani Minerals Pvt.Ltd
 
Improving profitability for small business
Improving profitability for small businessImproving profitability for small business
Improving profitability for small business
Ben Wann
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
Erika906060
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
creerey
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
LR1709MUSIC
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
seoforlegalpillers
 
Project File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdfProject File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdf
RajPriye
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
taqyed
 

Recently uploaded (20)

Set off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptxSet off and carry forward of losses and assessment of individuals.pptx
Set off and carry forward of losses and assessment of individuals.pptx
 
Enterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdfEnterprise Excellence is Inclusive Excellence.pdf
Enterprise Excellence is Inclusive Excellence.pdf
 
BeMetals Presentation_May_22_2024 .pdf
BeMetals Presentation_May_22_2024   .pdfBeMetals Presentation_May_22_2024   .pdf
BeMetals Presentation_May_22_2024 .pdf
 
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdfMeas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
Meas_Dylan_DMBS_PB1_2024-05XX_Revised.pdf
 
Filing Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed GuideFiling Your Delaware Franchise Tax A Detailed Guide
Filing Your Delaware Franchise Tax A Detailed Guide
 
Sustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & EconomySustainability: Balancing the Environment, Equity & Economy
Sustainability: Balancing the Environment, Equity & Economy
 
What are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdfWhat are the main advantages of using HR recruiter services.pdf
What are the main advantages of using HR recruiter services.pdf
 
3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx3.0 Project 2_ Developing My Brand Identity Kit.pptx
3.0 Project 2_ Developing My Brand Identity Kit.pptx
 
The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...The Parable of the Pipeline a book every new businessman or business student ...
The Parable of the Pipeline a book every new businessman or business student ...
 
The-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic managementThe-McKinsey-7S-Framework. strategic management
The-McKinsey-7S-Framework. strategic management
 
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
RMD24 | Retail media: hoe zet je dit in als je geen AH of Unilever bent? Heid...
 
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptxCADAVER AS OUR FIRST TEACHER anatomt in your.pptx
CADAVER AS OUR FIRST TEACHER anatomt in your.pptx
 
Role of Remote Sensing and Monitoring in Mining
Role of Remote Sensing and Monitoring in MiningRole of Remote Sensing and Monitoring in Mining
Role of Remote Sensing and Monitoring in Mining
 
Improving profitability for small business
Improving profitability for small businessImproving profitability for small business
Improving profitability for small business
 
Attending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learnersAttending a job Interview for B1 and B2 Englsih learners
Attending a job Interview for B1 and B2 Englsih learners
 
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBdCree_Rey_BrandIdentityKit.PDF_PersonalBd
Cree_Rey_BrandIdentityKit.PDF_PersonalBd
 
FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134FINAL PRESENTATION.pptx12143241324134134
FINAL PRESENTATION.pptx12143241324134134
 
What is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdfWhat is the TDS Return Filing Due Date for FY 2024-25.pdf
What is the TDS Return Filing Due Date for FY 2024-25.pdf
 
Project File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdfProject File Report BBA 6th semester.pdf
Project File Report BBA 6th semester.pdf
 
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
一比一原版加拿大渥太华大学毕业证(uottawa毕业证书)如何办理
 

kubernetes_python_api_testing.pptx

  • 1. PYTHON FOR K8 API TESTING 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 2. INTRODUCTION • About the topic • Testing Kubernetes resources using python. • Testing Architecture Python Script Kubernetes-client Python compiler Kube config Kubernetes control plane API Server 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 3. PYTHON SETUP • Python CLI commands • Version • path • Python virtual environment • Activate virtual env • Deactivate Virtual env • Pip install • Install thirds party libraries • Install libraries from text file 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 4. PYTHON PEP8 • Docstrings • Linting • https://peps.python.org/pep-0008/ 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 5. PYTHON UNIT TEST ESSENTIALS • Decorator • It’s a wrapper to a function • Unit test • Test case for each function • Pytest • Third party tool for executing test case • Stestr • Third party tool for executing test case as a batch file 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 6. MOCKING IN UNIT TESTS • Mocks • It allows you to replace parts of your system under test with mock objects and make assertions about how they have been used 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 7. EXAMPLE FOR MOCKING • values = {'a': 1, 'b': 2, 'c': 3} • def side_effect(arg): • ... return values[arg] • mock.side_effect = side_effect • mock('a'), mock('b'), mock('c') (1, 2, 3) • mock.side_effect = [5, 4, 3, 2, 1] • mock(), mock(), mock() 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 8. PYTHON KUBERNETES ESSENTIALS • Yaml parser • Kube-config • Kubernetes-client • proxy setup 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 9. INTRODUCTION TO WHY KUBERNETES API TESTING • To make sure your new deployments are up and running • Could be that your APIs are behind a VPN or a firewall or you need a special kind of authentication • Differences in the various environments • Changes in APIs due to ongoing API development and the necessity to test multiple versions. 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 10. CONTEXT • To get the current context • To know on which cluster the context is • kubectl config get-contexts • config.list_kube_config_contexts() 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 11. NODES • To check the nodes states • listing the nodes • Describe the nodes • Parse the required parameter of node output • Node selector • state 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 12. RBAC ROLES • Permissions for namespaced resources • To list the roles • To create the roles • kubectl get rolebindings • client.RbacAuthorizationV1Api() 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 13. CLUSTER ROLES • Permissions at cluster level • We test the clusterrole bindings associated with the namespace. • kubectl get clusterroles • list_cluster_role() 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 14. NODE CERTIFICATES VALIDITY • By default, kubeadm generates all the certificates needed for a cluster to run. You can override this behaviour by providing your own certificates. • kubeadm certs check-expiration 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 15. NAMESPACES • To get list of all namespaces in cluster • We test our list of namespaces are present in the cluster • Kubectl get ns • list_namespace() 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 16. SERVICES • A service is a method for exposing a network application that is running as one or more pods in your cluster as an api • We test our namespace services are present in the namespace. • Check the endpoints are available • We do not guarantee that svc is functionally running. • Kubectl get svc • list_service_for_all_namespaces 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 17. PODS • A Pod is a group of one or more containers. • We test the pods are present and running state • Kubectl get pods • list_pod_for_all_namespaces 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 18. POD REPLICA • Replicaset will be indicating how many Pods it should be maintaining. • We test pod replicas present and matching with our count • Kubectl get pods • V1ReplicaSet 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 19. AGE OF PODS 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 20. CONFIGMAP • A ConfigMap is an API object used to store non-confidential data in key-value pairs • We test the presence of configmap • We test the data inside the configmap • Kubectl get configmap • list_namespaced_config_map 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 21. DEPLOYMENT • Deployment is controller of pods • We test the deployment is present in the given namespace. • Kubectl get deploy • list_deployment_for_all_namespaces 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 22. DEPLOYMENT SPECS • Specs are the other configurations related to the kind • We test the images names and selector in the deployments are as expected • Pythonic code to traverse the deployment output 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 23. SECRETS • A Secret is an object that contains a small amount of sensitive data such as a password • We test the presence of secret in the namespace • We can’t decrypt the secret so we cant guarantee the data behind • Kubectl get secrets 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 24. VOLUMES • A volume is a directory, possibly with some data in it, which is accessible to the containers in a pod. • Kubectl get pvc 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 25. STATEFULSET • StatefulSet manages Pods that are based on an identical container spec • We test the presence of statefullset in the namespace • Kubectl get sts 2023 © Visualpath All Rights Reserved. | Designed By Visualpath