SlideShare a Scribd company logo
LEVERAGINGLEVERAGING
EPHEMERAL NAMESPACESEPHEMERAL NAMESPACES
IN A CI/CD PIPELINEIN A CI/CD PIPELINE
Can Yücel (@canthefason)
Senior Software Engineer
KubeCon EU 2016
HighlightsHighlights
Fundamentals of namespaces
Breaking the idea of having separate clusters
Ephemeral namespaces
Talk about some Kubernetes early stage features
Running every single piece as Kubernetes components
NamespacesNamespaces
“ A namespace is a mechanism to partition resources
created by users into a logically named group.
~ Kubernetes Docs
Isolation on Different LevelsIsolation on Different Levels
Network level isolation
Access policies
Resource control
Network Level IsolationNetwork Level Isolation
Leveraging subdomainsLeveraging subdomains
Access PoliciesAccess Policies
{"user":"admin"}
{"user":"scheduler", "readonly": true, "resource": "pods"}
{"user":"scheduler", "resource": "bindings"}
{"user":"proxy", "resource": "services"}
{"user":"proxy", "resource": "endpoints"}
{"user":"kubelet", "resource": "pods"}
{"user":"kubelet", "resource": "nodes"}
{"user":"kubelet", "readonly": true, "resource": "services"}
{"user":"kubelet", "readonly": true, "resource": "endpoints"}
{"user":"kubelet", "resource": "events"}
{"user":"bob", "readonly": true, "namespace": "prod"}
{"user":"alice", "namespace": "prod"}
policy.jsonl
ABAC provides much more granularity on policy
management
Resource ControlResource Control
apiVersion: v1
kind: ResourceQuota
metadata:
name: quota
spec:
- hard:
memory: "1Gi"
cpu: 20
pods: 15
services: 5
replicationcontrollers: 10
resourcequotas: 1
Cluster:
32 GB RAM, and 16 cores
Team A:
20 GB RAM, and 10 cores
Team B:
10 GB RAM, and 4 cores
How to Partition?How to Partition?
Environment based partitioningEnvironment based partitioning
qa, stage, production...
System / team based partitioningSystem / team based partitioning
kube-system, devops, bots
Project based partitioningProject based partitioning
example.com, better-example.com
A Day of a CI/CD PipelineA Day of a CI/CD Pipeline
Provision separate machines for every build
Run your tests on isolated clusters
When all tests are successful tear down the cluster
If it fails keep the cluster up for a while for debugging
Ephemeral Namespaces!Ephemeral Namespaces!
namespaces
namespaces
namespace
Ephemeral Namespaces AreEphemeral Namespaces Are
Isolated environments that are running different versions
of services on top of it
The environments where we run our integrations/e2e tests,
and gets dumped when we get the end results
Namespaces with Benefits!Namespaces with Benefits!
Time effective provisioning
Efficient resource utilization
In a CI/CD pipeline, namespaces provide:In a CI/CD pipeline, namespaces provide:
Time Effective ProvisioningTime Effective Provisioning
It takes only a couple of seconds to create all
services
Efficient Resource UtilizationEfficient Resource Utilization
Let your scheduler decide on which
host you will run your test
instances
Deployment ProcessDeployment Process
1. Run your unit tests
2. Build Docker Image
3. Deploy to sandbox
4. Provision services that you will run your
tests against
5. Run your integration/e2e tests
6. Delete namespace
7. Deploy updated services to staging/prod
Happy Path!
Provisioning Test EnvironmentsProvisioning Test Environments
Identical environments with different versions!
Pods From Different NamespacesPods From Different Namespaces
➜ kubectl get po --namespace=e2e-1
NAME READY STATUS RESTARTS AGE
mongo-oij3f 1/1 Running 0 10m
nginx-44k6p 1/1 Running 0 10m
selenium-9bcfc 1/1 Running 0 10m
todo-service-phgrb 1/1 Running 0 10m
todo-service-rbrjl 1/1 Running 0 10m
➜ kubectl get po --namespace=e2e-2
NAME READY STATUS RESTARTS AGE
mongo-p6g8c 1/1 Running 0 5m
nginx-mgdzz 1/1 Running 0 5m
selenium-9l81p 1/1 Running 0 5m
todo-service-mt9gh 1/1 Running 0 5m
todo-service-yxo9v 1/1 Running 0 5m
➜ kubectl get po --namespace=e2e-3
NAME READY STATUS RESTARTS AGE
mongo-llm3x 1/1 Running 0 1m
nginx-vvov6 1/1 Running 0 1m
nightwatch 1/1 Running 0 34s
selenium-g2g1i 1/1 Running 0 1m
todo-service-1k8vc 1/1 Running 0 1m
todo-service-ddfjw 1/1 Running 0 1m
Adding E2E Components as PodsAdding E2E Components as Pods
Selenium server
Nightwatch.js scripts
All Tests PassedAll Tests Passed ✓✓
$ kubectl delete namespace e2e-10
It will dump every Kubernetes component
within that namespace!
Test Gets FailedTest Gets Failed 😞
Find a way to connect to the Selenium Server for
debugging
Expose VNC Port 5900​
kubectl port-forward selenium :5900 --namespace=e2e-1
Live In ActionLive In Action
How We Use GoCDHow We Use GoCD
Idempotent pipeline stages
Dependency management is handled with fan-in
resolution
Evaluating DependenciesEvaluating Dependencies
Text
GO_DEPENDENCY_LABEL_E2E=5.2eedd92
GO_DEPENDENCY_LOCATOR_E2E=e2e-tests/5/buildImage/1
GO_DEPENDENCY_LABEL_TODO=35.86ca86c
GO_DEPENDENCY_LOCATOR_TODO=todo-service/35/deployK8s/1
GO_DEPENDENCY_LABEL_NGINX=12.4288a7c
GO_DEPENDENCY_LOCATOR_NGINX=nginx/12/deployK8s/1
Each GO_DEPENDENCY variable has
dependant pipeline information
For Provisioning Test Environments: Create all dependencies
For Deployment: Compare versions and call create/rolling
update
Running Every Piece in PodsRunning Every Piece in Pods
Nightwatch scripts
kubectl run -i -tty nightwatch --image=canthefason/e2e-tests:$E2E_IMAGE_TAG 
--restart=Never --namespace=e2e-$GO_PIPELINE_LABEL
state=$(kubectl get -o template po nightwatch $kubeargs 
--template={{.status.phase}})
while [ "$state" == "Running" ]; do
sleep 5
echo "waiting for the state"
state=$(kubectl get -o template po nightwatch $kubeargs 
--template={{.status.phase}})
done
echo "State: $state"
if [ "$state" == "Failed" ]; then
exit 1
fi
Running Every Piece in PodsRunning Every Piece in Pods
Selenium manifest
apiVersion: v1
kind: ReplicationController
metadata:
name: selenium
spec:
replicas: 1
selector:
app: selenium
template:
metadata:
name: selenium
labels:
app: selenium
spec:
volumes:
- name: shm
hostPath:
path: /dev/shm
containers:
- name: selenium
image: selenium/standalone-chrome-debug:2.52.0
ports:
- containerPort: 4444
- containerPort: 5900
imagePullPolicy: Always
volumeMounts:
- name: shm
mountPath: /dev/shm
Health CheckersHealth Checkers
Text
curl -k --retry 10 --retry-delay 5 -v 
https://$KUBE_HOST/api/v1/proxy/namespaces/sandbox/services/todo/ping
curl -k --silent --output /dev/stderr --write-out "%{http_code}" -v 
https://$KUBE_HOST/api/v1/proxy/namespaces/sandbox/services/todo/ping
if [ "$STATUSCODE" -ne "200" ]; then
if [ "$rcExist" != "ReplicationController" ]; then
kubectl delete -f scripts/rc.yml $kubeargs
fi
exit 1
fi
Future WorkFuture Work
Scale down the pods when the namespace is idle
Automatically delete namespaces that are older
than certain age
Build a Selenium Grid infrastructure and utilize
Selenium Agents among the namespaces
TakeawaysTakeaways
Never ever expose your Apiserver 8080 port!
Think twice before defining your ssh keys as
secrets!
Make sure that you properly setup kubelet
garbage collectors
--maximum-dead-containers=100
--maximum-dead-containers-per-container=2
--minimum-container-ttl-duration=1m0s
LinksLinks
http://github.com/canthefason/kubecon
https://github.com/kubernetes/contrib
Thanks ToThanks To
Kubernetes Team
LaunchPad Central
Quest Henkart
UK Consulate in NY...
Q & AQ & A
Twitter: @canthefason
GitHub: /canthefason

