Managing Kubernetes from Python using Kube
-
Upload
david-charles -
Category
Software
-
view
84 -
download
0
Transcript of Managing Kubernetes from Python using Kube
![Page 1: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/1.jpg)
Managing Kubernetesfrom Python with Kube
Dave Charles@cobecto
![Page 2: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/2.jpg)
![Page 3: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/3.jpg)
Benefits
![Page 4: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/4.jpg)
![Page 5: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/5.jpg)
![Page 6: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/6.jpg)
Benefits
![Page 7: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/7.jpg)
Downsides?
![Page 8: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/8.jpg)
Kubernetes
K8s
![Page 9: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/9.jpg)
MASTER
NODE NODE NODE
CLUSTER
![Page 10: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/10.jpg)
MASTER
ETCDAPI
SERVERCONTROLLER
MANAGER SCHEDULER
![Page 11: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/11.jpg)
MASTER
ETCDAPI
SERVERCONTROLLER
MANAGER SCHEDULER
Distributed key value store: K8s
STATE
![Page 12: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/12.jpg)
MASTER
ETCDAPI
SERVERCONTROLLER
MANAGER SCHEDULER
ReST API through which all K8s components
interact
![Page 13: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/13.jpg)
MASTER
ETCDAPI
SERVERCONTROLLER
MANAGER SCHEDULER
Runs controllers that drive K8s state towards specification
![Page 14: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/14.jpg)
MASTER
ETCDAPI
SERVERCONTROLLER
MANAGER SCHEDULER
Applies policies to allocate work
across the cluster
![Page 15: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/15.jpg)
NODE
DOCKER KUBELET PROXY
![Page 16: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/16.jpg)
NODE
Container runtime
DOCKER KUBELET PROXY
![Page 17: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/17.jpg)
NODE
Communicates with master to
facilitate container
orchestration
DOCKER KUBELET PROXY
![Page 18: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/18.jpg)
NODE
Networking magic, reflects
services defined
DOCKER KUBELET PROXY
![Page 19: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/19.jpg)
NODE
MASTER
POD 1
container1
container2
POD 2
container3
NODEPOD 1
container1
container2
NODEPOD 2
container3
![Page 20: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/20.jpg)
API SERVER
SCHEDULER
CONTROLLER
users control plane clusterNODE
NODE
NODE
kubelet
registry
APICLIENT
UI
![Page 21: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/21.jpg)
API SERVER
SCHEDULER
CONTROLLER
users control plane clusterNODE
NODE
NODE
kubelet
registrykubectl run nginx:v1
![Page 22: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/22.jpg)
API SERVER
SCHEDULER
CONTROLLER
users control plane clusterNODE
NODE
NODE
kubelet
registrykubectl run nginx:v1
status
![Page 23: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/23.jpg)
API SERVER
SCHEDULER
CONTROLLER
users control plane clusterNODE
NODE
NODE
kubelet
registry
status
status
![Page 24: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/24.jpg)
API SERVER
SCHEDULER
CONTROLLER
users control plane clusterNODE
NODE
NODE
registry
![Page 25: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/25.jpg)
• NAMESPACE• Provides multiple virtual clusters backed by
the same physical cluster• “default” by, well, default
Some Terminology
![Page 26: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/26.jpg)
• POD• Encapsulate containers and volumes• Atomic unit of replication and placement• A logical host
Some Terminology
![Page 27: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/27.jpg)
• Replication Controllers• Ensure n copies of a POD• Will drive current state towards desired state• If too few replicas, will create new ones• If too many, will destroy some• Used for scaling up, down and rolling
updates
Some Terminology
![Page 28: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/28.jpg)
• Services• Targets group of pods with label selectors• Pods get their own IP, but they cannot be
relied upon to be stable over time• Services provide a stable endpoint so that
ephemeral pods can be found and accessed.
Some Terminology
![Page 29: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/29.jpg)
https://bitbucket.org/cobeio/kube
http://python-kube.readthedocs.io/en/latest/
https://github.com/davecharles/kube_workshop
![Page 30: Managing Kubernetes from Python using Kube](https://reader030.fdocuments.us/reader030/viewer/2022020213/5886a7a61a28ab0c1d8b7631/html5/thumbnails/30.jpg)
https://www.infoq.com/presentations/7-sins-microservices
http://martinfowler.com/articles/microservices.html
https://www.nginx.com/blog/microservices-at-netflix-architectural-best-practices/
https://bitbucket.org/cobeio/kube