Docsright arrowEdge Stackright arrowAmbassador Edge Stack with GKE

5 min • read

Ambassador Edge Stack with GKE

Google offers a L7 load balancer to leverage network services such as managed SSL certificates, SSL offloading or the Google content delivery network. A L7 load balancer in front of Ambassador Edge Stack can be configured by hand or by using the Ingress-GCE resource. Using the Ingress resource also allows you to create Google-managed SSL certificates through Kubernetes.

With this setup, HTTPS will be terminated at the Google load balancer. The load balancer will be created and configured by the Ingress-GCE resource. The load balancer consists of a set of forwarding rules and a set of backend services. In this setup, the ingress resource creates two forwarding rules, one for HTTP and one for HTTPS. The HTTPS forwarding rule has the SSL certificates attached. Also, one backend service will be created to point to a list of instance groups at a static port. This will be the NodePort of the Ambassador Edge Stack service.

With this setup, the load balancer terminates HTTPS and then directs the traffic to the Ambassador Edge Stack service via the NodePort. Ambassador Edge Stack is then doing all the routing to the other internal/external services.

Overview of steps

  1. Install and configure the ingress with the HTTP(S) load balancer
  2. Install Ambassador Edge Stack
  3. Configure and connect Ambassador Edge Stack to ingress
  4. Create an SSL certificate and enable HTTPS
  5. Create BackendConfig for health checks
  6. Configure Ambassador Edge Stack to do HTTP -> HTTPS redirection

ambassador will be running as a NodePort service. Health checks will be configured to go to a BackendConfig resource.

0. Ambassador Edge Stack

This guide will install Emissary-ingress. You can also install Ambassador Edge Stack. Please note:

  • The ingress and the ambassador service need to run in the same namespace
  • The ambassador service needs to be of type NodePort and not LoadBalancer. Also remove the line with externalTrafficPolicy: Local
  • Ambassador-Admin needs to be of type NodePort instead of ClusterIP since it needs to be available for health checks

1 . Install and configure ingress with the HTTP(S) load balancer

Create a GKE cluster through the web console. Use the release channel. When the cluster is up and running follow this tutorial from Google to configure an ingress and a L7 load balancer. After you have completed these steps you will have a running L7 load balancer and one service.

2. Install Ambassador Edge Stack

Follow the first section of the Emissary-ingress installation guide to install Emissary-ingress. Stop before defining the ambassador service.

Ambassador Edge Stack needs to be deployed as NodePort instead of LoadBalancer to work with the L7 load balancer and the ingress.

Save the YAML below in ambassador.yaml and apply with kubectl apply -f ambassador.yaml

You will now have an ambassador service running next to your ingress.

3. Configure and connect ambassador to the ingress

You need to change the ingress for it to send traffic to ambassador. Assuming you have followed the tutorial, you should have a file named basic-ingress.yaml. Change it to point to ambassador instead of web:

Now let's connect the other service from the tutorial to ambassador by specifying a Mapping:

All traffic will now go to ambassador and from ambassador to the web service. You should be able to hit your load balancer and get the output. It may take some time until the load balancer infrastructure has rolled out all changes and you might see gateway errors during that time. As a side note: right now all traffic will go to the web service, including the load balancer health check.

4. Create an SSL certificate and enable HTTPS

Read up on managed certificates on GKE. You need a DNS name and point it to the external IP of the load balancer.

certificate.yaml:

Modify the ingress from before:

Please wait (5-15 minutes) until the certificate is created and all edge servers have the certificates ready. kubectl describe ManagedCertificate will show you the status or go to the web console to view the load balancer.

You should now be able to access the web service via https://www.example.com.

5. Configure BackendConfig for health checks

Create and apply a BackendConfig resource with a custom health check specified:

Then edit your previous ambassador.yaml file to add an annotation referencing the BackendConfig and apply the file:

6. Configure Ambassador Edge Stack to do HTTP -> HTTPS redirection

Configure Ambassador Edge Stack to redirect traffic from HTTP to HTTPS. You will need to restart Ambassador Edge Stack to effect the changes with kubectl rollout restart deployment ambassador.

The result should be that http://www.example.com will redirect to https://www.example.com.

You can now add more services by specifying the hostname in the Mapping.