This repository contains a demonstration project showcasing the usage of Telepresence with two microservices, Ping and Pong, running in a local Minikube cluster. The purpose of this project is to demonstrate how local development can be seamlessly integrated with services running in a Kubernetes environment.
This project leverages Telepresence to allow developers to debug and develop services locally as if they were running in a Kubernetes cluster. It includes a basic setup where the Ping service calls the Pong service. With Telepresence, developers can intercept these calls to route them to a local instance of the Pong service, enabling easier testing and development.
Before setting up this project, please ensure you have the following installed on your MacOS system:
- Docker
- Minikube
- Telepresence
- kubectl
- curl (for testing HTTP requests)
- Node.js (to run the Pong service locally)
Follow these steps to set up the necessary components and deploy the Ping and Pong services to your local Kubernetes cluster using Minikube:
Install Telepresence by following the Telepresence Installation Guide.
Follow the Minikube Installation Guide to install Minikube.
Start your Minikube cluster with the following command:
minikube start
-
Initialize the project:
Make the initialization and cleanup scripts executable:
chmod +x init.sh chmod +x cleanup.sh
Run the initialization script:
./init.sh
-
Enable access to the Ping service:
In a new terminal window, forward the Ping service port to access it locally:
kubectl port-forward svc/ping 30000:3000
In the initial terminal window, test the Ping service; it should return "pong":
curl localhost:30000/ping
Here’s how to use Telepresence to debug and develop locally:
-
Set up Telepresence:
telepresence helm install telepresence connect
Verify the setup:
telepresence status telepresence list
-
Intercept and modify the Pong service:
Intercept traffic to the Pong service:
telepresence intercept pong --port 3000:3000
Before running the Pong service locally, modify the response handler:
- Open
./pong/index.js
- Comment out the line
res.send('pong');
- Uncomment the line
// res.send('foobar');
Start the local Pong service:
node ./pong/index.js
Test the Ping service again; it should now return "foobar":
curl localhost:30000/ping
- Open
-
Revert to cluster-managed service:
Stop intercepting traffic:
telepresence leave pong
Test the Ping service to confirm it's routing through the cluster; it should return "pong" again:
curl localhost:30000/ping
To remove the deployed services and stop using resources, follow these steps:
-
Switch to the terminal window where port forwarding is running and terminate it by pressing
CTRL+C
. -
In your initial terminal window, execute:
./cleanup.sh telepresence helm uninstall telepresence quit minikube stop
Contributions are welcome! For more information on how to contribute, please refer to the CONTRIBUTING.md file.
This project is distributed under the MIT License. See the LICENSE file for more details.