- Published on
- Yair Mark
When working on an app that will go into a Kubernetes cluster ,be it minikube or a full blown cluster, it can be a pain developing the app against services it needs that live in the cluster. For example you may have configured these dependant service endpoints using the service name for example
http://some-service-svc:7001. The problem is when running your app locally you will not be able to connect using this setup.
Luckily that is exactly what Telepresence was built to tackle. You first start by installing it which is as simple as
telepresence. Then ensure that your Kubernetes context is set so that you are pointing to the cluster you want your local app needs to connect to. Finally in the same shell run:
telepresence --run-shell --namespace your-namespace
This will prompt you for your credentials so that it can get super user access I believe to setup a VPN proxy. The command outputs the following:
T: Invoking sudo. Please enter your sudo password. [sudo] password for youruser: T: Starting proxy with method 'vpn-tcp', which has the following limitations: All processes are affected, only one telepresence can run per machine, and you can't use other VPNs. You may T: need to add cloud hosts and headless services with --also-proxy. For a full list of method limitations see https://telepresence.io/reference/methods.html T: Volumes are rooted at $TELEPRESENCE_ROOT. See https://telepresence.io/howto/volumes.html for details. T: No traffic is being forwarded from the remote Deployment to your local machine. You can use the --expose option to specify which ports you want to forward. T: Guessing that Services IP range is 126.96.36.199/16. Services started after this point will be inaccessible if are outside this range; restart telepresence if you can't access a new T: Service.
Once it has finished running you will now be in a bash session that Telepresence has setup. Now say for example you are working on a nodejs app, to run it using Telepresence against your cluster from the same shell simply run
npm start or whatever command you use and your app will now speak to your cluster as if it were inside the cluster. Follow your normal dev process but running the app in this Telepresence shell when you want to test/debug something.
When you are done with your deving simply exit the shell as you normally would with