OC(1)

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

πŸ’… 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 use apply, you have to always create the resource initially with either apply or create --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 to golang and jsonpath output 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 to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion) ⏳
  • -k, --kustomize="" β€” process a kustomization directory. This flag can't be used together with -f or -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 either apply or create --save-config. Should be used with either -l or --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, --filename recursively. 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 the managedFields when 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 (or true), warn, ignore (or false). "true" or "strict" will use a schema to validate the input and fail the request if invalid. It will perform server side validation if ServerSideFieldValidation is 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 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 ⭐

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