OC(1)
πΈ OC(1) πΈ
okay bestie, so this is the oc debug manual page and honestly it's giving lifesaver energy π
the manual name is OC and this whole thing is literally about launching a pod so you can debug stuff. periodt.
β¨ SYNOPSIS β¨
oc debug [OPTIONS]
π DESCRIPTION π
Launch a command shell to debug a running application. slay.
okay so when you're debugging images and setup problems, it's highkey useful to get an exact copy of a running pod configuration and just troubleshoot with a shell. the way that a pod that's failing may not be started and not accessible to rsh or exec? π so the debug command makes it easy to create a carbon copy of that setup. iconic behavior.
the default mode is to start a shell inside of the first container of the referenced pod. the started pod will be a copy of your source pod, with labels stripped, the command changed to /bin/sh for Linux containers or cmd.exe for Windows containers, and readiness and liveness checks disabled. if you just want to run a command, add -- and a command to run. passing a command will not create a TTY or send STDIN by default. other flags are supported for altering the container or pod in common ways. no cap.
a common problem running containers is a security policy that prohibits you from running as a root user on the cluster. you can use this command to test running a pod as non-root (with --as-user) or to run a non-root pod as root (with --as-root). chef's kiss.
you may invoke other types of objects besides pods β any controller resource that creates a pod (like a deployment, build, or job), objects that can host pods (like nodes), or resources that can be used to create pods (such as image stream tags), or simply pass --image=IMAGE to start a simple shell session in an image with a shell program. the versatility is giving main character energy β¨
the debug pod is deleted when the remote command completes or the user interrupts the shell.
π OPTIONS π
--allow-missing-template-keys=trueβ if true, ignore any errors in templates when a field or map key is missing in the template. only applies to golang and jsonpath output formats.--as-root=falseβ if true, try to run the container as the root user.--as-user=-1β try to run the container as a specific user UID (note: admins may limit your ability to use this flag, so don't be sus about it).-c,--container=""β container name; defaults to first container.--dry-run="none"β must be"none","server", or"client". if client strategy, only print the object that would be sent, without sending it. if server strategy, submit server-side request without persisting the resource.-f,--filename=[]β filename, directory, or URL to files to read a template.--image=""β override the image used by the targeted container.--image-stream=""β specify an image stream (namespace/name:tag) containing a debug image to run.--keep-annotations=falseβ if true, keep the original pod annotations.--keep-init-containers=trueβ run the init containers for the pod. defaults to true.--keep-labels=falseβ if true, keep the original pod labels.--keep-liveness=falseβ if true, keep the original pod liveness probes.--keep-readiness=falseβ if true, keep the original pod readiness probes.--keep-startup=falseβ if true, keep the original startup probes.-k,--kustomize=""β process the kustomization directory. this flag can't be used together with-for-R.-I,--no-stdin=falseβ bypasses passing STDIN to the container, defaults to true if no command specified.-T,--no-tty=falseβ disable pseudo-terminal allocation.--node-name=""β set a specific node to run on - by default the pod will run on any valid node.--one-container=falseβ if true, run only the selected container, remove all others.-o,--output=""β output format. one of: (json,yaml,kyaml,name,go-template,go-template-file,template,templatefile,jsonpath,jsonpath-as-json,jsonpath-file).--preserve-pod=falseβ if true, the pod will not be deleted after the debug command exits.-q,--quiet=falseβ no informational messages will be printed.-R,--recursive=falseβ process the directory used in-f,--filenamerecursively. useful when you want to manage related manifests organized within the same directory.--show-labels=falseβ when printing, show all labels as the last column (default hide labels column).--show-managed-fields=falseβ if true, keep themanagedFieldswhen printing objects in JSON or YAML format.--template=""β template string or path to template file to use when-o=go-template,-o=go-template-file. the template format is golang templates [β¨http://golang.org/pkg/text/template/#pkg-overviewβ©].--to-namespace=""β override the namespace to create the pod into (instead of using--namespace).-t,--tty=falseβ force a pseudo-terminal to be allocated.
π¦ OPTIONS INHERITED FROM PARENT COMMANDS π¦
--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 (so like, be careful bestie π).--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 exportingKUBECTL_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 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"β 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.-s,--server=""β the address and port of the Kubernetes API server.--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.--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.
π EXAMPLE π
# Start a shell session into a pod using the OpenShift tools image
oc debug
# Debug a currently running deployment by creating a new pod
oc debug deploy/test
# Debug a node as an administrator
oc debug node/master-1
# Debug a Windows node
# Note: the chosen image must match the Windows Server version (2019, 2022) of the node
oc debug node/win-worker-1 --image=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
# Launch a shell in a pod using the provided image stream tag
oc debug istag/mysql:latest -n openshift
# Test running a job as a non-root user
oc debug job/test --as-user=1000000
# Debug a specific failing container by running the env command in the 'second' container
oc debug daemonset/test -c second -- /bin/env
# See the pod that would be created to debug
oc debug mypod-9xbc -o yaml
# Debug a resource but launch the debug pod in another namespace
# Note: Not all resources can be debugged using --to-namespace without modification. For example,
# volumes and service accounts are namespace-dependent. Add '-o yaml' to output the debug pod definition
# to disk. If necessary, edit the definition then run 'oc debug -f -' or run without --to-namespace
oc debug mypod-9xbc --to-namespace testns
π SEE ALSO π
β HISTORY β
June 2016, Ported from the Kubernetes man-doc generator.
okay and that's literally the whole thing bestie π«Ά this page comes from the Openshift CLI User Manuals, and it's dated June 2016 β yeah, vintage but still iconic. stay slay, debug responsibly, and don't forget to clean up your pods π β¨
π¦ 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