kubectl apply [page]deterministic
Apply a configuration to a resource by file name or stdin
##
Apply a configuration to a resource by file name or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.
JSON and YAML formats are accepted.
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.
``` kubectl apply (-f FILENAME | -k DIRECTORY) ```
##
``` # Apply the configuration in pod.json to a pod kubectl apply -f ./pod.json # Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml kubectl apply -k dir/ # Apply the JSON passed into stdin to a pod cat pod.json | kubectl apply -f - # Apply the configuration from all files that end with '.json' kubectl 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 kubectl 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 kubectl apply --prune -f manifest.yaml --all --prune-allowlist=core/v1/ConfigMap ```
##
<table style="width: 100%; table-layout: fixed;"> <colgroup> <col span="1" style="width: 10px;" /> <col span="1" /> </colgroup> <tbody>
<tr> <td colspan="2">--all</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>Select all resources in the namespace of the specified resource types.</p></td> </tr>
<tr> <td colspan="2">--allow-missing-template-keys Default: true</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>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.</p></td> </tr>
<tr> <td colspan="2">--cascade string[="background"] Default: "background"</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>Must be "background", "orphan", or "foreground". Selects the deletion cascading strategy for the dependents (e.g. Pods created by a ReplicationController). Defaults to background.</p></td> </tr>
<tr> <td colspan="2">--dry-run string[="unchanged"] Default: "none"</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>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.</p></td> </tr>
<tr> <td colspan="2">--field-manager string Default: "kubectl-client-side-apply"</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>Name of the manager used to track field ownership.</p></td> </tr>
<tr> <td colspan="2">-f, --filename strings</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>The files that contain the configurations to apply.</p></td> </tr>
<tr> <td colspan="2">--force</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>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.</p></td> </tr>
<tr> <td colspan="2">--force-conflicts</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-word;"><p>If true, server-side apply will force the changes against conflicts.</p></td> </tr>
<tr> <td colspan="2">--grace-period int Default: -1</td> </tr> <tr> <td></td><td style="line-height: 130%; word-wrap: break-w …(trimmed)