More Related Content

PPTX
KubeCon EU 2016: Transforming the Government
PDF
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
PDF
KubeCon EU 2016: Using Traffic Control to Test Apps in Kubernetes
PDF
Deep dive in container service discovery
PPTX
How to Achieve Canary Deployment on Kubernetes
PPTX
Lifecycle of a pod
PDF
Making kubernetes simple for developers
PDF
KubeCon EU 2016: Templatized Application Configuration on OpenShift and Kuber...
KubeCon EU 2016: Transforming the Government
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Using Traffic Control to Test Apps in Kubernetes
Deep dive in container service discovery
How to Achieve Canary Deployment on Kubernetes
Lifecycle of a pod
Making kubernetes simple for developers
KubeCon EU 2016: Templatized Application Configuration on OpenShift and Kuber...

What's hot (20)

PPTX
Scaling Jenkins with Kubernetes by Ami Mahloof
PDF
Kubernetes debug like a pro
PDF
05.10.2017 AWS User Group Meetup - FALLACIES OF DISTRIBUTED COMPUTING WITH KU...
PDF
Introduction to CircleCI
PDF
DockerCon EU 2015: Trading Bitcoin with Docker
PPTX
Cloud Native Okteto Cloud
PDF
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
PDF
Kernel load-balancing for Docker containers using IPVS
PDF
Kubernetes 101 and Fun
PPTX
Kubernetes101 - Pune Kubernetes Meetup 6
PDF
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
PDF
KubeCon EU 2016: "rktnetes": what's new with container runtimes and Kubernetes
PDF
Running Kubernetes in Production: A Million Ways to Crash Your Cluster - DevO...
PPTX
Kubernetes @ Nanit by Chen Fisher
PDF
Docker Athens: Docker Engine Evolution & Containerd Use Cases
PDF
DevOps Fest 2020. Сергій Калінець. Building Data Streaming Platform with Apac...
PDF
Zero downtime deployment of micro-services with Kubernetes
PDF
KubeCon EU 2016: Killing containers to make weather beautiful
PDF
Cantainer CI/ CD with Kubernetes
PDF
KubeCon EU 2016: ITNW (If This Now What): Orchestrating an Enterprise
Scaling Jenkins with Kubernetes by Ami Mahloof
Kubernetes debug like a pro
05.10.2017 AWS User Group Meetup - FALLACIES OF DISTRIBUTED COMPUTING WITH KU...
Introduction to CircleCI
DockerCon EU 2015: Trading Bitcoin with Docker
Cloud Native Okteto Cloud
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
Kernel load-balancing for Docker containers using IPVS
Kubernetes 101 and Fun
Kubernetes101 - Pune Kubernetes Meetup 6
Kubernetes上で動作する機械学習モジュールの配信&管理基盤Rekcurd について
KubeCon EU 2016: "rktnetes": what's new with container runtimes and Kubernetes
Running Kubernetes in Production: A Million Ways to Crash Your Cluster - DevO...
Kubernetes @ Nanit by Chen Fisher
Docker Athens: Docker Engine Evolution & Containerd Use Cases
DevOps Fest 2020. Сергій Калінець. Building Data Streaming Platform with Apac...
Zero downtime deployment of micro-services with Kubernetes
KubeCon EU 2016: Killing containers to make weather beautiful
Cantainer CI/ CD with Kubernetes
KubeCon EU 2016: ITNW (If This Now What): Orchestrating an Enterprise
Ad

