The purpose of this demo is to showcase how can we debug a Kubernetes service locally using Telepresence. There is a minimal client-server Kubernetes application, with a React (Javascript) front-end, and a SpringBoot (Java) back-end. The application can be packaged in a Helm chart.
You need to have Docker, Kubectl, Minikube, NGINX Ingress Controller, Helm, and Telepresence installed.
- To build the demo (build docker images and package the helm chart) :
.\gradlew buildApp
- To build and deploy into a Kubernetes cluster:
.\gradlew deployApp
- After deploying the application to the Kubernetes cluster:
- Go to the server folder:
$ cd server
- Build a local docker image:
$ docker build -t k8s-demo-server-img .
- Swap the remote deployment with the local Docker image:
$ telepresence --swap-deployment k8s-demo:server --expose 8000:8002 --docker-run --rm -it k8s-demo-server-img
- If you want to remote debug the back-end:
$ telepresence --swap-deployment k8s-demo:server --expose 8000:8002 --docker-run --rm -it -p 5005:5005 -e JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=y k8s-demo-server-img
- In case you are using a Kubernetes client:
telepresence --mount /tmp/known --swap-deployment k8s-demo:server --expose 8000:8002 --docker-run --rm -it -v=/tmp/known/var/run/secrets:/var/run/secrets k8s-demo-server-img
- All in one!:
telepresence --mount /tmp/known --swap-deployment k8s-demo:server --expose 8000:8002 --docker-run --rm -it -p 5005:5005 -e JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=y -v=/tmp/known/var/run/secrets:/var/run/secrets k8s-demo-server-img
- Go to the server folder:
|-- client/ | |-- src/: front-end source code. | |-- Dockerfile: front-end Docker image recipe. | |-- build.gradle: build Docker image task. | |-- package.json: project metadata. |-- server/ | |-- build/: build directory (jar file destination). | |-- src/: back-end source code. | |-- Dockerfile: back-end Docker image recipe. | |-- build.gradle: build Docker image task. |-- helm/ | |-- chart/ | | |-- templates/: parameterizable Kubernetes objects. | | |-- Chart.yaml: name and version information. | | |-- values.yaml: values to feed the templates. | |-- build.gradle: helm chart package task. |-- build.gradle: build and deploy tasks. |-- settings.gradle
- Client and Server are running in different Docker containers, inside a single pod.
- A service is exposing the pod inside the Kubernetes cluster.
- The ingress allows access to the service from outside the Kubernetes cluster.
To access the application:
- Front-end:
http://<hostname>/client
- Backend:
http://<hostname>/server
http://<hostname>/server/services
- Leonardo Coelho - leonardo.coelho@ua.pt