OC(1)

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

🌸 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 -f or -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, --filename recursively. 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 the managedFields when 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 exporting 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 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 πŸ’œ

oc(1)


⭐ 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