OC(1)

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

✨ OC(1) ✨

the iconic oc get manpage, bestie πŸ’… β€” like, this is the OpenShift CLI user manual, June 2016 energy, ported from the Kubernetes man-doc generator, and we're about to make it make sense, no cap 🫢


✨ NAME ✨

oc get β€” display one or many resources πŸ’–


✨ SYNOPSIS ✨

oc get [OPTIONS]

✨ DESCRIPTION ✨

okay so bestie, oc get is literally THE command for displaying one or many resources. it prints a table of the most important info about the resources you ask for, and it's giving main character energy ✨

you can filter the list with a label selector and the --selector flag, and if the resource type you want is namespaced, you'll only see results in the current namespace unless you specify a namespace. iykyk 🌸

and here's the iconic part: if you set the output to 'template' and pass a Go template as the value of the --template flag, you can filter the attributes of the fetched resources. obsessed πŸ’œ

πŸ¦‹ pro tip from the manpage itself: use oc api-resources for a complete list of supported resources πŸ‘‘

✨ OPTIONS ✨

  • -A, --all-namespaces=false β€” if present, list the requested object(s) across all namespaces. namespace in current context is ignored even if specified with --namespace. slay across the whole cluster 🌈
  • --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. no cap, it's forgiving like that 🫢
  • --chunk-size=500 β€” return large lists in chunks rather than all at once. pass 0 to disable. big lists? handled πŸ’…
  • --field-selector="" β€” selector (field query) to filter on, supports '=', '==', and '!='. (e.g. --field-selector key1=value1,key2=value2). the server only supports a limited number of field queries per type. lowkey picky but valid πŸ’€
  • -f, --filename=[] β€” filename, directory, or URL to files identifying the resource to get from a server. point it at stuff and it fetches πŸŽ€
  • --ignore-not-found=false β€” if set to true, suppresses NotFound error for specific objects that do not exist. using this flag with commands that query for collections of resources has no effect when no resources are found. ghosting missing objects fr fr πŸ™ˆ
  • -k, --kustomize="" β€” process the kustomization directory. this flag can't be used together with -f or -R. not me making them mutually exclusive πŸ’…
  • -L, --label-columns=[] β€” accepts a comma separated list of labels that are going to be presented as columns. names are case-sensitive. you can also use multiple flag options like -L label1 -L label2... cute and flexible 🌸
  • --no-headers=false β€” when using the default or custom-column output format, don't print headers (default print headers). minimal vibes only ✨
  • -o, --output="" β€” output format. one of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file, custom-columns, custom-columns-file, wide). see custom columns [⟨https://kubernetes.io/docs/reference/kubectl/#custom-columns⟩], golang template [⟨http://golang.org/pkg/text/template/#pkg-overview⟩] and jsonpath template [⟨https://kubernetes.io/docs/reference/kubectl/jsonpath/⟩]. so many formats, all iconic πŸ‘‘
  • --output-watch-events=false β€” output watch event objects when --watch or --watch-only is used. existing objects are output as initial ADDED events. watch party but make it structured πŸŽ‰
  • --raw="" β€” raw URI to request from the server. uses the transport specified by the kubeconfig file. direct line to the server, no filter πŸ”₯
  • -R, --recursive=false β€” process the directory used in -f, --filename recursively. useful when you want to manage related manifests organized within the same directory. go deep bestie πŸ¦‹
  • -l, --selector="" β€” selector (label query) to filter on, supports '=', '==', '!=', 'in', 'notin'. (e.g. -l key1=value1,key2=value2,key3 in (value3)). matching objects must satisfy all of the specified label constraints. all conditions must be met, periodt πŸ’…
  • --server-print=true β€” if true, have the server return the appropriate table output. supports extension APIs and CRDs. let the server do the pretty printing ✨
  • --show-kind=false β€” if present, list the resource type for the requested object(s). kind of a big deal πŸŽ€
  • --show-labels=false β€” when printing, show all labels as the last column (default hide labels column). labels in the back, where they belong 🌸
  • --show-managed-fields=false β€” if true, keep the managedFields when printing objects in JSON or YAML format. for the data girlies πŸ’œ
  • --sort-by="" β€” if non-empty, sort list types using this field specification. the field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). the field in the API resource specified by this JSONPath expression must be an integer or a string. sort it out, literally 🌈
  • --subresource="" β€” if specified, gets the subresource of the requested object. sub-sub-sub-obsessed πŸ”₯
  • --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⟩]. template girlies rise 🫢
  • -w, --watch=false β€” after listing/getting the requested object, watch for changes. don't just look, keep watching πŸ‘€
  • --watch-only=false β€” watch for changes to the requested object(s), without listing/getting first. straight to the drama, no recap πŸ’€

