Kubernetes
From Beginner to Expert
@kubernetesio @briandorsey @jeffmendoza
Advanced Concepts
@kubernetesio @briandorsey @jeffmendoza
Jobs
Run-to-completion, as opposed to run-forever
Aggregates success/failure counts
Built for batch and big-data work
Status: GA in Kubernetes v1.2
...
@kubernetesio @briandorsey @jeffmendoza
Lab (Setup)
@kubernetesio @briandorsey @jeffmendoza
Pods
Pod
Lobsters
Log Grabber
Volume
Consumers
Log Aggregator
Can be used to group multiple containers & shared volumes
Containers within a pod are tightly coupled
Shared namespaces
@kubernetesio @briandorsey @jeffmendoza
Lab (Pod Patterns / Sidecar)
@kubernetesio @briandorsey @jeffmendoza
Generalized Labels (1.2)
Pod
Pod
frontend
Pod
frontend
Pod
Pod
env = qa
env = test
Expressions
env = prod
Pod
env = prod
Dashboard
selector:
env = notin(prod)
@kubernetesio @briandorsey @jeffmendoza
ReplicaSets (1.2)
Replication Controller
Pod
Pod
frontend
Pod
frontend
Pod
Pod
app = demo
app = demo
app = demo
ReplicaSet
#pods = 3
app = demo
color in (blue,grey)
show: version = v2
Similar to ReplicationController but supports generalized Selectors
selector:
matchLabels:
app: demo
matchExpressions:
- {key: color, operator: In, values: [blue,grey]}
color = blue
color = blue
color = grey
@kubernetesio @briandorsey @jeffmendoza
Deployments: Updates as a Service
Reliable mechanism for creating, updating and managing Pods
Deployment manages replica changes, including rolling updates and scaling
Edit Deployment configurations in place with kubectl edit or kubectl apply
Managed rollouts and rollbacks
Status: BETA in Kubernetes v1.2
...
@kubernetesio @briandorsey @jeffmendoza
Deployment Based Rolling Update
Deployment
API
Deployment
Create frontend-1234567
Deployment
Create frontend-1234567
Scale frontend-1234567 up to 1
Deployment
Create frontend-1234567
Scale frontend-1234567 up to 1
Scale frontend-7654321 down to 0
Deployment
Create frontend-1234567
Scale frontend-1234567 up to 1
Scale frontend-7654321 down to 0
Scale frontend-1234567 up to 2
Pod
Pod
frontend
Pod
version = v1
ReplicaSet
frontend-1234567
version = v2
type = BE
#pods = 0
show: version = v2
ReplicaSet
frontend-7654321
version = v1
type = BE
#pods = 2
show: version = v2
version = v2
ReplicaSet
frontend-7654321
version = v1
type = BE
#pods = 0
version= v1
ReplicaSet
frontend-1234567
version = v2
type = BE
#pods = 1
show: version = v2
ReplicaSet
frontend-1234567
version = v2
type = BE
#pods = 2
type = BE
type = BE
Pod
version = v2
type = BE
Service
Label selectors:
version = 1.0
type = Frontend
@kubernetesio @briandorsey @jeffmendoza
Canary
Service
Label selectors:
version = 1.0
type = Frontend
Service
name = backend
Label selector:
type = BE
Replication Controller
Pod
Pod
frontend
Pod
version= v1
version = v1
Replication Controller
version = v1
type = BE
#pods = 2
show: version = v2
type = BE
type = BE
Replication Controller
Replication Controller
version = v2
type = BE
#pods = 1
show: version = v2
Pod
frontend
Pod
version = v2
type = BE
@kubernetesio @briandorsey @jeffmendoza
Lab (Canary / Update / Rollback)
@kubernetesio @briandorsey @jeffmendoza
Autoscale
$ kubectl autoscale rc frontend-rc-v1 --min=1 --max=20
@kubernetesio @briandorsey @jeffmendoza
Pod Horizontal Autoscaling
Replication Controller
Pod
frontend
Pod
name=locust
name=locust
Replication Controller
name=locust
role=worker
#pods = 1
show: version = v2
Pod
frontend
Pod
name=locust
Replication Controller
name=locust
role=worker
#pods = 2
show: version = v2
Pod
Pod
name=locust
Scale
CPU Target% = 50
Heapster
role=worker
role=worker
role=worker
role=worker
Replication Controller
name=locust
role=worker
#pods = 4
70% CPU
40% CPU
> 50% CPU
< 50% CPU
@kubernetesio @briandorsey @jeffmendoza
Lab (Auto Scale)
@kubernetesio @briandorsey @jeffmendoza
Graceful Termination
Goal: Give pods time to clean up
Catch SIGTERM, cleanup, exit ASAP
Pod status “Terminating”
Declarative: ‘DELETE’ appears as an object field in the API
@kubernetesio @briandorsey @jeffmendoza