Slide 1

Slide 1 text

@saturnism @googlecloud #kubernetes From Laptop to the World With Kubernetes

Slide 2

Slide 2 text

@saturnism @googlecloud #kubernetes Ray Tsang Developer Advocate Google Cloud Platform @saturnism | +RayTsang

Slide 3

Slide 3 text

@saturnism @googlecloud #kubernetes Ray Tsang Developer Architect Traveler Photographer flickr.com/saturnism

Slide 4

Slide 4 text

@saturnism @googlecloud #kubernetes

Slide 5

Slide 5 text

@saturnism @googlecloud #kubernetes Let's go Production!

Slide 6

Slide 6 text

@saturnism @googlecloud #kubernetes When will the production environment be ready? 6 months later…? Maybe?

Slide 7

Slide 7 text

@saturnism @googlecloud #kubernetes It works in staging… But not in production!

Slide 8

Slide 8 text

@saturnism @googlecloud #kubernetes Containerize! Runtime + Application Like a static binary!

Slide 9

Slide 9 text

@saturnism @googlecloud #kubernetes Containers libs app kernel libs app libs app libs app

Slide 10

Slide 10 text

@saturnism @googlecloud #kubernetes Containers Orchestration

Slide 11

Slide 11 text

@saturnism @googlecloud #kubernetes Enter Kubernetes Greek for “Helmsman”; also the root of the word “Governor” • Container orchestrator • Runs containers • Supports multiple cloud and bare-metal environments • Inspired and informed by Google’s experiences and internal systems • Open source, written in Go Manage applications, not machines

Slide 12

Slide 12 text

@saturnism @googlecloud #kubernetes web browsers Scheduler kubectl web browsers scheduler Kubelet Kubelet Kubelet Kubelet Config file Kubernetes Master Container Image Developer View What just happened?

Slide 13

Slide 13 text

@saturnism @googlecloud #kubernetes Developer View spec: containers: - name: myservice image: myservice resources: limits: memory: "128Mi" cpu: "0.1" ports: - containerPort: 3306 protocol: TCP replicas: 1 10000

Slide 14

Slide 14 text

@saturnism @googlecloud #kubernetes Cluster of Machines as One

Slide 15

Slide 15 text

@saturnism @googlecloud #kubernetes web browsers Scheduler kubectl web browsers scheduler Kubelet Kubelet Kubelet Kubelet Config file Kubernetes Master Container Image Developer View What just happened?

Slide 16

Slide 16 text

@saturnism @googlecloud #kubernetes Developer View spec: containers: - name: myservice image: myservice resources: limits: memory: "128Mi" cpu: "0.1" ports: - containerPort: 3306 protocol: TCP replicas: 1 10000

Slide 17

Slide 17 text

@saturnism @googlecloud #kubernetes Cluster of Machines as One

Slide 18

Slide 18 text

@saturnism @googlecloud #kubernetes

Slide 19

Slide 19 text

@saturnism @googlecloud #kubernetes Hello World Service - Greet Guestbook Service - Create Guestbook Service - Retrieve

Slide 20

Slide 20 text

@saturnism @googlecloud #kubernetes Guestbook UI Hello World Service Redis session replication greeting MySQL Guestbook Service CRUD

Slide 21

Slide 21 text

@saturnism @googlecloud #kubernetes Minikube - Get Started Locally

Slide 22

Slide 22 text

@saturnism @googlecloud #kubernetes Group of containers Live and die together Shared network interface Shared volumes Unique Routable IP Pod App Log Collector Pods ...

Slide 23

Slide 23 text

@saturnism @googlecloud #kubernetes Pod IPs are routable • Docker default is private IP Pods can reach each other without NAT • even across nodes No brokering of port numbers This is a fundamental requirement • several SDN solutions Inter-Pods Networking

Slide 24

Slide 24 text

@saturnism @googlecloud #kubernetes Label anything Name-value pair Make your own Pod App Log Collector Labels ... type = Frontend version = 1.0

Slide 25

Slide 25 text

@saturnism @googlecloud #kubernetes Replication Controller Replicas → 2 Pod frontend Pod App Log Collector ... type = Frontend version = 1.0 Pod App Log Collector ... type = Frontend version = 1.0 Replication Controllers

