OC(1)
π
OC β oc apply π¦
okay so bestie, this is the oc apply page from the OC(1) manual (yes, that OC β the OpenShift CLI one, June 2016 edition, we love a vintage moment) β¨
πΈ NAME πΈ
oc apply β apply a configuration to a resource by file name or stdin π«Ά
β¨ SYNOPSIS β¨
oc apply [OPTIONS]
π DESCRIPTION π
okay so picture this: you're applying a configuration to a resource β by file name or stdin, your choice, we're flexible π . The thing is, the resource name must be specified. Like, non-negotiable. But here's the slay part: this resource will get created if it doesn't exist yet π¦.
π real talk though β to useapply, you have to always create the resource initially with eitherapplyorcreate --save-config. Those are the two options, periodt.
JSON and YAML formats are accepted, both iconic, both welcome π.
β οΈ Alpha Disclaimer β οΈ β the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See <https://issues.k8s.io/34274>. Not me warning you twice about this, but like... I'm warning you.
π OPTIONS π
--all=falseβ select all resources in the namespace of the specified resource types. all of them. every last one π--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 togolangandjsonpathoutput formats π--cascade="background"β must be"background","orphan", or"foreground". Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background π¦--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 π--field-manager="kubectl-client-side-apply"β name of the manager used to track field ownership. it's giving accountability β¨-f,--filename=[]β the files that contain the configurations to apply π--force=falseβ if true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation π (like, it will ask you. be ready.)--force-conflicts=falseβ if true, server-side apply will force the changes against conflicts π₯--grace-period=-1β period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to1for immediate shutdown. Can only be set to0when--forceis true (force deletion) β³-k,--kustomize=""β process a kustomization directory. This flag can't be used together with-for-Rβ pick a lane bestie π«--openapi-patch=trueβ if true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types π§-o,--output=""β output format. One of: (json,yaml,kyaml,name,go-template,go-template-file,template,templatefile,jsonpath,jsonpath-as-json,jsonpath-file) π--overwrite=trueβ automatically resolve conflicts between the modified and live configuration by using values from the modified configuration π--prune=falseβ automatically delete resource objects, that do not appear in the configs and are created by eitherapplyorcreate --save-config. Should be used with either-lor--all. (reminder: still Alpha, see above π)--prune-allowlist=[]β overwrite the default allowlist with<group/version/kind>for--pruneπ-R,--recursive=falseβ process the directory used in-f,--filenamerecursively. Useful when you want to manage related manifests organized within the same directory πΈ-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 β--server-side=falseβ if true, apply runs in the server instead of the client π₯οΈ--show-managed-fields=falseβ if true, keep themanagedFieldswhen printing objects in JSON or YAML format π--subresource=""β if specified, apply will operate on the subresource of the requested object. Only allowed when using--server-sideβ οΈ--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β the length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object β--validate="ignore"β must be one of:strict(ortrue),warn,ignore(orfalse)."true"or"strict"will use a schema to validate the input and fail the request if invalid. It will perform server side validation ifServerSideFieldValidationis enabled on the api-server, but will fall back to less reliable client-side validation if not."warn"will warn about unknown or duplicate fields without blocking the request if server-side field validation is enabled on the API server, and behave as"ignore"otherwise."false"or"ignore"will not perform any schema validation, silently dropping any unknown or duplicate fields π--wait=falseβ if true, wait for resources to be gone before returning. This waits for finalizers π«Ά
π OPTIONS INHERITED FROM PARENT COMMANDS π
the whole family showed up, we love a supportive parent π
--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 π (like, actually insecure. be so fr.)--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 β
the moment you've all been waiting for, the examples, the main character energy π
# Apply the configuration in pod.json to a pod
oc apply -f ./pod.json
# Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
oc apply -k dir/
# Apply the JSON passed into stdin to a pod
cat pod.json | oc apply -f -
# Apply the configuration from all files that end with '.json'
oc apply -f '*.json'
# Note: --prune is still in Alpha
# Apply the configuration in manifest.yaml that matches label app=nginx and delete all other resources that are not in the file and match label app=nginx
oc apply --prune -f manifest.yaml -l app=nginx
# Apply the configuration in manifest.yaml and delete all the other config maps that are not in the file
oc apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/ConfigMap
π¦ SEE ALSO π¦
π HISTORY π
June 2016, Ported from the Kubernetes man-doc generator π§ββοΈ (a whole era, honestly)
π okay that's the whole page bestie, you ate that. now go apply something. π
and that's a wrap, mwah π β brought to you by Openshift, from the Openshift CLI User Manuals, page OC(1), dated June 2016 β¨πΈ
π¦ 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