OpenShift - Create a port forward rule using the oc port-forward command

by
Jeremy Canfield |
Updated: November 08 2022
| OpenShift articles
Let's say you have a pod named hello-openshift that is listening on port 8080.
~]# oc describe pod hello-openshift | grep -i port
Port: 8080/TCP
The oc port-forward command can be used to create a port forward rule that will be used to forward the request from some other port to port 8080.
~]# oc port-forward pod/hello-openshift 12345:8080
Forwarding from 127.0.0.1:12345 -> 8080
Forwarding from [::1]:12345 -> 8080
The oc adm policy who-can command can be used to determine if you have a role that grants permission to create a port forward rule. You may need to Add or Remove a Role Binding from a User Group or Service Account.
~]$ oc adm policy who-can create port-forward
Namespace: my-project
Verb: create
Resource: port-forward
Users: system:admin
system:serviceaccount:my-project:my-service-account
Groups: my-group
Openshift_Admin
system:cluster-admins
Did you find this article helpful?
If so, consider buying me a coffee over at