If you are just trying to do a quick check then you can port-forward to the pod - do kubectl get pods
to find the pod name and then kubectl port-forward <pod-name> 8080:8080
or whatever port you use if not 8080. Then you can hit your endpoint in your browser or with curl on localhost. For example, if you have the spring boot actuator running you could go to http://localhost:8080/actuator/health
.
If you are trying to access the Pod through the Service then you can port-forward to the Service but you may want to expose the Service externally. You'll want to pick how to expose it externally and set that up. Then you'll have an external URL you can use and won't need to go via the kube internal APIs.
It is also possible to construct a URL to hit the Service when proxying with kubectl proxy
. For example you could hit the actuator on a spring boot app using http (not https) with api/v1/namespaces/<namespace>/services/<http:><service_name>:<port_name>/proxy/actuator/health
. The <port_name>
will be in the service spec and you'll find it in the output of kubectl describe service
.