Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2017 QConSP - From Laptop to the World

2017 QConSP - From Laptop to the World

Slides for 2017 QCon Sao Paulo on Kubernetes and Federation

http://qconsp.com/speaker/ray-tsang

Ray Tsang

May 08, 2017
Tweet

More Decks by Ray Tsang

Other Decks in Technology

Transcript

  1. @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
  2. @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?
  3. @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
  4. @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?
  5. @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
  6. @saturnism @googlecloud #kubernetes Group of containers Live and die together

    Shared network interface Shared volumes Unique Routable IP Pod App Log Collector Pods ...
  7. @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
  8. @saturnism @googlecloud #kubernetes Label anything Name-value pair Make your own

    Pod App Log Collector Labels ... type = Frontend version = 1.0
  9. @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
  10. @saturnism @googlecloud #kubernetes Replication Controller Replicas → 1 Pod App

    Log Collector ... type = Frontend version = 1.0 Replication Controllers
  11. @saturnism @googlecloud #kubernetes Replication Controllers node 1 f0118 node 3

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

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

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

    node 4 Replication Controller - Desired = 4 - Current = 4 b0111 a1209 c9bad
  15. @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
  16. @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
  17. @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
  18. @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
  19. @saturnism @googlecloud @kubernetesio UI CLI API Control Plane Clusters API

    Admin Kubernetes on Kubernetes on Another Web Service Cloud Kubernetes on Premise Federation
  20. @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
  21. @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 ...
  22. @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
  23. @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
  24. @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
  25. @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
  26. @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
  27. @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
  28. @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
  29. @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
  30. @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
  31. @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
  32. @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
  33. @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
  34. @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
  35. @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
  36. @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
  37. @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
  38. @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
  39. @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.
  40. @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
  41. @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