Use port forwarding
You can use the OpenShift CLI (oc) to port-forward one or more local ports to a pod.
Procedure
-
Use a command similar to the following to listen on the specified port in a pod:
$ oc port-forward <pod> [<local_port>:]<remote_port> [...[<local_port_n>:]<remote_port_n>]For example, use the following command to listen on ports
5000and6000locally and forward data to and from ports5000and6000in the pod:$ oc port-forward <pod> 5000 6000Example outputForwarding from 127.0.0.1:5000 -> 5000 Forwarding from [::1]:5000 -> 5000 Forwarding from 127.0.0.1:6000 -> 6000 Forwarding from [::1]:6000 -> 6000For example, use the following command to listen on port
8888locally and forward to5000in the pod:$ oc port-forward <pod> 8888:5000Example outputForwarding from 127.0.0.1:8888 -> 5000 Forwarding from [::1]:8888 -> 5000For example, use the following command to listen on a free port locally and forward to
5000in the pod:$ oc port-forward <pod> :5000Example outputForwarding from 127.0.0.1:42390 -> 5000 Forwarding from [::1]:42390 -> 5000Alternatively, use the following command to listen on a free port locally and forward to
5000in the pod:$ oc port-forward <pod> 0:5000