1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl  apply  -  Apply  a configuration to a resource by file name or
10       stdin
11
12
13

SYNOPSIS

15       kubectl apply [OPTIONS]
16
17
18

DESCRIPTION

20       Apply a configuration to a resource by file name or stdin. The resource
21       name must be specified. This resource will be created if it doesn't ex‐
22       ist yet. To use 'apply', always create the resource initially with  ei‐
23       ther 'apply' or 'create --save-config'.
24
25
26       JSON and YAML formats are accepted.
27
28
29       Alpha Disclaimer: the --prune functionality is not yet complete. Do not
30       use unless you are aware of what the current state is. See  https://is
31       sues.k8s.io/34274.
32
33
34

OPTIONS

36       --all=false      Select all resources in the namespace of the specified
37       resource types.
38
39
40       --allow-missing-template-keys=true      If true, ignore any  errors  in
41       templates  when a field or map key is missing in the template. Only ap‐
42       plies to golang and jsonpath output formats.
43
44
45       --cascade="background"      Must be "background", "orphan",  or  "fore‐
46       ground".  Selects  the  deletion  cascading strategy for the dependents
47       (e.g. Pods created by a ReplicationController). Defaults to background.
48
49
50       --dry-run="none"      Must be "none", "server", or "client". If  client
51       strategy, only print the object that would be sent, without sending it.
52       If server strategy, submit server-side request without  persisting  the
53       resource.
54
55
56       --field-manager="kubectl-client-side-apply"       Name  of  the manager
57       used to track field ownership.
58
59
60       -f, --filename=[]      that contains the configuration to apply
61
62
63       --force=false      If true, immediately remove resources from  API  and
64       bypass  graceful  deletion.  Note  that  immediate deletion of some re‐
65       sources may result in inconsistency or data loss and requires confirma‐
66       tion.
67
68
69       --force-conflicts=false       If true, server-side apply will force the
70       changes against conflicts.
71
72
73       --grace-period=-1      Period of time in seconds given to the  resource
74       to  terminate  gracefully.  Ignored if negative. Set to 1 for immediate
75       shutdown. Can only be set to 0 when --force is true (force deletion).
76
77
78       -k, --kustomize=""      Process a kustomization  directory.  This  flag
79       can't be used together with -f or -R.
80
81
82       --openapi-patch=true       If  true, use openapi to calculate diff when
83       the openapi presents and the resource can be found in the openapi spec.
84       Otherwise, fall back to use baked-in types.
85
86
87       -o,  --output=""      Output format. One of: (json, yaml, name, go-tem‐
88       plate, go-template-file, template, templatefile, jsonpath, jsonpath-as-
89       json, jsonpath-file).
90
91
92       --overwrite=true      Automatically resolve conflicts between the modi‐
93       fied and live configuration by using values from the modified  configu‐
94       ration
95
96
97       --prune=false       Automatically  delete resource objects, that do not
98       appear in the configs and are created by either apply or create --save-
99       config. Should be used with either -l or --all.
100
101
102       --prune-whitelist=[]       Overwrite  the  default  whitelist with  for
103       --prune
104
105
106       --record=false      Record current kubectl command in the resource  an‐
107       notation.  If  set to false, do not record the command. If set to true,
108       record the command. If not set, default to updating the existing  anno‐
109       tation value only if one already exists.
110
111
112       -R, --recursive=false      Process the directory used in -f, --filename
113       recursively. Useful when you want to manage related manifests organized
114       within the same directory.
115
116
117       -l,  --selector=""       Selector  (label query) to filter on, supports
118       '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching objects
119       must satisfy all of the specified label constraints.
120
121
122       --server-side=false       If  true, apply runs in the server instead of
123       the client.
124
125
126       --show-managed-fields=false      If true, keep the  managedFields  when
127       printing objects in JSON or YAML format.
128
129
130       --template=""      Template string or path to template file to use when
131       -o=go-template, -o=go-template-file. The template format is golang tem‐
132       plates [http://golang.org/pkg/text/template/#pkg-overview].
133
134
135       --timeout=0s       The  length  of  time  to wait before giving up on a
136       delete, zero means determine a timeout from the size of the object
137
138
139       --validate="strict"      Must be one of: strict (or true), warn, ignore
140       (or false).            "true" or "strict" will use a schema to validate
141       the input and fail the request if invalid. It will perform server  side
142       validation  if  ServerSideFieldValidation is enabled on the api-server,
143       but will fall back to less  reliable  client-side  validation  if  not.
144                 "warn"  will  warn  about unknown or duplicate fields without
145       blocking the request if server-side field validation is enabled on  the
146       API  server,  and  behave  as "ignore" otherwise.            "false" or
147       "ignore" will not perform any schema validation, silently dropping  any
148       unknown or duplicate fields.
149
150
151       --wait=false      If true, wait for resources to be gone before return‐
152       ing. This waits for finalizers.
153
154
155

OPTIONS INHERITED FROM PARENT COMMANDS

157       --as=""      Username to impersonate for the operation. User could be a
158       regular user or a service account in a namespace.
159
160
161       --as-group=[]       Group  to  impersonate for the operation, this flag
162       can be repeated to specify multiple groups.
163
164
165       --as-uid=""      UID to impersonate for the operation.
166
167
168       --azure-container-registry-config=""      Path to the  file  containing
169       Azure container registry configuration information.
170
171
172       --cache-dir="/builddir/.kube/cache"      Default cache directory
173
174
175       --certificate-authority=""      Path to a cert file for the certificate
176       authority
177
178
179       --client-certificate=""      Path to a client certificate file for TLS
180
181
182       --client-key=""      Path to a client key file for TLS
183
184
185       --cluster=""      The name of the kubeconfig cluster to use
186
187
188       --context=""      The name of the kubeconfig context to use
189
190
191       --insecure-skip-tls-verify=false      If true, the server's certificate
192       will not be checked for validity. This will make your HTTPS connections
193       insecure
194
195
196       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
197       quests.
198
199
200       --match-server-version=false        Require  server  version  to  match
201       client version
202
203
204       -n, --namespace=""      If present, the namespace scope  for  this  CLI
205       request
206
207
208       --password=""      Password for basic authentication to the API server
209
210
211       --profile="none"         Name   of   profile   to   capture.   One   of
212       (none|cpu|heap|goroutine|threadcreate|block|mutex)
213
214
215       --profile-output="profile.pprof"      Name of the  file  to  write  the
216       profile to
217
218
219       --request-timeout="0"       The length of time to wait before giving up
220       on a single server request. Non-zero values  should  contain  a  corre‐
221       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
222       out requests.
223
224
225       -s, --server=""      The address and port of the Kubernetes API server
226
227
228       --tls-server-name=""      Server name to  use  for  server  certificate
229       validation.  If  it  is  not provided, the hostname used to contact the
230       server is used
231
232
233       --token=""      Bearer token for authentication to the API server
234
235
236       --user=""      The name of the kubeconfig user to use
237
238
239       --username=""      Username for basic authentication to the API server
240
241
242       --version=false      Print version information and quit
243
244
245       --warnings-as-errors=false      Treat warnings received from the server
246       as errors and exit with a non-zero exit code
247
248
249

EXAMPLE

251                # Apply the configuration in pod.json to a pod
252                kubectl apply -f ./pod.json
253
254                # Apply resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
255                kubectl apply -k dir/
256
257                # Apply the JSON passed into stdin to a pod
258                cat pod.json | kubectl apply -f -
259
260                # Apply the configuration from all files that end with '.json' - i.e. expand wildcard characters in file names
261                kubectl apply -f '*.json'
262
263                # Note: --prune is still in Alpha
264                # 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
265                kubectl apply --prune -f manifest.yaml -l app=nginx
266
267                # Apply the configuration in manifest.yaml and delete all the other config maps that are not in the file
268                kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap
269
270
271
272

SEE ALSO

274       kubectl(1), kubectl-apply-edit-last-applied(1), kubectl-apply-set-last-
275       applied(1), kubectl-apply-view-last-applied(1),
276
277
278

HISTORY

280       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
281       com)  based  on the kubernetes source material, but hopefully they have
282       been automatically generated since!
283
284
285
286Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum