DocsTelepresenceTelepresence in Docker Quick Start
Telepresence in Docker Quick Start
Contents
Overview
This quickstart provides the fastest way to get an understanding of how Telepresence can speed up your development in Kubernetes within docker. It should take you about 5-10 minutes. You'll create a local cluster using Kind with a sample app installed, and use Telepresence to redirect traffic from a workload in your cluster to a local docker image.
Prerequisites
You’ll need kubectl
installed and set up
(Linux /
macOS /
Windows)
to use a Kubernetes cluster.
You will also need Docker installed.
1. Install the Telepresence CLI
GNU/Linux
macOS
Windows
We offer an easy installation path using an MSI Installer. However if you'd like to setup Telepresence using Powershell, you can run these commands:
2. Set up a local cluster with sample app
We provide a repo that sets up a local cluster for you
with the in-cluster Telepresence components and a sample app already installed. It does not need sudo
or Run as Administrator
privileges.
GNU/Linux
macOS
Windows
3. Use Telepresence to connect your laptop to the cluster
Connect to the cluster:
telepresence connect --docker --namespace <namespace>
Normally, Telepresence would provide cluster dns for your browser, but, in docker mode, the telepresence daemons are running inside docker; Telepresence is only providing cluster dns to that docker network. To open our app in a browser, we will need to use kubectl to connect to it. Port-forward a connection to the ingress in the demo cluster:
kubectl port-forward service/verylargejavaservice 8080:8080
Open the app in your browser by typing http://localhost:8080/ into the search bar.
You are connected to the VeryLargeJavaService, which talks to the DataProcessingService as an upstream dependency. The DataProcessingService in turn has a dependency on VeryLargeDatastore.
4. Route traffic from the cluster to your local application
Historically, when developing microservices with Kubernetes, your choices have been to run an entire set of services in a cluster or namespace just for you, and spend 15 minutes on every one-line change, pushing the code, waiting for it to build, waiting for it to deploy, etc. Or, you could run all 50 services in your environment on your laptop, and be deafened by the fans.
With Telepresence, you can intercept traffic from a service in the cluster and route it to your laptop, effectively replacing the cluster version
with your local development environment. This gives you back the fast feedback loop of local development, and access to your preferred tools like your favorite IDE or debugger.
And you still have access to all the cluster resources via telepresence connect
. Now you'll see this in action.
Next, we’ll create an intercept. An intercept is a rule that tells Telepresence where to send traffic. In this example, we will send all traffic destined for the DataProcessingService to the version of the DataProcessingService running locally instead:
Start the intercept with the
intercept
command, setting the service name and port:telepresence intercept --port <local port>:<service port> <workload name> --docker-run -- <docker run flags> <image name> <image flags>
Go to the frontend service again in your browser and refresh (if you closed the
port-forward
from step 3, you will have to re-start it). You will now see the blue elements in the app.
What's Next?
Collaborating
Use personal intercepts to get specific requests when working with colleagues.
Outbound Sessions
Control what your laptop can reach in the cluster while connected.
Telepresence for Docker Compose
Develop in a hybrid local/cluster environment using Telepresence for Docker Compose.