OC(1)
π
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β iftrue, all those template errors about a missing field or map key just get ignored. Very chill. Only applies togolangandjsonpathoutput 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 tobackground.--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β iftrue, 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 to1for immediate shutdown. Lowkey important: it can only be set to0when--forceis true (force deletion). Rules are rules π-k,--kustomize=""β process a kustomization directory. This flag can't be used together with-for-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,--filenamerecursively. Super useful when you want to manage related manifests organized within the same directory. Tidy queen behavior π§--save-config=falseβ iftrue, the configuration of the current object gets saved in its annotation. Otherwise the annotation stays unchanged. This one's useful when you want to performkubectl applyon this object in the future. Future-you says thank you π«Ά--show-managed-fields=falseβ iftrue, keep themanagedFieldswhen printing objects in JSON or YAML format.--subresource=""β if specified,replacewill 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(ortrue),warn,ignore(orfalse)."true"or"strict"uses a schema to validate the input and fails the request if it's invalid β it performs server side validation ifServerSideFieldValidationis 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β iftrue, 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β iftrue, opt-out of response compression for all requests to the server. Uncompressed and unbothered π--insecure-skip-tls-verify=falseβ iftrue, 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 thekubercfile to use for preferences. This can be disabled by exporting theKUBECTL_KUBERC=falsefeature gate or turning off the featureKUBERC=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 π§
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:--forcecan nuke stuff immediately with possible inconsistency or data loss,--grace-period=0only works with--force,--insecure-skip-tls-verifyliterally makes your HTTPS insecure, and-krefuses to share the sandbox with-for-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
- 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