✨ 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. be someone else for a sec 🎭
  • --as-group=[] β€” group to impersonate for the operation, this flag can be repeated to specify multiple groups. group chat energy πŸ‘―β€β™€οΈ
  • --as-uid="" β€” UID to impersonate for the operation. the specific ID, not the name ✨
  • --as-user-extra=[] β€” user extras to impersonate for the operation, this flag can be repeated to specify multiple values for the same key. extra extra πŸ“
  • --cache-dir="/homeless-shelter/.kube/cache" β€” default cache directory. yes, that's the literal path bestie, don't @ me πŸ’€
  • --certificate-authority="" β€” path to a cert file for the certificate authority. trust issues, but make them official πŸŽ€
  • --client-certificate="" β€” path to a client certificate file for TLS. flex that cert 🌸
  • --client-key="" β€” path to a client key file for TLS. the key to the castle πŸ”‘
  • --cluster="" β€” the name of the kubeconfig cluster to use. pick your cluster like you pick your playlist 🌈
  • --context="" β€” the name of the kubeconfig context to use. context is everything, lowkey ✨
  • --disable-compression=false β€” if true, opt-out of response compression for all requests to the server. uncompressed and unbothered πŸ’…
  • --insecure-skip-tls-verify=false β€” if true, the server's certificate will not be checked for validity. this will make your HTTPS connections insecure ⚠️ bestie, this is the dangerous one, be careful fr fr
  • --kubeconfig="" β€” path to the kubeconfig file to use for CLI requests. your config, your rules 🫢
  • --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. preferences, but make it optional 🌸
  • --match-server-version=false β€” require server version to match client version. version check, iconic behavior πŸ‘‘
  • -n, --namespace="" β€” if present, the namespace scope for this CLI request. pick a namespace, any namespace πŸŽ€
  • --profile="none" β€” name of profile to capture. one of (none|cpu|heap|goroutine|threadcreate|block|mutex). for the performance girlies πŸ”₯
  • --profile-output="profile.pprof" β€” name of the file to write the profile to. where the profile goes πŸ’Ύ
  • --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. wait forever or don't wait at all, no in-between πŸ’€
  • -s, --server="" β€” the address and port of the Kubernetes API server. point me to the server bestie 🌐
  • --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. name it or the default gets it 🌈
  • --token="" β€” bearer token for authentication to the API server. your golden ticket 🎫
  • --user="" β€” the name of the kubeconfig user to use. who are you today? πŸ’…
  • --warnings-as-errors=false β€” treat warnings received from the server as errors and exit with a non-zero exit code. warnings? not on my watch, literally 😀

✨ EXAMPLE ✨

bestie, the examples are literally iconic, steal these for your next project πŸ’–

# List all pods in ps output format
oc get pods

# List all pods in ps output format with more information (such as node name)
oc get pods -o wide

# List a single replication controller with specified NAME in ps output format
oc get replicationcontroller web

# List deployments in JSON output format, in the "v1" version of the "apps" API group
oc get deployments.v1.apps -o json

# List a single pod in JSON output format
oc get -o json pod web-pod-13je7

# List a pod identified by type and name specified in "pod.yaml" in JSON output format
oc get -f pod.yaml -o json

# List resources from a directory with kustomization.yaml - e.g. dir/kustomization.yaml
oc get -k dir/

# Return only the phase value of the specified pod
oc get -o template pod/web-pod-13je7 --template={{.status.phase}}

# List resource information in custom columns
oc get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image

# List all replication controllers and services together in ps output format
oc get rc,services

# List one or more resources by their type and names
oc get rc/web service/frontend pods/web-pod-13je7

# List the 'status' subresource for a single pod
oc get pod web-pod-13je7 --subresource status

# List all deployments in namespace 'backend'
oc get deployments.apps --namespace backend

# List all pods existing in all namespaces
oc get pods --all-namespaces

✨ SEE ALSO ✨

oc(1) β€” the parent command, the blueprint, the moment πŸ’…


✨ HISTORY ✨

June 2016 β€” ported from the Kubernetes man-doc generator. a classic, a legend, an era 🫢


ty for reading bestie, stan oc get, and remember: this iconic piece of documentation is brought to you by Openshift β€” the Openshift CLI User Manuals β€” dated June 2016. slay, you're welcome, periodt πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from