Skip to main content
This guide shows how to use Telepresence to intercept traffic for a Kubernetes deployment so you can run and debug a service locally while cluster traffic is routed to your workstation. This is ideal for faster iteration: no image build/push cycles are required and you can use your IDE and debugger directly. Prerequisite: Telepresence is already connected to the cluster (verify with telepresence status).

1) Find the deployment to intercept

List deployments to identify the workload you want to intercept (example: auth-depl):
Example output:
You can also confirm Telepresence connectivity before creating an intercept:

2) Choose local and service ports

Decide which local port your process will listen on and the service port used by the pod. If the pod only exposes one port, the service port suffix can be omitted in the intercept command. If multiple ports exist on the workload, specify the service port (e.g., :3000).

3) Create the intercept

Map a local port to the service port and create the intercept:
Example Telepresence confirmation:
When active, Telepresence injects the traffic agent into the pod and forwards service traffic to 127.0.0.1:8000 on your machine.

4) Run the service locally

Switch to the service directory and start the app so it listens on the chosen local port (8000 in the example). Example index.js (auth service) listening on port 8000:
Start the service locally (example uses nodemon):
Example output:
Running the service locally lets you use your IDE and debugger directly on code that would otherwise run in the cluster — no image build/push required.

5) Verify the cluster routes traffic to your local process

From inside the cluster (for example, from another pod or using cluster DNS), a request to the service name should route to your local process. Example: curl the service auth-service on port 3000 from another pod:
Expected response:
This demonstrates that Telepresence forwarded cluster traffic to your workstation.

6) What Telepresence installs in the pod?

When an intercept is active, Telepresence adds a traffic-agent container to the intercepted pod to forward traffic. Inspect pods and describe the intercepted pod:
Example excerpt (condensed):
The traffic-agent container is responsible for redirecting the pod traffic to your machine.

7) Remove an intercept

List current intercepts:
Example output while auth-depl is intercepted:
To remove the intercept:
Verify it has been removed:
Example output after leaving:

8) Intercept another service (example: products)

Repeat the same workflow for additional deployments. Example for products-depl:
  1. Identify the deployment:
  1. Create an intercept (use a different local port if 8000 is in use, e.g., 9000):
  1. Run the products service locally and ensure it listens on the chosen port.
Note: Multiple intercepts can be active simultaneously; ensure local ports do not conflict.

9) Debugging: missing environment variables when running locally

When you run service code outside the pod, the pod’s environment variables are not automatically available on your machine. If the service relies on pod-provided env vars (for service discovery, API URLs, credentials, etc.), you must replicate them locally. Example symptom observed for the products service:
  • Public LoadBalancer requests hung.
  • Local products process logged:
This indicates API_URL was undefined locally. Relevant server code:
apiURL was populated from an environment variable:
In the deployment manifest the pod receives API_URL:
To avoid runtime errors when developing locally, provide the same env vars on your workstation. Options:
  • Create a .env file and use dotenv.
  • export API_URL="http://inventory-service:3000/" in your shell.
  • Use a tooling approach to inject pod env into your local environment.
Tip: If you see a URL- or host-related error after intercepting, check that any service discovery or env vars used to contact other services are present in your local environment.

Summary & quick reference

  • Create an intercept:
    • telepresence intercept <deployment> -p <localPort>:<servicePort>
  • Start your service locally on <localPort>.
  • Telepresence injects a traffic-agent container into the pod to forward traffic.
  • To remove an intercept: telepresence leave <intercept-name>.
  • Remember to replicate pod environment variables locally if your code depends on them.
You can fetch and replicate a pod’s environment variables locally so your process behaves identically to the pod.

Watch Video