This guide provides you with a hands-on tutorial with Telepresence and Golang. To go through this tutorial, the only thing you'll need is a computer that runs Docker Desktop >=20.10.7. We'll give you a pre-configured remote Kubernetes cluster and a Docker container to run locally.
If you don't have Docker Desktop already installed, go to the Docker download page and install Docker.
Telepresence connects your local workstation with a remote Kubernetes cluster. In this tutorial, you'll start with a pre-configured, remote cluster.
- Get a Free Remote Cluster
Sign in to Ambassador Cloud to activate your demo cluster.
- Go to the Service Catalog to see all the services deployed on your cluster.The Service Catalog gives you a consolidated view of all your services across development, staging, and production. After exploring the Service Catalog, continue with this tutorial to test the application in your demo cluster.
The remote cluster is running the Emojivoto application, which consists of four services. Test out the application:
Go to the Emojivoto webapp and vote for some emojis.
Now, click on the 🍩 emoji. You'll see that a bug is present, and voting 🍩 doesn't work.
The bug is present in the
voting-svc service, you'll run that service locally. To save your time, we prepared a Docker container with this service running and all you'll need to fix the bug.
Run the Docker container locally, by running this command inside your local terminal:
The application is failing due to a little bug inside this service which uses gRPC to communicate with the others services. We can use
grpcurlto test the gRPC endpoint and see the error by running:
In order to fix the bug, use the Docker container's embedded IDE to fix this error. Go to http://localhost:8083 and open
api/api.go. Remove the
"fmt"package by deleting the line 5.
and also replace the line
Then save the file (
Cmd+sfor Mac or
Menu -> File -> Save) and verify that the error is fixed now:
Now the bug is fixed, you can use Telepresence to intercept all the traffic through our local service. Run the following command inside the container:
Now you can go back to Emojivoto webapp and you'll see that voting for 🍩 woks as expected.
You have created an intercept to tell Telepresence where to send traffic. The
voting-svc traffic is now destined to the local Dockerized version of the service. This intercepts all the traffic to the local
voting-svc service, which has been fixed with the Telepresence intercept.
Preview URLs allows you to safely share your development environment. With this approach, you can try and test your local service more accurately because you have a total control about which traffic is handled through your service, all of this thank to the preview URL.
First leave the current intercept:
Then login to telepresence:
Create an intercept, which will tell Telepresence to send traffic to the service in our container instead of the service in the cluster.
When prompted for ingress configuration, you need to enter edge-stack.ambassador as your DNS for the first and last questions. For the remaining questions, the default values are correct.
If you access the Emojivoto webapp application on your remote cluster and vote for the 🍩 emoji, you'll see the bug is still present.
Vote for the 🍩 emoji using the Preview URL obtained in the previous step, and you will see that the bug is fixed, since traffic is being routed to the fixed version which is running locally.
You've intercepted a service in one of our demo clusters, now you can use Telepresence to intercept a service in your own environment!