Kubernetes
Sang-Min Park

Niantic Labs.
“The views, thoughts, opinions
are solely to myself and does
not represent my current and
previous employers.”
Kubernetes
• From Google, 2014. Currently Open Source.

• Container Orchestration Engine

• Replaces AWS EC2, Azure compute, …

• Monolithic, one-size fits all collection of functions

• Core of Google Cloud Platform
Brief History …
- 90’s
• Buy Hardware

• Install O/S, dependencies

• Operate service & infra.
• Idea

• Application code
- 2010
• Buy Less Hardware

• Operate service & infra.
• Idea

• Application code 

• Install O/S, dependencies
- 2016
• Operate infra.
• Idea

• Application code

• Install O/S, dependencies

• Operate service
- Current
• Operate infra.
• Idea

• Application code, faster

• Install O/S, dependencies, faster

• Operate service, faster
Docker
Docker
• Uses resource isolation features of Linux kernel

• cgroup for isolating usage of CPUs, disk I/O

• namespaces for isolating process IDs, hostname, file
system

• Lightweight image without O/S - “Build once, run
everywhere”

• Minutes to boot VM vs. Second to start container
Docker’s so good…
And I need to run
1000s dockers?
Kubernetes
• Manages life-cycle of containers (≈ EC2)

• Controllers for replication and coordination of containers
(≈ Autoscaling, CloudFormation)

• Manages networking and storage (≈ EC2, Elastic IP)

• Convenient object management (≈ IAM, Tagging)

• Built-in Cloud integration
Pod
• The basic building block: 90% of dev time spent here

• Encapsulates application container 

• A pod runs a single container: most use-cases

• A pod runs multiple containers
Pod
kubectl get pods
kubectl describe pod myapp-pod
kubectl delete pod myapp-pod
kubectl logs myapp-pod
kubectl exec myapp-pod -it /bin/sh
Node
• Host machine running Pods (containers)

• VM or physical machine

• VM Instances in EC2, GCP, …

• Runs kubelet, kube-proxy, and docker

• CPU and memory capacity for scheduling

• SRE’s concern (add, retire, upgrade)
Node
Controllers
• Pod = unit of single or co-located containers

• Controllers = Coordination over set of pods

• E.g., front-end pods, database pods, …

• Unit of deployments (where as Pod is unit of debugging)
Replication Controller
kubectl create -f ./replication.yaml
replication controller “nginx” created
More Controllers
• Deployments: changes actual state of pods to desired
state

• StatefulSets: guarantees about the ordering and
uniqueness of pods

• DaemonSet: ensures all Nodes run a copy of a pod

• Jobs: run batch type pods

• The list grows…
Services
• Not really about services …

• Pods are ephemeral

• External endpoint: public IP, stable port, and DNS

• Equivalent to Elastic IP or load balancer in EC2

• Iptable as implementation mechanism
Typical design so far
Next things are clever
Objects
• Persistent entities: Pod, Node, Controllers, Services, …

• Declarative spec describes desired state

• K8 ensures actual state = desired state

• Declarative programming vs. service oriented architecture
Getting a job done
S3
EC2
IAM
ELB
May I get the image ID?
Can you run this image?
Can I get the password?
Can you run it behind LB?
Wow such cloud
I am so empowered!
Do this.
Kubernete’s way
Labels and Selectors
• Objects can be labeled (key-value pair)

• Match one object kinds to another

• Schedule pods to nodes

• Map service/controllers to set of pods
Such Cloud way
What’s the image ID?
Wth, dependency
updated!
Crap, instances
crashed
What’s the current ID?
Ok change it now
Label
Things changed, but
I’ll figure them out
Secrets
• Object that contains a sensitive data

• Passwords, OAuth token, etc

• Production service needs secure token passed to Pods
Secrets in Pods
Such Cloud way
Kubernetes
• Maybe Google invented a weapon against AWS

• Monolithic architecture with collection of useful tools

• Declarative style makes it easier to program

• Go for it. It works really well.

