Slide 1

Slide 1 text

Janet Kuo Software Engineer Twitter: @janet_kuo github.com/janetkuo Running Workloads in Kubernetes

Slide 2

Slide 2 text

2 Google Cloud Platform https://goo.gl/dWYJq4

Slide 3

Slide 3 text

3 Google Cloud Platform https://goo.gl/2NLT0f

Slide 4

Slide 4 text

Concept

Slide 5

Slide 5 text

Google Cloud Platform 5 Kubernetes is a platform for application patterns

Slide 6

Slide 6 text

Google Cloud Platform 6 Pod is a single instance of an application in Kubernetes

Slide 7

Slide 7 text

Google Cloud Platform 7 Controller manages replicated pods for an application pattern

Slide 8

Slide 8 text

8 Google Cloud Platform Master node Worker node Worker node

Slide 9

Slide 9 text

9 Google Cloud Platform Master node Worker node Worker node Pod Container Container Pod Container Container

Slide 10

Slide 10 text

10 Google Cloud Platform Master node Worker node Worker node Pod Container Container Pod Container Container C controller

Slide 11

Slide 11 text

Four General Patterns

Slide 12

Slide 12 text

12 Google Cloud Platform No persistent states ● Web frontends ● Web servers Keeps states ● Databases ● Message queues Daemon that runs as a background process ● Cluster storage ● Logs collection ● Node monitoring DAEMON Batch processing of independent work items ● Emails to send ● Frames to render BATCH STATELESS STATEFUL Application Patterns

Slide 13

Slide 13 text

Four Controllers Each for one pattern

Slide 14

Slide 14 text

14 Google Cloud Platform 01 Deployment For Stateless Pattern No persistent states Scale is easy Availability > Consistency Create multiple replicas of the same pod Pods are disposable Rolling update Update at a controlled rate Block updates on failure History and rollback

Slide 15

Slide 15 text

15 Google Cloud Platform kubectl Master node Worker node Worker node Pod Container Container Pod Container Container Service C async Demo: https://github.com/janetkuo/k8s-demos/tree/master/dep 01 Deployment For Stateless Pattern

Slide 16

Slide 16 text

16 Google Cloud Platform 02 StatefulSet For Stateful Pattern Store persistent data Need stable, unique, and sticky identity and storage Consistency > Availability Create similar pods, each has its own identity and storage Pods are not disposable Deploy, scale, terminate In order (default), or in parallel (1.7 feature) Rolling update (1.7 feature) Update one pod at a time, and block updates on failure History

Slide 17

Slide 17 text

17 Google Cloud Platform kubectl Master node Worker node Worker node Pod 0 Container Container Pod 1 Container Container Service C async Demo: https://github.com/janetkuo/k8s-demos/tree/master/stateful 02 StatefulSet For Stateful Pattern

Slide 18

Slide 18 text

18 Google Cloud Platform 03 DaemonSet For Daemon Pattern One Daemon per node Background process Daemons created and removed with nodes Node labels Control which nodes daemons should run on Rolling update (1.6 feature) Update at a controlled rate Block updates on failure History and rollback

Slide 19

Slide 19 text

19 Google Cloud Platform kubectl Master node Worker node Worker node Pod Container Container Pod Container Container Service C async Demo: https://github.com/janetkuo/k8s-demos/tree/master/ds 03 DaemonSet For Daemon Pattern

Slide 20

Slide 20 text

20 Google Cloud Platform 04 Jobs For Batch Pattern Run in Parallel How many pods can be created and running at a time Run to Completion How many pods need to complete (exit successfully) Parallel processing of independent but related work items Emails to send or frames to render

Slide 21

Slide 21 text

21 Google Cloud Platform kubectl Master node Worker node Worker node Pod Container Container Pod Container Container C async Demo: https://github.com/janetkuo/k8s-demos/tree/master/jobs 04 Jobs For Batch Pattern

Slide 22

Slide 22 text

Recap

Slide 23

Slide 23 text

23 Google Cloud Platform 4 Controllers for 4 Patterns ● Availability ● Scale & recover easily ● Disposable copies of the same pod ● Consistency ● Unique, sticky identity and storage ● Deploy, scale, and terminate in order or in parallel ● One pod per node by default ● Daemon pods added and removed with nodes ● Use node labels to control DaemonSet for daemon pattern ● Run multiple pods in parallel ● Run pods to completion Jobs for batch pattern Deployment for stateless pattern StatefulSet for stateful pattern

Slide 24

Slide 24 text

Where Do I Start?

Slide 25

Slide 25 text

25 Google Cloud Platform Focus on using Kubernetes, not managing it. Google Container Engine Google Compute Engine Run containers on Google Cloud Platform, powered by Kubernetes. Minikube Use Kubernetes locally on your laptop. Get a Kubernetes Cluster Kubernetes runs anywhere! Full list of solutions: https://kubernetes.io/docs/setup/pick-right-solution/

Slide 26

Slide 26 text

26 Google Cloud Platform Kubernetes Package Manager Kubernetes Charts github.com/kubernetes/charts Charts are curated application definitions for Kubernetes Kubernetes Helm https://github.com/kubernetes/helm Helm is a tool for managing Kubernetes charts.

Slide 27

Slide 27 text

27 Google Cloud Platform How Do I Customize? Kubernetes is extensible! github.com/upmc-enterprises/elasticsearch-operator github.com/coreos/etcd-operator Write your own controllers. Use the controllers that others wrote.

Slide 28

Slide 28 text

28 Google Cloud Platform Kubernetes is Open github.com/kubernetes/kubernetes kubernetes.io slack.k8s.io / @janet @kubernetesio / @janet_kuo

Slide 29

Slide 29 text

Questions?

Slide 30

Slide 30 text

Appendix

Slide 31

Slide 31 text

VM1 OS v3.14 Dependencies v1 VM2 OS v3.16 App Code App Code Dependencies v2 Container Container Container Dependencies v2 App Code App Code Dependencies v2 App Code Dependencies v2 Virtualized App relies on dependencies installed on the guest OS Containerized Code and dependencies packaged in modular unit Container 101