The easy way: kubectl port-forward
I guess everyone had this problem: You develop a new service or a new feature for an existing service, which needs to access some other service that runs on the cluster and is not accessible locally from your machine. Already you have a problem, since starting your whole application landscape with all dependencies and needed services most of the time is not possible on a single machine a developer has access to. But running your new service in the cloud comes with a lot of work and, quite possible, deployment specifics most of us don’t want to touch while developing a new service. The easy way to do this comes with kubernetes: kubectl port-forward.
The practical way: kubefwd
The fancy way: telepresence
telepresence --swap-deployment <deployment> \
--docker-run --rm \
-e MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -v$(pwd):/build \
-v $HOME/.m2/repository:/m2 \
-p 8080:8080 \
-p 5005:5005 \
maven mvn -Dmaven.repo.local=/m2 \
-f /build spring-boot:run
Further tools and reading
squash is a debugger for kubernetes. It spawns a squash pod which attaches a remote debugger to your application pod, which you can attach to. At least that is what I understood of it, as the documentation is still a bit shallow. I had some problems getting it to run and could only get it to run within VS Code, which is not my preferred IDE for my use case.
This is the “I run everything local” approach. If the services you use are small enough to do this, maybe this is the solution for you. I personally don’t like to run more then I need and so use docker-compose only rarely.
While minikube can help you deploy all the services and run them on kubernetes, and you can attach your local container registry, the major problem of debugging can not really be solved with minikube alone. Telepresence however can interact really well with minikube, so the combination might solve some problems like missing permission on a given Kubernetes cluster.