Slide 1

Slide 1 text

GCLB Traffic Management: envoy inside @sakajunquality Google Developers Expert, Cloud 19 April 2019 #gcpug

Slide 2

Slide 2 text

Traffic Management between Services - Canary Release - Disaster Recovery - Service Migration - etc...

Slide 3

Slide 3 text

Istio?

Slide 4

Slide 4 text

Istio(in functionality) https://istio.io/

Slide 5

Slide 5 text

In “some” cases Istio is too much

Slide 6

Slide 6 text

In “some” cases Istio is too much (For the record, I am Istio user in production)

Slide 7

Slide 7 text

In “some” cases Istio is too much (For the record, I am Istio user in production) (And I like Istio)

Slide 8

Slide 8 text

Istio: Deployment Model https://istio.io/docs/concepts/deployment-models/

Slide 9

Slide 9 text

Istio: Control Plane? or https://istio.io/docs/concepts/deployment-models/

Slide 10

Slide 10 text

And many things to be taken care of…

Slide 11

Slide 11 text

Traffic Director?

Slide 12

Slide 12 text

Traffic Director - Yes! Control Plane is managed by Google and outside cluster - should be reliable enough - Still need to deploy envoy for the data plane - And still too much? Maybe - Anyways another time!

Slide 13

Slide 13 text

https://twitter.com/kelseyhightower/status/1150158904900431873

Slide 14

Slide 14 text

https://twitter.com/kelseyhightower/status/1150175947665993728

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

https://twitter.com/mattklein123/status/1156413081116798976

Slide 17

Slide 17 text

+

Slide 18

Slide 18 text

Envoy L7 ILB - Announced in Cloud Next ’19 SF Sessions - L7 Internal Load Balancer - Powered by fully-managed envoy - => Traffic Management Capability https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management

Slide 19

Slide 19 text

How it works https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management

Slide 20

Slide 20 text

