Slide 1

Slide 1 text

@BastianHofmann Highly available cross-region deployments with Kubernetes Bastian Hofmann

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Container orchestration platform

Slide 4

Slide 4 text

Deploy, run and scale your services in isolated containers

Slide 5

Slide 5 text

No vendor lock in

Slide 6

Slide 6 text

Standardized APIs

Slide 7

Slide 7 text

Runs on

Slide 8

Slide 8 text

Your laptop

Slide 9

Slide 9 text

Bare metal

Slide 10

Slide 10 text

Cloud Providers

Slide 11

Slide 11 text

And if you don't want to install and maintain Kubernetes yourself

Slide 12

Slide 12 text

Managed Kubernetes

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

Self-healing built in

Slide 15

Slide 15 text

But what happens when a complete datacenter is not available

Slide 16

Slide 16 text

Multi-Region Kubernetes Setups

Slide 17

Slide 17 text

Why

Slide 18

Slide 18 text

Availability

Slide 19

Slide 19 text

Scalability

Slide 20

Slide 20 text

More Points-of-Presence

Slide 21

Slide 21 text

Reduce dependencies on one single cloud provider

Slide 22

Slide 22 text

Because of the standardised API across providers Kubernetes can help

Slide 23

Slide 23 text

Features

Slide 24

Slide 24 text

Scheduling by Node Labels

Slide 25

Slide 25 text

failure- domain.beta.kubernetes.io/ region=dbl failure- domain.beta.kubernetes.io/ zone=dbl1

Slide 26

Slide 26 text

Regions vs availability zone

Slide 27

Slide 27 text

failure- domain.beta.kubernetes.io/ region=dbl failure- domain.beta.kubernetes.io/ zone=dbl1

Slide 28

Slide 28 text

apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: template: spec: containers: - image: nginx name: nginx nodeSelector: failure-domain.beta.kubernetes.io/region: dbl

Slide 29

Slide 29 text

Affinities

Slide 30

Slide 30 text

spec: affinity: podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - topologyKey: "failure-domain.beta.kubernetes.io/ region" labelSelector: matchLabels: app: nginx

Slide 31

Slide 31 text

Service discovery with built in DNS

Slide 32

Slide 32 text

apiVersion: v1 kind: Service metadata: name: nginx spec: type: ClusterIP ports: - port: 80 targetPort: 80 selector: app: nginx

Slide 33

Slide 33 text

External LoadBalancers

Slide 34

Slide 34 text

apiVersion: v1 kind: Service metadata: name: nginx spec: type: LoadBalancer ports: - port: 80 targetPort: 80 selector: app: nginx

Slide 35

Slide 35 text

external-dns

Slide 36

Slide 36 text

StorageClasses

Slide 37

Slide 37 text

Some storage providers support dynamic volume provisioning

Slide 38

Slide 38 text

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

Slide 39 text

Challenges

Slide 40

Slide 40 text

Especially over different regions

Slide 41

Slide 41 text

External load balancing and traffic management

Slide 42

Slide 42 text

Internal load balancing

Slide 43

Slide 43 text

Connectivity between private networks

Slide 44

Slide 44 text

Kubernetes DNS across multiple clusters

Slide 45

Slide 45 text

Latencies

Slide 46

Slide 46 text

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

Slide 47 text

Synchronising Deployments across multiple clusters

Slide 48

Slide 48 text

Storage

Slide 49

Slide 49 text

Data replication

Slide 50

Slide 50 text

Split-brain problem

Slide 51

Slide 51 text

Possible setups

Slide 52

Slide 52 text

One cluster across AZs in one region

Slide 53

Slide 53 text

One cluster across regions

Slide 54

Slide 54 text

Multiple clusters connected via VPN

Slide 55

Slide 55 text

One cluster setup

Slide 56

Slide 56 text

One Kubernetes cluster across multiple availability zones

Slide 57

Slide 57 text

Zone 1 Zone 2 Kubernetes Master Components Nginx Nginx Nginx Service Curl

Slide 58

Slide 58 text

Easiest option

Slide 59

Slide 59 text

Low latencies

Slide 60

Slide 60 text

You can use one network

Slide 61

Slide 61 text

All pods and services can talk with each other

Slide 62

Slide 62 text

One cluster => one internal DNS

Slide 63

Slide 63 text

Service Discovery and internal load balancing works

Slide 64

Slide 64 text

External LoadBalancers work

Slide 65

Slide 65 text

Zone 1 Zone 2 Kubernetes Master Components Nginx Nginx Nginx Service Curl LB

Slide 66

Slide 66 text

You can mount storage across AZ

Slide 67

Slide 67 text

One cluster state => One deployment

Slide 68

Slide 68 text

But what if the whole region is down?

Slide 69

Slide 69 text

One Kubernetes cluster across multiple regions and VPN connection between networks

Slide 70

Slide 70 text

Region 1 Region 2 WireGuard VPN Kubernetes Master Components Nginx Nginx Nginx Service Curl

Slide 71

Slide 71 text

Latencies get higher by distance

Slide 72

Slide 72 text

You need a VPN to connect the networks

Slide 73

Slide 73 text