Slide 26

Slide 26 text

@saturnism @googlecloud #kubernetes Replication Controller Replicas → 1 Pod App Log Collector ... type = Frontend version = 1.0 Replication Controllers

Slide 27

Slide 27 text

@saturnism @googlecloud #kubernetes Replication Controllers node 1 f0118 node 3 node 4 node 2 d9376 b0111 a1209 Replication Controller - Desired = 4 - Current = 4

Slide 28

Slide 28 text

@saturnism @googlecloud #kubernetes Replication Controllers node 1 f0118 node 3 node 4 node 2 Replication Controller - Desired = 4 - Current = 4 d9376 b0111 a1209

Slide 29

Slide 29 text

@saturnism @googlecloud #kubernetes Replication Controllers node 1 f0118 node 3 node 4 Replication Controller - Desired = 4 - Current = 3 b0111 a1209

Slide 30

Slide 30 text

@saturnism @googlecloud #kubernetes Replication Controllers node 1 f0118 node 3 node 4 Replication Controller - Desired = 4 - Current = 4 b0111 a1209 c9bad

Slide 31

Slide 31 text

@saturnism @googlecloud #kubernetes Replication Controller Replicas → 2 Pod frontend Pod type = Frontend version = 1.0 Pod type = Frontend version = 1.0 Services Service Label selectors: version = 1.0 type = Frontend

Slide 32

Slide 32 text

@saturnism @googlecloud #kubernetes Pod frontend Pod type = Frontend version = 1.0 Pod type = Frontend version = 1.0 Services Service Label selectors: version = 1.0 type = Frontend Pod type = Frontend version = 2.0

Slide 33

Slide 33 text

@saturnism @googlecloud #kubernetes Pod frontend Pod type = Frontend version = 1.0 Pod type = Frontend version = 1.0 Services Service Label selectors: type = Frontend Pod type = Frontend version = 2.0

Slide 34

Slide 34 text

@saturnism @googlecloud #kubernetes Service discovery Read service IP addresses via environmental variables

Slide 35

Slide 35 text

@saturnism @googlecloud #kubernetes Service discovery Kubernetes API or… DNS Lookups! ping redis

Slide 36

Slide 36 text

@saturnism @googlecloud #kubernetes

Slide 37

Slide 37 text

@saturnism @googlecloud #kubernetes Next Step? Data Centers as One!

Slide 38

Slide 38 text

@saturnism @googlecloud @kubernetesio UI CLI API Control Plane Servers Admin containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers Cluster / Data Center / Availability Zone

Slide 39

Slide 39 text

@saturnism @googlecloud @kubernetesio UI CLI API Control Plane Clusters API Admin Kubernetes on Kubernetes on Another Web Service Cloud Kubernetes on Premise Federation

Slide 40

Slide 40 text

@saturnism @googlecloud @kubernetesio UI CLI API Federation Control Plane Federated Clusters API Admin Kubernetes on Kubernetes on Another Web Service Cloud Kubernetes on Premise Federation containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers containers Cluster Control Plane Servers

Slide 41

Slide 41 text

@saturnism @googlecloud @kubernetesio Cluster 2 us-central1-b Cluster 1 us-east1-b Cluster 3 europe-west1-b Cluster 4 asia-east1-b API API API API Cluster 2 - us-central1-b Federation API Server Federation Controller Federation Key/value store (etcd) Federation API contexts: - context: cluster: federation-cluster user: federation-cluster Initialize Federation Control Plane kubefed init my-federation --host-cluster-context=cluster-2 ...

Slide 42

Slide 42 text

@saturnism @googlecloud @kubernetesio Adding a Cluster Cluster 4 (asia-east1-b) Federation Control Plane kubefed join cluster-4 --host-cluster-context=cluster2 ... apiVersion: federation/v1beta1 kind: Cluster metadata: name: gce-asia-east1 spec: serverAddressByClientCIDRs: - clientCIDR: "0.0.0.0/0" serverAddress: "https://..." secretRef: name: gce-asia-east1 API kubeconfig

Slide 43

Slide 43 text

@saturnism @googlecloud @kubernetesio Federated Service Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-service.yaml

Slide 44

Slide 44 text

@saturnism @googlecloud @kubernetesio Federated Service Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-service.yaml svc

