OC(1)

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

πŸ’… OC(1) β€” okay bestie, let's talk oc replace ✨

So this is the manual page for oc from back in June 2016 (yes, she's an icon from 2016, we stan a vintage queen), and today's main character is the replace command. Buckle up, it's giving cluster glow-up energy πŸŽ€


🌸 NAME 🌸

oc replace β€” replace a resource by file name or stdin. That's it, that's the vibe πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

oc replace [OPTIONS]

✨ DESCRIPTION ✨

Replace a resource by file name or stdin. Simple as that, no cap.

JSON and YAML formats are accepted, so bring whichever one your heart desires 🫢

⚠️ Real talk though: if you're replacing an existing resource, the complete resource spec must be provided. Not a snippet, not a fragment β€” the whole thing, bestie. Partial specs are a no.

And if you're sitting there like "where do I even get the complete spec," don't stress β€” you can grab it with this:

$ oc get TYPE NAME -o yaml

Get the yaml, keep the yaml, replace with the yaml. Slay πŸ”₯


πŸ’… OPTIONS πŸ’…

  • --allow-missing-template-keys=true β€” if true, all those template errors about a missing field or map key just get ignored. Very chill. Only applies to golang and jsonpath output formats, so don't come for her about the others πŸ’
  • --cascade="background" β€” has to be "background", "orphan", or "foreground". This picks the deletion cascading strategy for the dependents (like, say, the Pods a ReplicationController made, iykyk). Defaults to background.
  • --dry-run="none" β€” must be "none", "server", or "client". Client strategy? She just prints the object that would have been sent, without actually sending it β€” window shopping πŸ’– Server strategy? Submits the server-side request without persisting the resource. Nice try, no commitment.
  • --field-manager="kubectl-replace" β€” the name of the manager used to track field ownership. That's her whole job, respect it πŸ‘‘
  • -f, --filename=[] β€” the files that contain the configurations to replace. The actual goods.
  • --force=false β€” if true, immediately remove resources from the API and bypass graceful deletion. ⚠️ Heads up: immediate deletion of some resources may result in inconsistency or data loss, and it requires confirmation. Yes it's dramatic, it's supposed to be.
  • --grace-period=-1 β€” the period of time in seconds the resource gets to terminate gracefully. Ignored if negative. Set it to 1 for immediate shutdown. Lowkey important: it can only be set to 0 when --force is true (force deletion). Rules are rules πŸ’…
  • -k, --kustomize="" β€” process a kustomization directory. This flag can't be used together with -f or -R, so pick a lane bestie 🚫
  • -o, --output="" β€” output format. One of: (json, yaml, kyaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file). A whole menu, order whatever πŸ“
  • --raw="" β€” the raw URI to PUT to the server. Uses the transport specified by the kubeconfig file.
  • -R, --recursive=false β€” process the directory used in -f, --filename recursively. Super useful when you want to manage related manifests organized within the same directory. Tidy queen behavior 🧚
  • --save-config=false β€” if true, the configuration of the current object gets saved in its annotation. Otherwise the annotation stays unchanged. This one's useful when you want to perform kubectl apply on this object in the future. Future-you says thank you 🫢
  • --show-managed-fields=false β€” if true, keep the managedFields when printing objects in JSON or YAML format.
  • --subresource="" β€” if specified, replace will operate on the subresource of the requested object. Getting specific, love that.
  • --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⟩ ].
  • --timeout=0 β€” how long to wait before giving up on a delete. Zero means determine a timeout from the size of the object. Girl's got a self-adjusting clock ⭐
  • --validate="ignore" β€” must be one of: strict (or true), warn, ignore (or false). "true" or "strict" uses a schema to validate the input and fails the request if it's invalid β€” it performs server side validation if ServerSideFieldValidation is enabled on the api-server, but falls back to less reliable client-side validation if not. "warn" warns about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behaves as "ignore" otherwise. "false" or "ignore" performs no schema validation at all, silently dropping any unknown or duplicate fields. Choose your fighter πŸ’€
  • --wait=false β€” if true, wait for resources to be gone before returning. This waits for finalizers. Patience is a virtue, apparently πŸ™ˆ

🌈 OPTIONS INHERITED FROM PARENT COMMANDS 🌈

These are the family hand-me-downs β€” still iconic, still yours πŸ’œ

  • --as="" β€” username to impersonate for the operation. Could be a regular user or a service account in a namespace. Main character energy, borrowed ✨
  • --as-group=[] β€” group to impersonate for the operation. This flag can be repeated to specify multiple groups. Stack 'em up πŸŽ€
  • --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. Multitasking queen.
  • --cache-dir="/homeless-shelter/.kube/cache" β€” default cache directory. Yes that's really the path, no we're not editing it 🫠
  • --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. Uncompressed and unbothered πŸ’…
  • --insecure-skip-tls-verify=false β€” if true, the server's certificate will not be checked for validity. ⚠️ Fr fr, this will make your HTTPS connections 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. Compatibility check, she's picky 😌
  • -n, --namespace="" β€” if present, the namespace scope for this CLI request. Always know which room you're in bestie πŸ¦‹
  • --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" β€” 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. Zero = no clock, no stress ⭐
  • -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. Strict queen, no notes πŸ”₯

πŸ“ EXAMPLE πŸ“

Okay here are the actual moves, copy her exactly, characters and all:

# Replace a pod using the data in pod.json
oc replace -f ./pod.json

# Replace a pod based on the JSON passed into stdin
cat pod.json | oc replace -f -

# Update a single-container pod's image version (tag) to v4
oc get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | oc replace -f -

# Force replace, delete and then re-create the resource
oc replace --force -f ./pod.json

That third one? Piping get into sed into replace? Yeah that's the iconic one, iykyk πŸ˜­πŸ’–


🧚 SEE ALSO 🧚

oc(1),

Go say hi to the parent command, she misses you 🫢


πŸ‘‘ HISTORY πŸ‘‘

June 2016 β€” Ported from the Kubernetes man-doc generator. A whole origin story, honestly.


πŸ’€ One last vibe check bestie: --force can nuke stuff immediately with possible inconsistency or data loss, --grace-period=0 only works with --force, --insecure-skip-tls-verify literally makes your HTTPS insecure, and -k refuses to share the sandbox with -f or -R. Respect the boundaries and you'll be fine ✨

Alright, that's the whole page! Big kiss from Openshift CLI User Manuals, OC(1), dated right back to that June 2016 moment β€” she was ported from the Kubernetes man-doc generator and she's been serving ever since. Go replace something responsibly, bestie πŸŽ€πŸ’œ

πŸ“¦ where this page comes from