Similar to KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline (20)

PDF
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
PDF
Kubernetes
PPTX
Automating Software Development Life Cycle - A DevOps Approach
PPTX
KVM and docker LXC Benchmarking with OpenStack
PDF
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
PDF
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
PPTX
Jenkins days workshop pipelines - Eric Long
PDF
Production sec ops with kubernetes in docker
PDF
Fabric8: Better Software Faster with Docker, Kubernetes, Jenkins
PPTX
Yet Another Session about Docker and Containers​
PDF
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
PDF
Kubernetes for Java developers
PDF
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...
PPTX
Deploying your web application with AWS ElasticBeanstalk
PPTX
Pipeline as code - new feature in Jenkins 2
PDF
Containerised Testing at Demonware : PyCon Ireland 2016
PDF
Cluster management with Kubernetes
PPTX
K8s in 3h - Kubernetes Fundamentals Training
PDF
Kubernetes: training micro-dragons for a serious battle
PPTX
Deploying windows containers with kubernetes
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
Kubernetes
Automating Software Development Life Cycle - A DevOps Approach
KVM and docker LXC Benchmarking with OpenStack
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Jenkins days workshop pipelines - Eric Long
Production sec ops with kubernetes in docker
Fabric8: Better Software Faster with Docker, Kubernetes, Jenkins
Yet Another Session about Docker and Containers​
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
Kubernetes for Java developers
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...
Deploying your web application with AWS ElasticBeanstalk
Pipeline as code - new feature in Jenkins 2
Containerised Testing at Demonware : PyCon Ireland 2016
Cluster management with Kubernetes
K8s in 3h - Kubernetes Fundamentals Training
Kubernetes: training micro-dragons for a serious battle
Deploying windows containers with kubernetes
Ad

