Rapid development of Kubernetes services with Telepresence
Tags: opensource, devtips, kubernetes, development
Published: 2017-10-04 21:52:26

---
title: Rapid development of Kubernetes services with Telepresence
published: true
description: Telepresence is an open source tool that simplifies the development of multi-container applications running on Kubernetes.
tags: opensource, devtips, kubernetes, development
canonical_url: https://www.telepresence.io/tutorials/kubernetes-rapid
---

Imagine you're developing a new Kubernetes service.
Typically the way you'd test is by changing the code, rebuilding the image, pushing the image to a Docker registry, and then redeploying the Kubernetes `Deployment`. This can be slow.

Or, you can use [Telepresence](https://www.telepresence.io). Telepresence will proxy a remote `Deployment` to a process running on your machine.
That means you can develop locally, editing code as you go, but test your service inside the Kubernetes cluster.

Let's say you're working on the following minimal server, `helloworld.py`:

```python
#!/usr/bin/env python3

from http.server import BaseHTTPRequestHandler, HTTPServer

class RequestHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/plain')
        self.end_headers()
        self.wfile.write(b"Hello, world!\n")
        return

httpd = HTTPServer(('', 8080), RequestHandler)
httpd.serve_forever()
```

You start a proxy inside your Kubernetes cluster that will forward requests from the cluster to your local process, and in the resulting shell you start the web server:

```
localhost$ telepresence --new-deployment hello-world --expose 8080
localhost$ python3 helloworld.py
```

This will create a new `Deployment` and `Service` named `hello-world`, which will listen on port 8080 and forward traffic to the process on your machine on port 8080.

You can see this if you start a container inside the Kubernetes cluster and connect to that `Service`.
In a new terminal run:

```console
localhost$ kubectl --restart=Never run -i -t --image=alpine console /bin/sh
kubernetes# wget -O - -q http://hello-world:8080/
Hello, world!
```

Now, switch back to the other terminal, kill `helloworld.py` and edit it so it returns a different string.
For example:

```console
python3 helloworld.py
^C
localhost$ sed s/Hello/Goodbye/g -i helloworld.py
localhost$ grep Goodbye helloworld.py
        self.wfile.write(b"Goodbye, world!\n")
localhost$ python3 helloworld.py
```

Now that we've restarted our local process with new code, we can send it another query from the other terminal where we have a shell running inside a Kubernetes pod:

```console
kubernetes# wget -O - -q http://hello-world:8080/
Goodbye, world!
kubernetes# exit
```

And there you have it: you edit your code locally, and changes are reflected immediately to clients inside the Kubernetes cluster without having to redeploy, create Docker images, and so on.

### Additional Resources 
If you're interested in trying Telepresence on your own, you can [install locally](https://www.telepresence.io/reference/install) with Homebrew, apt, or dnf. 

Or check out these other tutorials: 
* [Debugging services on Kubernetes](https://www.telepresence.io/tutorials/kubernetes)
* [Using Telepresence with Google Container Engine](https://cloud.google.com/community/tutorials/developing-services-with-k8s)
* [Getting started with OpenShift and Telepresence](https://www.telepresence.io/tutorials/openshift)
* [Telepresence and Minikube](https://www.telepresence.io/tutorials/minikube-vpn)

Have questions? Ask in the Telepresence [Gitter chatroom](https://gitter.im/datawire/telepresence) or [file an issue on GitHub](https://github.com/datawire/telepresence/issues/new). 

_This post originally appeared in the [Telepresence documentation](https://www.telepresence.io/tutorials/kubernetes-rapid)._