Ambassador Integration with Consul Connect
In addition to enabling Kubernetes services to discover and securely connect to each other, Connect also can help route traffic into a Kubernetes cluster from outside, when paired with an ingress controller like DataWire's Ambassador.
Ambassador is a popular Kubernetes-native service that acts as an ingress controller or API gateway. It supports an optional integration with Consul that allows it to route incoming traffic to the proxies for your Connect-enabled services.
This means you can have end-to-end encryption from the browser, to Ambassador, to your Kubernetes services.
Installation
Before you start, install Consul and enable Connect on the agents inside the cluster. Decide whether you will enable service sync or manually register your services with Consul.
Once you have tested and verified that everything is working, you can proceed with the Ambassador installation. Full instructions are available on the Ambassador site, but a summary of the steps is as follows:
If you are deploying to GKE, create a RoleBinding
to grant you cluster admin
rights:
Install Ambassador and a LoadBalancer
service for it:
Install the Ambassador Consul Connector:
Add TLSContext
and Mapping
annotations to your existing services, directing
HTTPS traffic to port 20000, which is opened by the Connect proxy. Here is an
example of doing this for the static-server
example used in the documentation
for the Connect sidecar:
Once Ambassador finishes deploying, you should have a new LoadBalancer
service
with a public-facing IP address. Connecting to the HTTP port on this address
should display the output from the static service.
Enabling end-to-end TLS
The Ambassador service definition provided in their documentation currently does not serve pages over HTTPS. To enable HTTPS for full end-to-end encryption, follow these steps.
First, upload your public SSL certificate and private key as a Kubernetes secret.
Download a copy of the ambassador-service.yaml file from Ambassador. Replace
the metadata
section with one that includes an Ambassador TLS configuration block,
using the secret name you created in the previous step. Then add an entry for port 443
to the LoadBalancer
spec. Here is a complete example:
Update the service definition by applying it with kubectl
:
You should now be able to test the SSL connection from your browser.
Troubleshooting
When Ambassador is unable to establish an authenticated connection to the Connect proxy servers, browser connections will display this message:
This error can have a number of different causes. Here are some things to check and troubleshooting steps you can take.
Check intentions between Ambassador and your upstream service
If you followed the above installation guide, Consul should have registered a service called "ambassador". Make sure you create an intention to allow it to connect to your own services.
To check whether Ambassador is allowed to connect, use the intention check
subcommand.
Confirm upstream proxy sidecar is running
First, find the name of the pod that contains your service.
Then describe the pod to make sure that the sidecar is present and running.
Start up a downstream proxy and try connecting to it
Log into one of your Consul server pods (or any pod that has a Consul binary in it).
Once inside the pod, try starting a test proxy. Use the name of your service in place of http-echo
.
If the proxy starts successfully, try connecting to it. Verify the output is as you expect.
Don't forget to kill the test proxy when you're done.
Check Ambassador Connect sidecar logs
Find the name of the Connect Integration pod and make sure it is running.
Dump the logs from the integration pod. If the service is running correctly, there won't be much in there.
Check Ambassador logs
Make sure the Ambassador pod itself is running.
Finally, check the logs for the main Ambassador pod.
Check Ambassador admin interface
Forward the admin port from the Ambassador pod to your local machine.
You should then be able to open http://localhost:8877/ambassador/v0/diag/ in your browser and view Ambassador's routing table. The table lists each URL mapping that has been set up. Service names will appear in green if Ambassador believes they are healthy, and red otherwise.
From this interface, you can also enable debug logging via the yellow "Set Debug On" button, which might give you a better idea of what's happening when requests fail.
Getting support
If you have tried the above troubleshooting steps and are still stuck, DataWire provides support for Ambassador via the popular Slack chat app. You can request access and then join the #ambassador
room to get help.