WireGuard as a VPN

Slide 74

Slide 74 text

https:/ /github.com/squat/kilo

Slide 75

Slide 75 text

Kilo gets all Nodes from Kubernetes

Slide 76

Slide 76 text

Discovers regions and zones by Kubernetes Node labels

Slide 77

Slide 77 text

Configures WireGuard

Slide 78

Slide 78 text

Routing tables

Slide 79

Slide 79 text

All pods and services can talk with each other

Slide 80

Slide 80 text

One cluster => one internal DNS

Slide 81

Slide 81 text

Service Discovery and internal load balancing works

Slide 82

Slide 82 text

You need a solution for external load balancing

Slide 83

Slide 83 text

Region 1 Region 2 WireGuard VPN Kubernetes Master Components Nginx Nginx Nginx Service Curl LB LB

Slide 84

Slide 84 text

You have to replicate storage yourself

Slide 85

Slide 85 text

Not every Storage provider supports dynamic volume provisioning

Slide 86

Slide 86 text

One cluster state => One deployment

Slide 87

Slide 87 text

Demo

Slide 88

Slide 88 text

Multi cluster setup

Slide 89

Slide 89 text

Connecting multiple clusters with a VPN

Slide 90

Slide 90 text

Cluster 1 Cluster 2 WireGuard VPN Kubernetes Master Components Kubernetes Master Components Nginx Nginx Nginx Service Nginx Service Curl

Slide 91

Slide 91 text

WireGuard as a VPN

Slide 92

Slide 92 text

https:/ /github.com/squat/kilo

Slide 93

Slide 93 text

All pods and services can talk with each other

Slide 94

Slide 94 text

Separate clusters => separate internal DNS

Slide 95

Slide 95 text

For service discovery configure each internal DNS to resolve to other clusters

Slide 96

Slide 96 text

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

Slide 97 text

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

Slide 98 text

Internal load balancing works

Slide 99

Slide 99 text

You have to replicate storage yourself

Slide 100

Slide 100 text

Every cluster has their own StorageClass that works on all nodes

Slide 101

Slide 101 text

Separate clusters have separate state

Slide 102

Slide 102 text

Management of deployments across clusters

Slide 103

Slide 103 text

Kubefed https://github.com/kubernetes-sigs/kubefed

Slide 104

Slide 104 text

FederatedNamespaces, FederatedDeployments, FederatedConfigMaps, FederatedServices, ...

Slide 105

Slide 105 text

Cluster aware controller that manages resources in all connected clusters

Slide 106

Slide 106 text

Cluster 1 Cluster 2 Kubernetes Master Components Kubernetes Master Components Kubefed Controller

Slide 107

Slide 107 text

Cluster 1 Cluster 2 Kubernetes Master Components Kubernetes Master Components Kubefed Controller FederatedService FederatedDeployment

Slide 108

Slide 108 text

Cluster 1 Cluster 2 Kubernetes Master Components Kubernetes Master Components Nginx Service Nginx Service Kubefed Controller Kubefed Controller Nginx Nginx

Slide 109

Slide 109 text

Demo

Slide 110

Slide 110 text

Solution for external traffic

Slide 111

Slide 111 text

Cluster 1 Cluster 2 WireGuard VPN Kubernetes Master Components Kubernetes Master Components Nginx Nginx Nginx Service Nginx Service Curl LB LB

Slide 112

Slide 112 text

Multi cluster external-dns

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

service.namespace.domain.svc.example.com service.namespace.domain.svc.region1.example.com service.namespace.domain.svc.region2.example.com

Slide 115

Slide 115 text

Demo

Slide 116

Slide 116 text

More options

Slide 117

Slide 117 text

Multiple clusters connected via Service Mesh (Istio)

Slide 118

Slide 118 text

Conclusion

Slide 119

Slide 119 text

Kubernetes makes it easier to create multi region setups

Slide 120

Slide 120 text

There are still challenges you have to overcome

Slide 121

Slide 121 text

Often just physics

Slide 122

Slide 122 text

Federation Tooling is just getting started

Slide 123

Slide 123 text

Test it 30 days For free Visit us at our booth

Slide 124

Slide 124 text

No content

Slide 125

Slide 125 text

https:/ /github.com/bashofmann/ kubernetes-multicluster-demos

Slide 126

Slide 126 text

[email protected] https:/ /twitter.com/BastianHofmann

Slide 127

Slide 127 text

Connecting multiple clusters with a Service Mesh Gateway

Slide 128

Slide 128 text

No content

Slide 129

Slide 129 text

No content

Slide 130

Slide 130 text

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

Slide 131 text

No VPN necessary

Slide 132

Slide 132 text

Fairly easy to set up

Slide 133

Slide 133 text

Pods from different clusters communicate over public Ips

Slide 134

Slide 134 text

Traffic encrypted and authenticated with mutual TLS

Slide 135

Slide 135 text

Communication is only possible through Istio proxies

Slide 136

Slide 136 text

Easy service discovery

Slide 137

Slide 137 text

Flexible, location aware traffic management

Slide 138

Slide 138 text

Telemetry and tracing included

Slide 139

Slide 139 text

Demo