30
Managing Kubernetes from Python with Kube Dave Charles @cobecto

Managing Kubernetes from Python using Kube

Embed Size (px)

Citation preview

Page 1: Managing Kubernetes from Python using Kube

Managing Kubernetesfrom Python with Kube

Dave Charles@cobecto

Page 2: Managing Kubernetes from Python using Kube
Page 3: Managing Kubernetes from Python using Kube

Benefits

Page 4: Managing Kubernetes from Python using Kube
Page 5: Managing Kubernetes from Python using Kube
Page 6: Managing Kubernetes from Python using Kube

Benefits

Page 7: Managing Kubernetes from Python using Kube

Downsides?

Page 8: Managing Kubernetes from Python using Kube

Kubernetes

K8s

Page 9: Managing Kubernetes from Python using Kube

MASTER

NODE NODE NODE

CLUSTER

Page 10: Managing Kubernetes from Python using Kube

MASTER

ETCDAPI

SERVERCONTROLLER

MANAGER SCHEDULER

Page 11: Managing Kubernetes from Python using Kube

MASTER

ETCDAPI

SERVERCONTROLLER

MANAGER SCHEDULER

Distributed key value store: K8s

STATE

Page 12: Managing Kubernetes from Python using Kube

MASTER

ETCDAPI

SERVERCONTROLLER

MANAGER SCHEDULER

ReST API through which all K8s components

interact

Page 13: Managing Kubernetes from Python using Kube

MASTER

ETCDAPI

SERVERCONTROLLER

MANAGER SCHEDULER

Runs controllers that drive K8s state towards specification

Page 14: Managing Kubernetes from Python using Kube

MASTER

ETCDAPI

SERVERCONTROLLER

MANAGER SCHEDULER

Applies policies to allocate work

across the cluster

Page 15: Managing Kubernetes from Python using Kube

NODE

DOCKER KUBELET PROXY

Page 16: Managing Kubernetes from Python using Kube

NODE

Container runtime

DOCKER KUBELET PROXY

Page 17: Managing Kubernetes from Python using Kube

NODE

Communicates with master to

facilitate container

orchestration

DOCKER KUBELET PROXY

Page 18: Managing Kubernetes from Python using Kube

NODE

Networking magic, reflects

services defined

DOCKER KUBELET PROXY

Page 19: Managing Kubernetes from Python using Kube

NODE

MASTER

POD 1

container1

container2

POD 2

container3

NODEPOD 1

container1

container2

NODEPOD 2

container3

Page 20: Managing Kubernetes from Python using Kube

API SERVER

SCHEDULER

CONTROLLER

users control plane clusterNODE

NODE

NODE

kubelet

registry

APICLIENT

UI

Page 21: Managing Kubernetes from Python using Kube

API SERVER

SCHEDULER

CONTROLLER

users control plane clusterNODE

NODE

NODE

kubelet

registrykubectl run nginx:v1

Page 22: Managing Kubernetes from Python using Kube

API SERVER

SCHEDULER

CONTROLLER

users control plane clusterNODE

NODE

NODE

kubelet

registrykubectl run nginx:v1

status

Page 23: Managing Kubernetes from Python using Kube

API SERVER

SCHEDULER

CONTROLLER

users control plane clusterNODE

NODE

NODE

kubelet

registry

status

status

Page 24: Managing Kubernetes from Python using Kube

API SERVER

SCHEDULER

CONTROLLER

users control plane clusterNODE

NODE

NODE

registry

Page 25: Managing Kubernetes from Python using Kube

• 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

• POD• Encapsulate containers and volumes• Atomic unit of replication and placement• A logical host

Some Terminology

Page 27: Managing Kubernetes from Python using Kube

• 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

• 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://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://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