Use Port Forwarding to Access Applications in a Cluster
If you need to connect directly to a tcp-port in a pod you can do this with port forwarding.
So for example to access the redis pod in the namespace redis you will use this on the client:
kubectl port-forward redis1-master-0 6379:6379 -n redis
"redis1-master" is the pod name.
You canncan then access redis with a client to localhost:6379
Get pod names
To get all pod names from namespace redis use the following:
$ kubectl get pods -n redis
NAME READY STATUS RESTARTS AGE
redis1-master-0 1/1 Running 0 39h
redis1-replicas-0 1/1 Running 0 39h
redis1-replicas-1 1/1 Running 0 39h
redis1-replicas-2 1/1 Running 0 39h
Links
https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/