OC(1)
πΈ OC(1) β okay so here's the tea, bestie πΈ
okay so bestie, this is the OC(1) manual page for oc port-forward, and it's literally about forwarding one or more local ports to a pod. no cap. π― the way that this command just works is giving main character energy. iykyk. π
β¨ NAME β¨
oc port-forward β forward one or more local ports to a pod. that's the whole vibe. π
π¦ SYNOPSIS π¦
oc port-forward [OPTIONS]
π DESCRIPTION π
okay so picture this: you've got a pod running and you need to forward one or more local ports to it. that's literally what this command does. it's giving "i need to talk to this pod's service from my local machine" and oc port-forward is here to make it happen. slay. β¨
you can pick which pod by using resource type/name β like deployment/mydeployment β to select a pod. if you leave out the resource type, it just defaults to 'pod'. no cap.
and here's the thing, bestie: if there are multiple pods matching the criteria, a pod will be selected automatically. the algorithm picks one for you. but heads up β the forwarding session ends when the selected pod terminates, and you'll need to rerun the command to resume forwarding. so when your pod dies, your connection dies too. that's just the way it is. π
π OPTIONS π
here are the actual options that are specific to this command:
--address=[localhost]β addresses to listen on (comma separated). it only accepts IP addresses orlocalhostas a value. whenlocalhostis supplied, kubectl will try to bind on both127.0.0.1and::1and will fail if neither of these addresses are available to bind. so basically, if you say localhost, it's going to try both the IPv4 and IPv6 loopback addresses, and if neither works, it's a no-go. π--pod-running-timeout=0β the length of time (like5s,2m, or3h, higher than zero) to wait until at least one pod is running. so if your pod is still spinning up, you can tell it to wait a bit. the default is0, which means no waiting. you have to set it to something higher than zero (like5sor2m) to actually wait. β³
π OPTIONS INHERITED FROM PARENT COMMANDS π
these are the options that come from the parent commands. they're kind of the OG flags that get passed down. let's go through them one by one, bestie:
--as=""β username to impersonate for the operation. user could be a regular user or a service account in a namespace. so you're basically saying "pretend to be this user." π--as-group=[]β group to impersonate for the operation. this flag can be repeated to specify multiple groups. so if you need to impersonate multiple groups, just throw this flag in multiple times. π―--as-uid=""β UID to impersonate for the operation. like, the numeric user ID. π’--as-user-extra=[]β user extras to impersonate for the operation. this flag can be repeated to specify multiple values for the same key. so if the user has extra attributes, this is how you pass them. π--cache-dir="/homeless-shelter/.kube/cache"β default cache directory. that's the path where it caches stuff. the default is"/homeless-shelter/.kube/cache". kinda specific, ngl. π--certificate-authority=""β path to a cert file for the certificate authority. so if you've got a custom CA, point to it here. π--client-certificate=""β path to a client certificate file for TLS. your client cert goes here. π--client-key=""β path to a client key file for TLS. and the key that matches the cert goes here. π--cluster=""β the name of the kubeconfig cluster to use. pick which cluster from your kubeconfig. π’--context=""β the name of the kubeconfig context to use. pick which context. π--disable-compression=falseβ iftrue, opt-out of response compression for all requests to the server. so if you set it totrue, no compression. the default isfalse. ποΈ--insecure-skip-tls-verify=falseβ iftrue, the server's certificate will not be checked for validity. this will make your HTTPS connections insecure. so like, don't do this unless you're in a test environment or you're feeling reckless. the default isfalse. β οΈ--kubeconfig=""β path to the kubeconfig file to use for CLI requests. where's your kubeconfig? put the path here. π--kuberc=""β path to the kuberc file to use for preferences. this can be disabled by exportingKUBECTL_KUBERC=falsefeature gate or turning off the featureKUBERC=off. so if you don't want to use kuberc, you can disable it. π οΈ--match-server-version=falseβ require server version to match client version. iftrue, the server and client versions need to match. default isfalse. π―-n, --namespace=""β if present, the namespace scope for this CLI request. so you can scope the request to a specific namespace. π·οΈ--profile="none"β name of profile to capture. one of(none|cpu|heap|goroutine|threadcreate|block|mutex). so if you need performance profiling, this is where you pick which profile. default is"none". π--profile-output="profile.pprof"β name of the file to write the profile to. default is"profile.pprof". so it writes to that file by default. π--request-timeout="0"β the length of time to wait before giving up on a single server request. non-zero values should contain a corresponding time unit (e.g.1s,2m,3h). a value of zero means don't timeout requests. so0means wait forever. π°οΈ-s, --server=""β the address and port of the Kubernetes API server. where's your API server? put it here. π--tls-server-name=""β server name to use for server certificate validation. if it is not provided, the hostname used to contact the server is used. so if you need to override the server name for TLS validation, this is it. π--token=""β bearer token for authentication to the API server. your token goes here. ποΈ--user=""β the name of the kubeconfig user to use. pick which user from your kubeconfig. π€--warnings-as-errors=falseβ treat warnings received from the server as errors and exit with a non-zero exit code. iftrue, warnings become errors and the command exits non-zero. default isfalse. π¨
π EXAMPLE π
okay so here are the iconic examples. i'm going to put them in code blocks so you can see exactly what's going on. no cap, these are literally the best examples. π
listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod:
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
oc port-forward pod/mypod 5000 6000
listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment:
# Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment
oc port-forward deployment/mydeployment 5000 6000
listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service:
# Listen on port 8443 locally, forwarding to the targetPort of the service's port named "https" in a pod selected by the service
oc port-forward service/myservice 8443:https
listen on port 8888 locally, forwarding to 5000 in the pod:
# Listen on port 8888 locally, forwarding to 5000 in the pod
oc port-forward pod/mypod 8888:5000
listen on port 8888 on all addresses, forwarding to 5000 in the pod:
# Listen on port 8888 on all addresses, forwarding to 5000 in the pod
oc port-forward --address 0.0.0.0 pod/mypod 8888:5000
listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod:
# Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod
oc port-forward --address localhost,10.19.21.23 pod/mypod 8888:5000
listen on a random port locally, forwarding to 5000 in the pod:
# Listen on a random port locally, forwarding to 5000 in the pod
oc port-forward pod/mypod :5000
π SEE ALSO π
oc(1),β that's it, bestie. go read the main character's page. π
π HISTORY π
June 2016, Ported from the Kubernetes man-doc generator. so this page has been serving looks since 2016. iconic. π
this slay page was brought to you by Openshift and the Openshift CLI User Manuals, dated June 2016. periodt. π
π¦ where this page comes from
- nixpkgs unstable: openshift 4.22.0-202605222050
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms