SLIDE 1 @BastianHofmann
Highly available cross-region deployments with Kubernetes
Bastian Hofmann
SLIDE 2
SLIDE 3
Container orchestration platform
SLIDE 4
Deploy, run and scale your services in isolated containers
SLIDE 5
No vendor lock in
SLIDE 6
Standardized APIs
SLIDE 7
Runs on
SLIDE 8
Your laptop
SLIDE 9
Bare metal
SLIDE 10
Cloud Providers
SLIDE 11
And if you don't want to install and maintain Kubernetes yourself
SLIDE 12
Managed Kubernetes
SLIDE 13
SLIDE 14
Self-healing built in
SLIDE 15
But what happens when a complete datacenter is not available
SLIDE 16
Multi-Region Kubernetes Setups
SLIDE 17
Why
SLIDE 18
Availability
SLIDE 19
Scalability
SLIDE 20
More Points-of-Presence
SLIDE 21
Reduce dependencies on one single cloud provider
SLIDE 22
Because of the standardised API across providers Kubernetes can help
SLIDE 23
Features
SLIDE 24
Scheduling by Node Labels
SLIDE 25
failure- domain.beta.kubernetes.io/ region=dbl failure- domain.beta.kubernetes.io/ zone=dbl1
SLIDE 26
Regions vs availability zone
SLIDE 27
failure- domain.beta.kubernetes.io/ region=dbl failure- domain.beta.kubernetes.io/ zone=dbl1
SLIDE 28 apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: template: spec: containers:
name: nginx nodeSelector: failure-domain.beta.kubernetes.io/region: dbl
SLIDE 29
Affinities
SLIDE 30 spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: "failure-domain.beta.kubernetes.io/
region" labelSelector: matchLabels: app: nginx
SLIDE 31
Service discovery with built in DNS
SLIDE 32 apiVersion: v1 kind: Service metadata: name: nginx spec: type: ClusterIP ports:
targetPort: 80 selector: app: nginx
SLIDE 33
External LoadBalancers
SLIDE 34 apiVersion: v1 kind: Service metadata: name: nginx spec: type: LoadBalancer ports:
targetPort: 80 selector: app: nginx
SLIDE 35
external-dns
SLIDE 36
StorageClasses
SLIDE 37
Some storage providers support dynamic volume provisioning
SLIDE 38 apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: standard provisioner: kubernetes.io/gce-pd parameters: type: pd-standard volumeBindingMode: WaitForFirstConsumer allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- us-central1-a
- us-central1-b
SLIDE 39
Challenges
SLIDE 40
Especially over different regions
SLIDE 41
External load balancing and traffic management
SLIDE 42
Internal load balancing
SLIDE 43
Connectivity between private networks
SLIDE 44
Kubernetes DNS across multiple clusters
SLIDE 45
Latencies
SLIDE 46 Beskow, Paul & Vik, Knut-Helge & Halvorsen, Pål & Griwodz, Carsten. (2009). The partial migration of game state and dynamic server selection to reduce latency. Multimedia Tools Appl..
- 45. 83-107. 10.1007/s11042-009-0287-7.
SLIDE 47
Synchronising Deployments across multiple clusters
SLIDE 48
Storage
SLIDE 49
Data replication
SLIDE 50
Split-brain problem
SLIDE 51
Possible setups
SLIDE 52
One cluster across AZs in one region
SLIDE 53
One cluster across regions
SLIDE 54
Multiple clusters connected via VPN
SLIDE 55
One cluster setup
SLIDE 56
One Kubernetes cluster across multiple availability zones
SLIDE 57 Zone 1 Zone 2
Kubernetes Master Components Nginx Nginx Nginx Service Curl
SLIDE 58
Easiest option
SLIDE 59
Low latencies
SLIDE 60
You can use one network
SLIDE 61
All pods and services can talk with each other
SLIDE 62
One cluster => one internal DNS
SLIDE 63
Service Discovery and internal load balancing works
SLIDE 64
External LoadBalancers work
SLIDE 65 Zone 1 Zone 2
Kubernetes Master Components Nginx Nginx Nginx Service Curl LB
SLIDE 66
You can mount storage across AZ
SLIDE 67
One cluster state => One deployment
SLIDE 68
But what if the whole region is down?
SLIDE 69
One Kubernetes cluster across multiple regions and VPN connection between networks
SLIDE 70 Region 1 Region 2
WireGuard VPN Kubernetes Master Components Nginx Nginx Nginx Service Curl
SLIDE 71
Latencies get higher by distance
SLIDE 72
You need a VPN to connect the networks
SLIDE 73
WireGuard as a VPN
SLIDE 74
https:/ /github.com/squat/kilo
SLIDE 75
Kilo gets all Nodes from Kubernetes
SLIDE 76
Discovers regions and zones by Kubernetes Node labels
SLIDE 77
Configures WireGuard
SLIDE 78
Routing tables
SLIDE 79
All pods and services can talk with each other
SLIDE 80
One cluster => one internal DNS
SLIDE 81
Service Discovery and internal load balancing works
SLIDE 82
You need a solution for external load balancing
SLIDE 83 Region 1 Region 2
WireGuard VPN Kubernetes Master Components Nginx Nginx Nginx Service Curl LB LB
SLIDE 84
You have to replicate storage yourself
SLIDE 85
Not every Storage provider supports dynamic volume provisioning
SLIDE 86
One cluster state => One deployment
SLIDE 87
Demo
SLIDE 88
Multi cluster setup
SLIDE 89
Connecting multiple clusters with a VPN
SLIDE 90 Cluster 1 Cluster 2
WireGuard VPN Kubernetes Master Components Kubernetes Master Components Nginx Nginx Nginx Service Nginx Service Curl
SLIDE 91
WireGuard as a VPN
SLIDE 92
https:/ /github.com/squat/kilo
SLIDE 93
All pods and services can talk with each other
SLIDE 94
Separate clusters => separate internal DNS
SLIDE 95
For service discovery configure each internal DNS to resolve to other clusters
SLIDE 96
cluster.region2:53 { forward . 10.10.11.10 } .:53 { kubernetes cluster.local cluster.region1 in-addr.arpa ip6.arpa { pods insecure upstream fallthrough in-addr.arpa ip6.arpa } forward . /etc/resolv.conf loop loadbalance }
SLIDE 97
cluster.region1:53 { forward . 10.10.10.10 } .:53 { kubernetes cluster.local cluster.region2 in-addr.arpa ip6.arpa { pods insecure upstream fallthrough in-addr.arpa ip6.arpa } forward . /etc/resolv.conf loop loadbalance }
SLIDE 98
Internal load balancing works
SLIDE 99
You have to replicate storage yourself
SLIDE 100
Every cluster has their own StorageClass that works on all nodes
SLIDE 101
Separate clusters have separate state
SLIDE 102
Management of deployments across clusters
SLIDE 103 Kubefed
https://github.com/kubernetes-sigs/kubefed
SLIDE 104
FederatedNamespaces, FederatedDeployments, FederatedConfigMaps, FederatedServices, ...
SLIDE 105
Cluster aware controller that manages resources in all connected clusters
SLIDE 106 Cluster 1 Cluster 2
Kubernetes Master Components Kubernetes Master Components Kubefed Controller
SLIDE 107 Cluster 1 Cluster 2
Kubernetes Master Components Kubernetes Master Components Kubefed Controller
FederatedService FederatedDeployment
SLIDE 108 Cluster 1 Cluster 2
Kubernetes Master Components Kubernetes Master Components Nginx Service Nginx Service Kubefed Controller Kubefed Controller Nginx Nginx
SLIDE 109
Demo
SLIDE 110
Solution for external traffic
SLIDE 111 Cluster 1 Cluster 2
WireGuard VPN Kubernetes Master Components Kubernetes Master Components Nginx Nginx Nginx Service Nginx Service Curl LB LB
SLIDE 112
Multi cluster external-dns
SLIDE 113
SLIDE 114
service.namespace.domain.svc.example.com service.namespace.domain.svc.region1.example.com service.namespace.domain.svc.region2.example.com
SLIDE 115
Demo
SLIDE 116
More options
SLIDE 117
Multiple clusters connected via Service Mesh (Istio)
SLIDE 118
Conclusion
SLIDE 119
Kubernetes makes it easier to create multi region setups
SLIDE 120 There are still challenges you have to
SLIDE 121
Often just physics
SLIDE 122
Federation Tooling is just getting started
SLIDE 123
Test it 30 days For free Visit us at our booth
SLIDE 124
SLIDE 125
https:/ /github.com/bashofmann/ kubernetes-multicluster-demos
SLIDE 126 mail@bastianhofmann.de https:/ /twitter.com/BastianHofmann
SLIDE 127
Connecting multiple clusters with a Service Mesh Gateway
SLIDE 128
SLIDE 129
SLIDE 130 Cluster 1 Cluster 2
Istio Gateway Istio Control Plane Kubernetes Master Components Kubernetes Master Components Istio Nginx Nginx Nginx Service Nginx Service Istio Gateway Curl
SLIDE 131
No VPN necessary
SLIDE 132
Fairly easy to set up
SLIDE 133
Pods from different clusters communicate over public Ips
SLIDE 134
Traffic encrypted and authenticated with mutual TLS
SLIDE 135
Communication is only possible through Istio proxies
SLIDE 136
Easy service discovery
SLIDE 137
Flexible, location aware traffic management
SLIDE 138
Telemetry and tracing included
SLIDE 139
Demo