Kubernetes

  • 1.
  • 2.
    “The views, thoughts,opinions are solely to myself and does not represent my current and previous employers.”
  • 5.
    Kubernetes • From Google,2014. Currently Open Source. • Container Orchestration Engine • Replaces AWS EC2, Azure compute, … • Monolithic, one-size fits all collection of functions • Core of Google Cloud Platform
  • 6.
  • 7.
    - 90’s • BuyHardware • Install O/S, dependencies • Operate service & infra. • Idea • Application code
  • 8.
    - 2010 • BuyLess Hardware • Operate service & infra. • Idea • Application code • Install O/S, dependencies
  • 9.
    - 2016 • Operateinfra. • Idea • Application code • Install O/S, dependencies • Operate service
  • 10.
    - Current • Operateinfra. • Idea • Application code, faster • Install O/S, dependencies, faster • Operate service, faster
  • 11.
  • 12.
    Docker • Uses resourceisolation features of Linux kernel • cgroup for isolating usage of CPUs, disk I/O • namespaces for isolating process IDs, hostname, file system • Lightweight image without O/S - “Build once, run everywhere” • Minutes to boot VM vs. Second to start container
  • 13.
    Docker’s so good… AndI need to run 1000s dockers?
  • 15.
    Kubernetes • Manages life-cycleof containers (≈ EC2) • Controllers for replication and coordination of containers (≈ Autoscaling, CloudFormation) • Manages networking and storage (≈ EC2, Elastic IP) • Convenient object management (≈ IAM, Tagging) • Built-in Cloud integration
  • 16.
    Pod • The basicbuilding block: 90% of dev time spent here • Encapsulates application container • A pod runs a single container: most use-cases • A pod runs multiple containers
  • 17.
    Pod kubectl get pods kubectldescribe pod myapp-pod kubectl delete pod myapp-pod kubectl logs myapp-pod kubectl exec myapp-pod -it /bin/sh
  • 18.
    Node • Host machinerunning Pods (containers) • VM or physical machine • VM Instances in EC2, GCP, … • Runs kubelet, kube-proxy, and docker • CPU and memory capacity for scheduling • SRE’s concern (add, retire, upgrade)
  • 19.
  • 20.
    Controllers • Pod =unit of single or co-located containers • Controllers = Coordination over set of pods • E.g., front-end pods, database pods, … • Unit of deployments (where as Pod is unit of debugging)
  • 21.
    Replication Controller kubectl create-f ./replication.yaml replication controller “nginx” created
  • 22.
    More Controllers • Deployments:changes actual state of pods to desired state • StatefulSets: guarantees about the ordering and uniqueness of pods • DaemonSet: ensures all Nodes run a copy of a pod • Jobs: run batch type pods • The list grows…
  • 23.
    Services • Not reallyabout services … • Pods are ephemeral • External endpoint: public IP, stable port, and DNS • Equivalent to Elastic IP or load balancer in EC2 • Iptable as implementation mechanism
  • 24.
    Typical design sofar Next things are clever
  • 25.
    Objects • Persistent entities:Pod, Node, Controllers, Services, … • Declarative spec describes desired state • K8 ensures actual state = desired state • Declarative programming vs. service oriented architecture
  • 27.
    Getting a jobdone S3 EC2 IAM ELB May I get the image ID? Can you run this image? Can I get the password? Can you run it behind LB?
  • 28.
    Wow such cloud Iam so empowered!
  • 29.
  • 30.
    Labels and Selectors •Objects can be labeled (key-value pair) • Match one object kinds to another • Schedule pods to nodes • Map service/controllers to set of pods
  • 32.
    Such Cloud way What’sthe image ID? Wth, dependency updated! Crap, instances crashed What’s the current ID? Ok change it now
  • 33.
  • 34.
    Secrets • Object thatcontains a sensitive data • Passwords, OAuth token, etc • Production service needs secure token passed to Pods
  • 35.
  • 36.
  • 37.
    Kubernetes • Maybe Googleinvented a weapon against AWS • Monolithic architecture with collection of useful tools • Declarative style makes it easier to program • Go for it. It works really well.