OC(1)
π
OC(1) β ok bestie, let's talk about oc proxy π«Ά
You're looking at the <cyan>oc</cyan> manual page, and specifically the <pink>oc proxy</pink> command, because apparently you want a whole proxy server and you want it now. No cap, this one's a baddie.
β¨ NAME β¨
oc proxy β literally just runs a proxy to the Kubernetes API server. That's the whole assignment. π
π¦ SYNOPSIS π¦
oc proxy [OPTIONS]
πΈ DESCRIPTION πΈ
Okay so picture this: it creates a proxy server, or if you're feeling fancy, an application-level gateway, sitting right between localhost and the Kubernetes API server. Iconic behavior honestly. β¨
It also lets you serve static content over whatever HTTP path you specify β because why not, main character energy.
Here's the vibe check on how data flows: all incoming data enters through one port and gets forwarded to the remote Kubernetes API server port. The one exception? Paths that match the static content path β those get served as static content instead. Periodt. π
π OPTIONS π
--accept-hosts="^localhost$,^127\.0\.0\.1$,^\[::1\]$"β the regular expression for hosts the proxy should accept. Default only trusts localhost stuff, lowkey protective. π--accept-paths="^.*"β regular expression for paths the proxy should accept. Default is "everything," so, slay.--address="127.0.0.1"β the IP address to serve on.--api-prefix="/"β the prefix to serve the proxied API under.--append-server-path=falseβ iftrue, it enables automatic path appending of the kube context server path to each request.--disable-filter=falseβ iftrue, disables request filtering in the proxy.
β οΈ Bestie, listen to me: this is dangerous. It can leave you vulnerable to XSRF attacks when used with an accessible port. Do not just turn this on for funsies. π
--keepalive=0βkeepalivespecifies the keep-alive period for an active network connection. Set it to0to disable keepalive.-p,--port=8001β the port to run the proxy on. Set it to0and it'll pick a random port for you. Cute.--reject-methods="^$"β regular expression for HTTP methods the proxy should reject. Example:--reject-methods='POST,PUT,PATCH'. π ββοΈ--reject-paths="^/api/./pods/./exec,^/api/./pods/./attach"β regular expression for paths the proxy should reject. And heads up: paths specified here get rejected even if they're accepted by--accept-paths. Rejection wins, no discussion. π-u,--unix-socket=""β the Unix socket to run the proxy on.-w,--www=""β also serve static files from the given directory, under the specified prefix.-P,--www-prefix="/static/"β the prefix to serve static files under, if a static file directory is specified.
π OPTIONS INHERITED FROM PARENT COMMANDS π
Yep, these come from the parent command β but they're still yours, bestie. π«Ά
--as=""β username to impersonate for the operation. User could be a regular user or a service account in a namespace.--as-group=[]β group to impersonate for the operation. This flag can be repeated to specify multiple groups.--as-uid=""β UID to impersonate for the operation.--as-user-extra=[]β user extras to impersonate for the operation. This flag can be repeated to specify multiple values for the same key.--cache-dir="/homeless-shelter/.kube/cache"β default cache directory.--certificate-authority=""β path to a cert file for the certificate authority.--client-certificate=""β path to a client certificate file for TLS.--client-key=""β path to a client key file for TLS.--cluster=""β the name of the kubeconfig cluster to use.--context=""β the name of the kubeconfig context to use.--disable-compression=falseβ iftrue, opt out of response compression for all requests to the server.--insecure-skip-tls-verify=falseβ iftrue, the server's certificate will not be checked for validity.
π This will make your HTTPS connections insecure. Like, actually insecure. You've been warned.
--kubeconfig=""β path to the kubeconfig file to use for CLI requests.--kuberc=""β path to the kuberc file to use for preferences. This can be disabled by exporting theKUBECTL_KUBERC=falsefeature gate or turning off the featureKUBERC=off.--match-server-version=falseβ require server version to match client version.-n,--namespace=""β if present, the namespace scope for this CLI request.--profile="none"β name of the profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex).--profile-output="profile.pprof"β name of the file to write the profile to.--request-timeout="0"β how long 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. β¨-s,--server=""β the address and port of the Kubernetes API server.--tls-server-name=""β server name to use for server certificate validation. If it's not provided, the hostname used to contact the server is used.--token=""β bearer token for authentication to the API server.--user=""β the name of the kubeconfig user to use.--warnings-as-errors=falseβ treat warnings received from the server as errors and exit with a non-zero exit code. Harsh but fair. π
π EXAMPLE π
Okay this is the part where it all clicks, watch:
# To proxy all of the Kubernetes API and nothing else
oc proxy --api-prefix=/
# To proxy only part of the Kubernetes API and also some static files
# You can get pods info with 'curl localhost:8001/api/v1/pods'
oc proxy --www=/my/files --www-prefix=/static/ --api-prefix=/api/
# To proxy the entire Kubernetes API at a different root
# You can get pods info with 'curl localhost:8001/custom/api/v1/pods'
oc proxy --api-prefix=/custom/
# Run a proxy to the Kubernetes API server on port 8011, serving static content from ./local/www/
oc proxy --port=8011 --www=./local/www/
# Run a proxy to the Kubernetes API server on an arbitrary local port
# The chosen port for the server will be output to stdout
oc proxy --port=0
# Run a proxy to the Kubernetes API server, changing the API prefix to k8s-api
# This makes e.g. the pods API available at localhost:8001/k8s-api/v1/pods/
oc proxy --api-prefix=/k8s-api
Not me reading this and immediately wanting to --port=0 just to see the random port print to stdout. ππ₯
π SEE ALSO π
That's it. That's the list. One icon. π
π§ HISTORY π§
June 2016 β ported from the Kubernetes man-doc generator. So it's a vintage, and it still ate. π β¨
And that's the whole page, bestie! π This absolute legend of a doc is brought to you by Openshift β the Openshift CLI User Manuals β dated all the way back to June 2016, and titled, of course, OC(1). Go forth and proxy responsibly. π¦ππΈ
π¦ 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