Exposing kubernetes service locally (without minikube) Exposing kubernetes service locally (without minikube) kubernetes kubernetes

Exposing kubernetes service locally (without minikube)


Do you want to acccess the pod being served by the service? if yes, you can use kubectl port-forward to connect to your pod and access it locally

Here is an example:

If you have a service which forwards all the requests to a pod ( nginx ) at port number 80 you can configure it to your local port as follows

kubectl port-forward -n default nginx-5767f4d585-hgtfj 8081:80

Here is the syntax of the same

kubectl port-forward -n NAMESPACE ${POD} local-port:pod-port

If you want to connect to your service directly, you need to do it via kubectl proxy

Here is a reference

Hope it helps.