Kubernetes is great for operations but ideally speaking, it’s not something developers should concern themselves about. In reality, apps developed for Kubernetes are different because they interact with other services and could be stateful, both of which are tough to replicate in a local setup. Developers are used to the luxury of hot reloading and debugging to quickly test and improve the app. When it comes to developing apps for Kubernetes, the developer needs to build and push the container image to the registry and then update Kubernetes pod. After all the time consuming tasks, developers still can’t hot-reload and debug their apps directly.
Over the time, there have been tools which help fasten the process of building the container image, automate the process of pushing to the registry and update Kubernetes with the change. While these tools can be a great addition, they’re quite inadequate from a developer’s perspective.
Telepresence is a lightweight development tool that can help you to debug and develop apps deployed to Kubernetes seamlessly. Basically, you could have a process running on your local system (without necessarily having to build containers) and telepresence will proxy all the requests back and forth from the cluster to that process. How does it do it?
It replaces your existing deployments with it’s own pod which runs a reverse-proxy that connects with our local system to forward and receive requests. This makes it possible for an app running locally to talk to other services which are running inside the Kubernetes cluster. You can find instructions on how to install it here.
Initially, there’s an existing deployment in the cluster which is running an API which returns “Hello World”. In this demo, I am going to replace the “Hello World” API deployed to Kubernetes with a process running locally that interacts with Kubernetes API to list the pods across namespaces with just one Telepresence command. Although I have interacted with Kubernetes API in this example, you could essentially interact with just about any other service.
As you can see, following the –run can be the command to run just about any binary on your local system which would run in context of Kubernetes, at least networking wise. In the demo, I had run the Uvicorn server.
Hopefully, this demonstrates how simple it can be to develop apps that need to interact with existing services deployed in Kubernetes. There might be times where you might want to forward requests to a container running locally, you can do that too with –docker-run instead of –run . Debugging and hot reloading apps in local containers can be done by VS Code’s Remote Development extension. You can also find language specific extensions, here’s one for Go.
You can find the code used in the above demo here.
There are couple of limitations as of now :
The following tools provide a way for in-cluster development which syncs with your local files. By going where the app resides, this solves both networking and storage issues for development.
Telepresence is a network proxy that connects with your local system to help develop apps in Kubernetes. A lot of projects are emerging in the space of development tools for Kubernetes. Telepresence is definitely on top of my list since it requires no configuration and simple to use. Please, drop a comment below to let us know which tools you have used and what you liked/disliked about them.