URL Map? Target Proxy …? - Remember the GCE Ingress! apiVersion: extensions/v1beta1 kind: Ingress metadata: name: my-ingress spec: rules: - http: paths: - path: /* backend: serviceName: hello servicePort: 8080 - path: /hi backend: serviceName: hey servicePort: 8080

Slide 21

Slide 21 text

How it works https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management https://cloud.google.com/load-balancing/docs/url-map-concepts#url-map-components

Slide 22

Slide 22 text

How it works https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management Those components are extended w/

Slide 23

Slide 23 text

How it works https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/route/route.proto Those components are extended w/

Slide 24

Slide 24 text

How it works https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management This is actually a same technology of Traffic Director’s route rules and traffic policies https://cloud.google.com/traffic-director/docs/traffic-control

Slide 25

Slide 25 text

Let’s try!

Slide 26

Slide 26 text

Demo

Slide 27

Slide 27 text

Demo - Frontend and Backend Services - Frontend is somewhere within VPC - Backend is spread into two GKE Clusters across zones - Control Backend traffic w/ internal L7 LB Frontend Services Backend ILB Cloud Load Balancing Primary Cluster Kubernetes Engine Secondary Cluster Kubernetes Engine Control Traffic Here!

Slide 28

Slide 28 text

Detailed Architecture: Backend zone-b zone-a Primary Cluster Kubernetes Engine Service Pods NEG Backend Service Secondary Cluster Kubernetes Engine Service Pods NEG Backend Service URL Map Target HTTP Proxy Forwarding Rule

Slide 29

Slide 29 text

Setup Check out the Gist https://gist.github.com/sakajunquality/1f258cbe20e0a509324cb5b2f45bb901

Slide 30

Slide 30 text

Demo: Primary 100% At first backend service is using only running on the primary cluster. Frontend Services Backend ILB Cloud Load Balancing Primary Cluster Kubernetes Engine 100%

Slide 31

Slide 31 text

Demo: Primary 100% // Test Traffic $ ./test.sh *** *** Results of load balancing to 10.100.1.199: *** 1000 This is Primary

Slide 32

Slide 32 text

Demo: Test Script // test.sh for LB_IP in 10.100.1.199; do RESULTS= for i in {1..1000}; do RESULTS="$RESULTS:`curl ${LB_IP}`"; done >/dev/null 2>&1 IFS=':' echo "***" echo "*** Results of load balancing to $LB_IP: " echo "***" for line in $RESULTS; do echo $line; done | grep -Ev "^$" | sort | uniq -c echo done

Slide 33

Slide 33 text

Demo: Primary 100% // export the current config gcloud beta compute url-maps export sakajun-map --region=us-west1 --destination=config.yaml defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service kind: compute#urlMap name: sakajun-map region: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1 selfLink: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/urlMaps/sakajun-map

Slide 34

Slide 34 text

Demo: Primary 90% / Secondary 10% Prepared the secondary cluster and sending traffic little by little: e.g. approx. 10% Frontend Services Backend ILB Cloud Load Balancing Primary Cluster Kubernetes Engine Secondary Cluster Kubernetes Engine 90% 10%

Slide 35

Slide 35 text

Demo: Primary 90% / Secondary 10% defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service hostRules: - description : '' hosts: - '*' pathMatcher : matcher1 kind: compute#urlMap name: sakajun-map pathMatchers : - defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service name: matcher1 routeRules : - matchRules : - prefixMatch : / routeAction : weightedBackendServices : - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service weight: 90 - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-secondary-service weight: 10 region: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1 selfLink: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/urlMaps/sakajun-map

Slide 36

Slide 36 text

Demo: Primary 90% / Secondary 10% defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service hostRules: - description : '' hosts: - '*' pathMatcher : matcher1 kind: compute#urlMap name: sakajun-map pathMatchers : - defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service name: matcher1 routeRules : - matchRules : - prefixMatch : / routeAction : weightedBackendServices : - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service weight: 90 - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-secondary-service weight: 10 region: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1 selfLink: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/urlMaps/sakajun-map - For any url starts from “/” - Send 90% traffic to primary backend - Send the rest of traffic to secondary backend

Slide 37

Slide 37 text

// Update the current config gcloud beta compute url-maps import sakajun-map --region=us-west1 --source=config.yaml Demo: Primary 90% / Secondary 10% // Check the traffic $ ./test.sh *** *** Results of load balancing to 10.100.1.199: *** 910 This is Primary 90 This is Secondary

Slide 38

Slide 38 text

Demo: Primary 50% / Secondary 50% Looks good! Now it’s time to increase traffic to the secondary cluster! Frontend Services Backend ILB Cloud Load Balancing Primary Cluster Kubernetes Engine Secondary Cluster Kubernetes Engine 50% 50%

Slide 39

Slide 39 text

Demo: Primary 50% / Secondary 50% defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service hostRules: - description : '' hosts: - '*' pathMatcher : matcher1 kind: compute#urlMap name: sakajun-map pathMatchers : - defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service name: matcher1 routeRules : - matchRules : - prefixMatch : / routeAction : weightedBackendServices : - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service weight: 50 - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-secondary-service weight: 50 region: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1 selfLink: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/urlMaps/sakajun-map Just changing the weight!

Slide 40

Slide 40 text

// Update the current config gcloud beta compute url-maps import sakajun-map --region=us-west1 --source=config.yaml Demo: Primary 50% / Secondary 50% // Check the traffic $ ./test.sh *** *** Results of load balancing to 10.100.1.199: *** 480 This is Primary 520 This is Secondary

Slide 41

Slide 41 text

Demo: Destroy a Cluster by mistake Oops! I just destroyed one of the clusters…. Let’s fix it. Frontend Services Backend ILB Cloud Load Balancing Primary Cluster Kubernetes Engine Secondary Cluster Kubernetes Engine 50% 50%

Slide 42

Slide 42 text

Demo: Destroy a Cluster by mistake defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service hostRules: - description : '' hosts: - '*' pathMatcher : matcher1 kind: compute#urlMap name: sakajun-map pathMatchers : - defaultService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service name: matcher1 routeRules : - matchRules : - prefixMatch : / routeAction : weightedBackendServices : - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-primary-service weight: 0 - backendService : https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/backendServices/sakajun-secondary-service weight: 100 region: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1 selfLink: https://www.googleapis.com/compute/beta/projects/sakajunlabs-0916/regions/us-west1/urlMaps/sakajun-map Stop sending to the primary

Slide 43

Slide 43 text

// Update the current config gcloud beta compute url-maps import sakajun-map --region=us-west1 --source=config.yaml Demo: Destroy a Cluster by mistake // Check the traffic $ ./test.sh *** *** Results of load balancing to 10.100.1.199: *** 1000 This is Secondary

Slide 44

Slide 44 text

Demo: Destroy a Cluster by mistake Now we have a plenty of time to recover the deleted cluster! And next time, we can stop traffic before destroying clusters. Demo Ends.

Slide 45

Slide 45 text

Limitations - Internal LB Limitations - e.g. Shared VPC, IAP... - https://cloud.google.com/load-balancing/docs/l7-internal/#limitations - URL Map Limitations - Some resource does not work as intended - https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management#limitations

Slide 46

Slide 46 text

Takeaways

Slide 47

Slide 47 text

Takeaways With Internal HTTP Load Balancer (and thanks to envoy proxy), you can control traffic - of service with several versions - running in different workloads: VMs or containers without a rich control plane!

Slide 48

Slide 48 text

Thanks

Slide 49

Slide 49 text

Resources - Internal HTTP(S) Load Balancing concepts - https://cloud.google.com/load-balancing/docs/l7-internal/ - Setting Up Internal HTTP(S) Load Balancing for GKE pods - https://cloud.google.com/load-balancing/docs/l7-internal/set-up-gke-pods - Traffic management with route rules and traffic policies - https://cloud.google.com/load-balancing/docs/l7-internal/traffic-management - Network endpoint groups in load balancing concepts - https://cloud.google.com/load-balancing/docs/negs/ - Proxy-only subnets for internal HTTP(S) load balancers - https://cloud.google.com/load-balancing/docs/l7-internal/proxy-only-subnets