More from KubeAcademy (20)

PDF
KubeCon EU 2016: Distributed containers in the physical world
PDF
KubeCon EU 2016:
PDF
KubeCon EU 2016: ChatOps and Automatic Deployment on Kubernetes
PDF
KubeCon EU 2016: A Practical Guide to Container Scheduling
PDF
KubeCon EU 2016: Trading in the Kube
ODP
KubeCon EU 2016: Integrated trusted computing in Kubernetes
PPTX
KubeCon EU 2016: Secure, Cloud-Native Networking with Project Calico
PDF
KubeCon EU 2016: Heroku to Kubernetes
PDF
KubeCon EU 2016: Kubernetes Storage 101
PDF
KubeCon EU 2016: Kubernetes in Production in The New York Times newsroom
PDF
KubeCon EU 2016: SmartCity IoT on Kubernetes
PDF
KubeCon EU 2016 Keynote: Pushing Kubernetes Forward
PDF
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
PPTX
KubeCon EU 2016: Multi-Tenant Kubernetes
PDF
KubeCon EU 2016: Bringing an open source Containerized Container Platform to ...
PDF
KubeCon EU 2016: Full Automatic Database: PostgreSQL HA with Kubernetes
PDF
KubeCon EU 2016: A lightweight deployment system for appops
PDF
KubeCon EU 2016: Scaling Open edX with Kubernetes
PDF
KubeCon EU 2016: Custom Volume Plugins
PDF
KubeCon EU 2016: What is OpenStack's role in a Kubernetes world?
KubeCon EU 2016: Distributed containers in the physical world
KubeCon EU 2016:
KubeCon EU 2016: ChatOps and Automatic Deployment on Kubernetes
KubeCon EU 2016: A Practical Guide to Container Scheduling
KubeCon EU 2016: Trading in the Kube
KubeCon EU 2016: Integrated trusted computing in Kubernetes
KubeCon EU 2016: Secure, Cloud-Native Networking with Project Calico
KubeCon EU 2016: Heroku to Kubernetes
KubeCon EU 2016: Kubernetes Storage 101
KubeCon EU 2016: Kubernetes in Production in The New York Times newsroom
KubeCon EU 2016: SmartCity IoT on Kubernetes
KubeCon EU 2016 Keynote: Pushing Kubernetes Forward
KubeCon EU 2016: Creating an Advanced Load Balancing Solution for Kubernetes ...
KubeCon EU 2016: Multi-Tenant Kubernetes
KubeCon EU 2016: Bringing an open source Containerized Container Platform to ...
KubeCon EU 2016: Full Automatic Database: PostgreSQL HA with Kubernetes
KubeCon EU 2016: A lightweight deployment system for appops
KubeCon EU 2016: Scaling Open edX with Kubernetes
KubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: What is OpenStack's role in a Kubernetes world?

