I have springboot microservice running inside docker container (Kubernetes) which can access unmanaged services (SQL, Elasticsearch, etc), which are not accessible from my laptop directly, so I’m forced to run commands via kubectl to access them. Is there a posibility to forward TCP connections through docker containers to enable direct access to those service, something like ssh port forwarding?
2
Answers
Yep, you can use
kubectl port-forward
to do exactly this. If you’d like to read the documentation it’s here.For this you have to create a
"service without selector"
and defineendpoints
for your "external" resourcesKubernetes doc on such services here
Of course, your service can be of type
"NodePort"
, so with the help of your load balancer in front of OCP, you can access the service from outside your cluster and the service will reach your external resource