SlideShare a Scribd company logo
K8S FOR K8 API TESTING
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
INTRODUCTION
• About the topic
• Testing done Kubernetes resources using pytjhfjyhon.
• 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
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
• 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 containers.
• We 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 directoryin it, which is accessible to the containers in a pod.
2023 © Visualpath All Rights Reserved. | Designed By Visualpath
STATEFULSET
• StatefulSet manages Pods that are
• We statefullset in the namespace
• Kubectl
2023 © Visualpath All Rights Reserved. | Designed By Visualpath

More Related Content

Similar to api_testing_k8s.pptx

Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue
 
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
HostedbyConfluent
 
KubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep diveKubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep dive
Bob Cotton
 
AKS
AKSAKS
KCD2022 Predictive Autoscaling Patterns in k8s.pdf
KCD2022 Predictive Autoscaling Patterns in k8s.pdfKCD2022 Predictive Autoscaling Patterns in k8s.pdf
KCD2022 Predictive Autoscaling Patterns in k8s.pdf
RobertoCarratalaSanc1
 
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
 
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
 
Introduction to Virtual Kubelet
Introduction to Virtual KubeletIntroduction to Virtual Kubelet
Introduction to Virtual Kubelet
Mitchell Pronschinske
 
Kubernetes and devops
Kubernetes and devopsKubernetes and devops
Kubernetes and devops
macchiang
 
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
 
Kubernetes on aws
Kubernetes on awsKubernetes on aws
Kubernetes on aws
Yousun Jeong
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
Sveta Smirnova
 
A Kubernetes CAPI Provider for Apache CloudStack
A Kubernetes CAPI Provider for Apache CloudStackA Kubernetes CAPI Provider for Apache CloudStack
A Kubernetes CAPI Provider for Apache CloudStack
ShapeBlue
 
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueCloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
ShapeBlue
 
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
 
[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
 
Knative with .NET Core and Quarkus with GraalVM
Knative with .NET Core and Quarkus with GraalVMKnative with .NET Core and Quarkus with GraalVM
Knative with .NET Core and Quarkus with GraalVM
Mark Lechtermann
 
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
AKS - Azure Kubernetes Services  - kubernetes meetup may 2018AKS - Azure Kubernetes Services  - kubernetes meetup may 2018
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
Jorge Arteiro
 
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
 
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
 

Similar to api_testing_k8s.pptx (20)

Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
 
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
 
KubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep diveKubeCon Prometheus Salon -- Kubernetes metrics deep dive
KubeCon Prometheus Salon -- Kubernetes metrics deep dive
 
AKS
AKSAKS
AKS
 
KCD2022 Predictive Autoscaling Patterns in k8s.pdf
KCD2022 Predictive Autoscaling Patterns in k8s.pdfKCD2022 Predictive Autoscaling Patterns in k8s.pdf
KCD2022 Predictive Autoscaling Patterns in k8s.pdf
 
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
 
The Kubernetes WebLogic revival (part 2)
The Kubernetes WebLogic revival (part 2)The Kubernetes WebLogic revival (part 2)
The Kubernetes WebLogic revival (part 2)
 
Introduction to Virtual Kubelet
Introduction to Virtual KubeletIntroduction to Virtual Kubelet
Introduction to Virtual Kubelet
 
Kubernetes and devops
Kubernetes and devopsKubernetes and devops
Kubernetes and devops
 
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”.
 
Kubernetes on aws
Kubernetes on awsKubernetes on aws
Kubernetes on aws
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
 
A Kubernetes CAPI Provider for Apache CloudStack
A Kubernetes CAPI Provider for Apache CloudStackA Kubernetes CAPI Provider for Apache CloudStack
A Kubernetes CAPI Provider for Apache CloudStack
 
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlueCloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
CloudStack Tooling Ecosystem – Kiran Chavala, ShapeBlue
 
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
 
[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
 
Knative with .NET Core and Quarkus with GraalVM
Knative with .NET Core and Quarkus with GraalVMKnative with .NET Core and Quarkus with GraalVM
Knative with .NET Core and Quarkus with GraalVM
 
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
AKS - Azure Kubernetes Services  - kubernetes meetup may 2018AKS - Azure Kubernetes Services  - kubernetes meetup may 2018
AKS - Azure Kubernetes Services - kubernetes meetup may 2018
 
Setup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes FederationSetup Hybrid Clusters Using Kubernetes Federation
Setup Hybrid Clusters Using Kubernetes Federation
 
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
 

Recently uploaded

Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
Oppotus
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
NABLAS株式会社
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Subhajit Sahu
 
Tabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsTabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflows
alex933524
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Subhajit Sahu
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
TravisMalana
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
ewymefz
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
James Polillo
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Linda486226
 

Recently uploaded (20)

Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
【社内勉強会資料_Octo: An Open-Source Generalist Robot Policy】
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
Algorithmic optimizations for Dynamic Levelwise PageRank (from STICD) : SHORT...
 
Tabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsTabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflows
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
Levelwise PageRank with Loop-Based Dead End Handling Strategy : SHORT REPORT ...
 
Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)Malana- Gimlet Market Analysis (Portfolio 2)
Malana- Gimlet Market Analysis (Portfolio 2)
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证成绩单
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdfSample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
Sample_Global Non-invasive Prenatal Testing (NIPT) Market, 2019-2030.pdf
 

api_testing_k8s.pptx

  • 1. K8S FOR K8 API TESTING 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 2. INTRODUCTION • About the topic • Testing done Kubernetes resources using pytjhfjyhon. • 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 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 • 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 containers. • We 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 directoryin it, which is accessible to the containers in a pod. 2023 © Visualpath All Rights Reserved. | Designed By Visualpath
  • 25. STATEFULSET • StatefulSet manages Pods that are • We statefullset in the namespace • Kubectl 2023 © Visualpath All Rights Reserved. | Designed By Visualpath