Recently uploaded (20)

PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
PDF
KodekX | Application Modernization Development
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Modernizing your data center with Dell and AMD
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf
KodekX | Application Modernization Development
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
“AI and Expert System Decision Support & Business Intelligence Systems”
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
GamePlan Trading System Review: Professional Trader's Honest Take
Modernizing your data center with Dell and AMD

KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline

  • 1. LEVERAGINGLEVERAGING EPHEMERAL NAMESPACESEPHEMERAL NAMESPACES IN A CI/CD PIPELINEIN A CI/CD PIPELINE Can Yücel (@canthefason) Senior Software Engineer KubeCon EU 2016
  • 2. HighlightsHighlights Fundamentals of namespaces Breaking the idea of having separate clusters Ephemeral namespaces Talk about some Kubernetes early stage features Running every single piece as Kubernetes components
  • 3. NamespacesNamespaces “ A namespace is a mechanism to partition resources created by users into a logically named group. ~ Kubernetes Docs
  • 4. Isolation on Different LevelsIsolation on Different Levels Network level isolation Access policies Resource control
  • 5. Network Level IsolationNetwork Level Isolation Leveraging subdomainsLeveraging subdomains
  • 6. Access PoliciesAccess Policies {"user":"admin"} {"user":"scheduler", "readonly": true, "resource": "pods"} {"user":"scheduler", "resource": "bindings"} {"user":"proxy", "resource": "services"} {"user":"proxy", "resource": "endpoints"} {"user":"kubelet", "resource": "pods"} {"user":"kubelet", "resource": "nodes"} {"user":"kubelet", "readonly": true, "resource": "services"} {"user":"kubelet", "readonly": true, "resource": "endpoints"} {"user":"kubelet", "resource": "events"} {"user":"bob", "readonly": true, "namespace": "prod"} {"user":"alice", "namespace": "prod"} policy.jsonl ABAC provides much more granularity on policy management
  • 7. Resource ControlResource Control apiVersion: v1 kind: ResourceQuota metadata: name: quota spec: - hard: memory: "1Gi" cpu: 20 pods: 15 services: 5 replicationcontrollers: 10 resourcequotas: 1 Cluster: 32 GB RAM, and 16 cores Team A: 20 GB RAM, and 10 cores Team B: 10 GB RAM, and 4 cores
  • 8. How to Partition?How to Partition? Environment based partitioningEnvironment based partitioning qa, stage, production... System / team based partitioningSystem / team based partitioning kube-system, devops, bots Project based partitioningProject based partitioning example.com, better-example.com
  • 9. A Day of a CI/CD PipelineA Day of a CI/CD Pipeline Provision separate machines for every build Run your tests on isolated clusters When all tests are successful tear down the cluster If it fails keep the cluster up for a while for debugging Ephemeral Namespaces!Ephemeral Namespaces! namespaces namespaces namespace
  • 10. Ephemeral Namespaces AreEphemeral Namespaces Are Isolated environments that are running different versions of services on top of it The environments where we run our integrations/e2e tests, and gets dumped when we get the end results
  • 11. Namespaces with Benefits!Namespaces with Benefits! Time effective provisioning Efficient resource utilization In a CI/CD pipeline, namespaces provide:In a CI/CD pipeline, namespaces provide:
  • 12. Time Effective ProvisioningTime Effective Provisioning It takes only a couple of seconds to create all services
  • 13. Efficient Resource UtilizationEfficient Resource Utilization Let your scheduler decide on which host you will run your test instances
  • 14. Deployment ProcessDeployment Process 1. Run your unit tests 2. Build Docker Image 3. Deploy to sandbox 4. Provision services that you will run your tests against 5. Run your integration/e2e tests 6. Delete namespace 7. Deploy updated services to staging/prod Happy Path!
  • 15. Provisioning Test EnvironmentsProvisioning Test Environments Identical environments with different versions!
  • 16. Pods From Different NamespacesPods From Different Namespaces ➜ kubectl get po --namespace=e2e-1 NAME READY STATUS RESTARTS AGE mongo-oij3f 1/1 Running 0 10m nginx-44k6p 1/1 Running 0 10m selenium-9bcfc 1/1 Running 0 10m todo-service-phgrb 1/1 Running 0 10m todo-service-rbrjl 1/1 Running 0 10m ➜ kubectl get po --namespace=e2e-2 NAME READY STATUS RESTARTS AGE mongo-p6g8c 1/1 Running 0 5m nginx-mgdzz 1/1 Running 0 5m selenium-9l81p 1/1 Running 0 5m todo-service-mt9gh 1/1 Running 0 5m todo-service-yxo9v 1/1 Running 0 5m ➜ kubectl get po --namespace=e2e-3 NAME READY STATUS RESTARTS AGE mongo-llm3x 1/1 Running 0 1m nginx-vvov6 1/1 Running 0 1m nightwatch 1/1 Running 0 34s selenium-g2g1i 1/1 Running 0 1m todo-service-1k8vc 1/1 Running 0 1m todo-service-ddfjw 1/1 Running 0 1m
  • 17. Adding E2E Components as PodsAdding E2E Components as Pods Selenium server Nightwatch.js scripts
  • 18. All Tests PassedAll Tests Passed ✓✓ $ kubectl delete namespace e2e-10 It will dump every Kubernetes component within that namespace!
  • 19. Test Gets FailedTest Gets Failed 😞 Find a way to connect to the Selenium Server for debugging Expose VNC Port 5900​ kubectl port-forward selenium :5900 --namespace=e2e-1
  • 20. Live In ActionLive In Action
  • 21. How We Use GoCDHow We Use GoCD Idempotent pipeline stages Dependency management is handled with fan-in resolution
  • 23. Running Every Piece in PodsRunning Every Piece in Pods Nightwatch scripts kubectl run -i -tty nightwatch --image=canthefason/e2e-tests:$E2E_IMAGE_TAG --restart=Never --namespace=e2e-$GO_PIPELINE_LABEL state=$(kubectl get -o template po nightwatch $kubeargs --template={{.status.phase}}) while [ "$state" == "Running" ]; do sleep 5 echo "waiting for the state" state=$(kubectl get -o template po nightwatch $kubeargs --template={{.status.phase}}) done echo "State: $state" if [ "$state" == "Failed" ]; then exit 1 fi
  • 24. Running Every Piece in PodsRunning Every Piece in Pods Selenium manifest apiVersion: v1 kind: ReplicationController metadata: name: selenium spec: replicas: 1 selector: app: selenium template: metadata: name: selenium labels: app: selenium spec: volumes: - name: shm hostPath: path: /dev/shm containers: - name: selenium image: selenium/standalone-chrome-debug:2.52.0 ports: - containerPort: 4444 - containerPort: 5900 imagePullPolicy: Always volumeMounts: - name: shm mountPath: /dev/shm
  • 25. Health CheckersHealth Checkers Text curl -k --retry 10 --retry-delay 5 -v https://$KUBE_HOST/api/v1/proxy/namespaces/sandbox/services/todo/ping curl -k --silent --output /dev/stderr --write-out "%{http_code}" -v https://$KUBE_HOST/api/v1/proxy/namespaces/sandbox/services/todo/ping if [ "$STATUSCODE" -ne "200" ]; then if [ "$rcExist" != "ReplicationController" ]; then kubectl delete -f scripts/rc.yml $kubeargs fi exit 1 fi
  • 26. Future WorkFuture Work Scale down the pods when the namespace is idle Automatically delete namespaces that are older than certain age Build a Selenium Grid infrastructure and utilize Selenium Agents among the namespaces
  • 27. TakeawaysTakeaways Never ever expose your Apiserver 8080 port! Think twice before defining your ssh keys as secrets! Make sure that you properly setup kubelet garbage collectors --maximum-dead-containers=100 --maximum-dead-containers-per-container=2 --minimum-container-ttl-duration=1m0s
  • 29. Thanks ToThanks To Kubernetes Team LaunchPad Central Quest Henkart UK Consulate in NY...
  • 30. Q & AQ & A Twitter: @canthefason GitHub: /canthefason