OC(1)

πŸ“¦
version 4.22.0 Β· 2 versions
, in nixpkgs unstable

πŸ’… 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 β€” if true, it enables automatic path appending of the kube context server path to each request.
  • --disable-filter=false β€” if true, 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 β€” keepalive specifies the keep-alive period for an active network connection. Set it to 0 to disable keepalive.
  • -p, --port=8001 β€” the port to run the proxy on. Set it to 0 and 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 β€” if true, opt out of response compression for all requests to the server.
  • --insecure-skip-tls-verify=false β€” if true, 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 the KUBECTL_KUBERC=false feature gate or turning off the feature KUBERC=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