Skip to content

Commit 4855184

Browse files
authored
Merge pull request #31028 from didicodes/telepresence
Update: Developing and debugging services locally
2 parents 9b7902e + d971479 commit 4855184

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

content/en/docs/tasks/debug-application-cluster/local-debugging.md

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,56 @@ content_type: task
44
---
55

66
<!-- overview -->
7-
8-
Kubernetes applications usually consist of multiple, separate services, each running in its own container. Developing and debugging these services on a remote Kubernetes cluster can be cumbersome, requiring you to [get a shell on a running container](/docs/tasks/debug-application-cluster/get-shell-running-container/) and running your tools inside the remote shell.
9-
10-
`telepresence` is a tool to ease the process of developing and debugging services locally, while proxying the service to a remote Kubernetes cluster. Using `telepresence` allows you to use custom tools, such as a debugger and IDE, for a local service and provides the service full access to ConfigMap, secrets, and the services running on the remote cluster.
11-
7+
8+
Kubernetes applications usually consist of multiple, separate services, each running in its own container. Developing and debugging these services on a remote Kubernetes cluster can be cumbersome, requiring you to [get a shell on a running container](/docs/tasks/debug-application-cluster/get-shell-running-container/) in order to run debugging tools.
9+
10+
`telepresence` is a tool to ease the process of developing and debugging services locally while proxying the service to a remote Kubernetes cluster. Using `telepresence` allows you to use custom tools, such as a debugger and IDE, for a local service and provides the service full access to ConfigMap, secrets, and the services running on the remote cluster.
11+
1212
This document describes using `telepresence` to develop and debug services running on a remote cluster locally.
1313

14-
15-
16-
1714
## {{% heading "prerequisites" %}}
1815

19-
2016
* Kubernetes cluster is installed
2117
* `kubectl` is configured to communicate with the cluster
22-
* [Telepresence](https://www.telepresence.io/reference/install) is installed
23-
18+
* [Telepresence](https://www.telepresence.io/docs/latest/install/) is installed
2419

2520

2621
<!-- steps -->
2722

28-
## Getting a shell on a remote cluster
29-
30-
Open a terminal and run `telepresence` with no arguments to get a `telepresence` shell. This shell runs locally, giving you full access to your local filesystem.
31-
32-
The `telepresence` shell can be used in a variety of ways. For example, write a shell script on your laptop, and run it directly from the shell in real time. You can do this on a remote shell as well, but you might not be able to use your preferred code editor, and the script is deleted when the container is terminated.
23+
## Connecting your local machine to a remote Kubernetes cluster
24+
25+
After installing `telepresence`, run `telepresence connect` to launch it's Daemon and connect your local workstation to the cluster.
3326

34-
Enter `exit` to quit and close the shell.
27+
```
28+
$ telepresence connect
29+
30+
Launching Telepresence Daemon
31+
...
32+
Connected to context default (https://<cluster public IP>)
33+
```
3534

35+
You can curl services using the Kubernetes syntax e.g. `curl -ik https://kubernetes.default`
36+
3637
## Developing or debugging an existing service
3738

3839
When developing an application on Kubernetes, you typically program or debug a single service. The service might require access to other services for testing and debugging. One option is to use the continuous deployment pipeline, but even the fastest deployment pipeline introduces a delay in the program or debug cycle.
40+
41+
Use the `telepresence intercept $SERVICE_NAME --port $LOCAL_PORT:REMOTE_PORT` command to create an "intercept" for rerouting remote service traffic.
42+
43+
Where:
3944

40-
Use the `--swap-deployment` option to swap an existing deployment with the Telepresence proxy. Swapping allows you to run a service locally and connect to the remote Kubernetes cluster. The services in the remote cluster can now access the locally running instance.
45+
- `$SERVICE_NAME` is the name of your local service
46+
- `$LOCAL_PORT` is the port that your service is running on your local workstation
47+
- And `$REMOTE_PORT` is the port your service listens to in the cluster
4148

42-
To run telepresence with `--swap-deployment`, enter:
43-
44-
`telepresence --swap-deployment $DEPLOYMENT_NAME`
45-
46-
where $DEPLOYMENT_NAME is the name of your existing deployment.
47-
48-
Running this command spawns a shell. In the shell, start your service. You can then make edits to the source code locally, save, and see the changes take effect immediately. You can also run your service in a debugger, or any other local development tool.
49+
Running this command tells Telepresence to send remote traffic to your local service instead of the service in the remote Kubernetes cluster. Make edits to your service source code locally, save, and see the corresponding changes when accessing your remote application take effect immediately. You can also run your local service using a debugger or any other local development tool.
4950

51+
## How does Telepresence work?
5052

53+
Telepresence installs a traffic-agent sidecar next to your existing application's container running in the remote cluster. It then captures all traffic requests going into the Pod, and instead of forwarding this to the application in the remote cluster, it routes all traffic (when you create a [global intercept](https://www.getambassador.io/docs/telepresence/latest/concepts/intercepts/#global-intercept)) or a subset of the traffic (when you create a [personal intercept](https://www.getambassador.io/docs/telepresence/latest/concepts/intercepts/#personal-intercept)) to your local development environment.
5154

5255
## {{% heading "whatsnext" %}}
53-
54-
56+
5557
If you're interested in a hands-on tutorial, check out [this tutorial](https://cloud.google.com/community/tutorials/developing-services-with-k8s) that walks through locally developing the Guestbook application on Google Kubernetes Engine.
56-
57-
Telepresence has [numerous proxying options](https://www.telepresence.io/reference/methods), depending on your situation.
58-
59-
For further reading, visit the [Telepresence website](https://www.telepresence.io).
60-
61-
58+
59+
For further reading, visit the [Telepresence website](https://www.telepresence.io).

0 commit comments

Comments
 (0)