Slide 45

Slide 45 text

@saturnism @googlecloud @kubernetesio Federated Service Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-service.yaml svc svc

Slide 46

Slide 46 text

@saturnism @googlecloud @kubernetesio Federated Service Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-service.yaml svc svc svc

Slide 47

Slide 47 text

@saturnism @googlecloud @kubernetesio Federated Service Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-service.yaml svc svc svc DNS

Slide 48

Slide 48 text

@saturnism @googlecloud @kubernetesio Federated Deployment Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-deployment.yaml svc svc svc

Slide 49

Slide 49 text

@saturnism @googlecloud @kubernetesio Federated ReplicaSet Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-deployment.yaml svc svc svc app

Slide 50

Slide 50 text

@saturnism @googlecloud @kubernetesio Federated Deployment Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-deployment.yaml svc svc svc app app

Slide 51

Slide 51 text

@saturnism @googlecloud @kubernetesio Federated Deployment Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-deployment.yaml svc svc svc app app app

Slide 52

Slide 52 text

@saturnism @googlecloud @kubernetesio Federated Deployment Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-deployment.yaml svc svc svc DNS app app app

Slide 53

Slide 53 text

@saturnism @googlecloud @kubernetesio

Slide 54

Slide 54 text

@saturnism @googlecloud @kubernetesio Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) svc app Clusters 1 and 3 DNS nslookup app.default.federation.svc.federation.com svc app

Slide 55

Slide 55 text

@saturnism @googlecloud @kubernetesio Federated Ingress Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-ingress.yaml svc svc svc app app app

Slide 56

Slide 56 text

@saturnism @googlecloud @kubernetesio Federated Ingress Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-ingress.yaml svc svc svc app app app Global L7 Load Balancer

Slide 57

Slide 57 text

@saturnism @googlecloud @kubernetesio Federated Ingress Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) Federation Control Plane kubectl create -f app-ingress.yaml svc svc svc app app app Global L7 Load Balancer Kubernetes Cluster 1 (Google Cloud) Kubernetes Cluster 2 (On-Prem) Kubernetes Cluster 3 (Another Cloud) svc svc svc app app app Node Port Node Port Node Port

Slide 58

Slide 58 text

@saturnism @googlecloud @kubernetesio Higher Availability Easy Application Migration Avoid Vendor Lock-in Capacity Overflow Cross-cluster Load Balancer Your users Cluster 1 Cluster 2 Cluster 3 Use Cases

Slide 59

Slide 59 text

@saturnism @googlecloud @kubernetesio Provider 1 Zone A Zone B Provider 2 Zone C Provider 1 Zone D Challenges

Slide 60

Slide 60 text

@saturnism @googlecloud @kubernetesio Geographically aware DNS gets clients to the "closest" healthy cluster. Standard Kubernetes service load balancing within each cluster. Can be extended to divert traffic away from "healthy-but-saturated" clusters. Cross-cluster Load Balancing

Slide 61

Slide 61 text

@saturnism @googlecloud @kubernetesio Location affinity Strictly coupled pods/applications • High bandwidth requirements • Low latency requirements • High fidelity requirements • Cannot easily span clusters Loosely coupled • Opposite of above • Relatively easily distributed across clusters Preferentially coupled • Strongly coupled but can be migrated piecemeal.

Slide 62

Slide 62 text

@saturnism @googlecloud @kubernetesio Location affinity continued... Negative Affinity • Don't run my replicas in the same failure domain (host/rack/zone) Topology • Same host • Same rack • Same zone • Same metro region • Same sub-continent Absolute affinity

Slide 63

Slide 63 text

@saturnism @googlecloud @kubernetesio Links Google Container Engine: https://cloud.google.com/container-engine/ Minikube: https://github.com/kubernetes/minikube Spring Boot Example: https://github.com/saturnism/spring-boot-docker Federation Example: https://github.com/saturnism/buttonmasher Visualizer: https://github.com/saturnism/gcp-live-k8s-visualizer Code Lab: bit.ly/k8s-lab

Slide 64

Slide 64 text

@saturnism @googlecloud #kubernetes Let's See...

Slide 65

Slide 65 text

@saturnism @googlecloud #kubernetes Thanks! Images by Connie Zhou http://kubernetes.io