From Laptop to the World With Kubernetes @saturnism @googlecloud - - PowerPoint PPT Presentation

from laptop to the world
SMART_READER_LITE
LIVE PREVIEW

From Laptop to the World With Kubernetes @saturnism @googlecloud - - PowerPoint PPT Presentation

From Laptop to the World With Kubernetes @saturnism @googlecloud #kubernetes Ray Tsang Developer Advocate Google Cloud Platform @saturnism | +RayTsang @saturnism @googlecloud #kubernetes Ray Tsang Developer Architect Traveler


slide-1
SLIDE 1

@saturnism @googlecloud #kubernetes

From Laptop to the World

With Kubernetes

slide-2
SLIDE 2

@saturnism @googlecloud #kubernetes

Ray Tsang

Developer Advocate Google Cloud Platform @saturnism | +RayTsang

slide-3
SLIDE 3

@saturnism @googlecloud #kubernetes

Ray Tsang

Developer Architect Traveler Photographer flickr.com/saturnism

slide-4
SLIDE 4

@saturnism @googlecloud #kubernetes

slide-5
SLIDE 5

@saturnism @googlecloud #kubernetes

Let's go Production!

slide-6
SLIDE 6

@saturnism @googlecloud #kubernetes

When will the production environment be ready?

6 months later…? Maybe?

slide-7
SLIDE 7

@saturnism @googlecloud #kubernetes

It works in staging… But not in production!

slide-8
SLIDE 8

@saturnism @googlecloud #kubernetes

Containerize!

Runtime + Application Like a static binary!

slide-9
SLIDE 9

@saturnism @googlecloud #kubernetes

Containers

libs app kernel libs app libs app libs app

slide-10
SLIDE 10

@saturnism @googlecloud #kubernetes

Containers Orchestration

slide-11
SLIDE 11

@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

@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

@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

@saturnism @googlecloud #kubernetes

Cluster of Machines as One

slide-15
SLIDE 15

@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

@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

@saturnism @googlecloud #kubernetes

Cluster of Machines as One

slide-18
SLIDE 18

@saturnism @googlecloud #kubernetes

slide-19
SLIDE 19

@saturnism @googlecloud #kubernetes

Hello World Service - Greet Guestbook Service - Create Guestbook Service - Retrieve

slide-20
SLIDE 20

@saturnism @googlecloud #kubernetes

Guestbook UI Hello World Service

Redis

session replication greeting

MySQL

Guestbook Service

CRUD

slide-21
SLIDE 21

@saturnism @googlecloud #kubernetes

Minikube - Get Started Locally

slide-22
SLIDE 22

@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

@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

@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

@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

@saturnism @googlecloud #kubernetes

Replication Controller Replicas → 1 Pod App Log Collector ... type = Frontend version = 1.0

Replication Controllers

slide-27
SLIDE 27

@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

@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

@saturnism @googlecloud #kubernetes

Replication Controllers

node 1

f0118

node 3 node 4 Replication Controller

  • Desired = 4
  • Current = 3

b0111 a1209

slide-30
SLIDE 30

@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

@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

@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

@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

@saturnism @googlecloud #kubernetes

Service discovery

Read service IP addresses via environmental variables

slide-35
SLIDE 35

@saturnism @googlecloud #kubernetes

Service discovery

Kubernetes API

  • r…

DNS Lookups! ping redis

slide-36
SLIDE 36

@saturnism @googlecloud #kubernetes

slide-37
SLIDE 37

@saturnism @googlecloud #kubernetes

Next Step? Data Centers as One!

slide-38
SLIDE 38

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@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

@saturnism @googlecloud @kubernetesio

slide-54
SLIDE 54

@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

@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

@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

@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

@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

@saturnism @googlecloud @kubernetesio

Provider 1

Zone A Zone B

Provider 2

Zone C

Provider 1

Zone D

Challenges

slide-60
SLIDE 60

@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

@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

@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

@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

@saturnism @googlecloud #kubernetes

Let's See...

slide-65
SLIDE 65

@saturnism @googlecloud #kubernetes

Thanks!

Images by Connie Zhou

http://kubernetes.io