1KUBERNETES(1)(kubernetes) KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7
9 kubectl set env - Update environment variables on a pod template
10
11
12
14 kubectl set env [OPTIONS]
15
16
17
19 Update environment variables on a pod template.
20
21
22 List environment variable definitions in one or more pods, pod tem‐
23 plates. Add, update, or remove container environment variable defini‐
24 tions in one or more pod templates (within replication controllers or
25 deployment configurations). View or modify the environment variable
26 definitions on all containers in the specified pods or pod templates,
27 or just those that match a wildcard.
28
29
30 If "--env -" is passed, environment variables can be read from STDIN
31 using the standard env syntax.
32
33
34 Possible resources include (case insensitive):
35
36
37 pod (po), replicationcontroller (rc), deployment (deploy), daemonset
38 (ds), job, replicaset (rs)
39
40
41
43 --all=false If true, select all resources in the namespace of the
44 specified resource types
45
46
47 --allow-missing-template-keys=true If true, ignore any errors in
48 templates when a field or map key is missing in the template. Only ap‐
49 plies to golang and jsonpath output formats.
50
51
52 -c, --containers="*" The names of containers in the selected pod
53 templates to change - may use wildcards
54
55
56 --dry-run="none" Must be "none", "server", or "client". If client
57 strategy, only print the object that would be sent, without sending it.
58 If server strategy, submit server-side request without persisting the
59 resource.
60
61
62 -e, --env=[] Specify a key-value pair for an environment variable
63 to set into each container.
64
65
66 --field-manager="kubectl-set" Name of the manager used to track
67 field ownership.
68
69
70 -f, --filename=[] Filename, directory, or URL to files the re‐
71 source to update the env
72
73
74 --from="" The name of a resource from which to inject environment
75 variables
76
77
78 --keys=[] Comma-separated list of keys to import from specified
79 resource
80
81
82 -k, --kustomize="" Process the kustomization directory. This flag
83 can't be used together with -f or -R.
84
85
86 --list=false If true, display the environment and any changes in
87 the standard format. this flag will removed when we have kubectl view
88 env.
89
90
91 --local=false If true, set env will NOT contact api-server but run
92 locally.
93
94
95 -o, --output="" Output format. One of: json|yaml|name|go-tem‐
96 plate|go-template-file|template|templatefile|jsonpath|json‐
97 path-as-json|jsonpath-file.
98
99
100 --overwrite=true If true, allow environment to be overwritten,
101 otherwise reject updates that overwrite existing environment.
102
103
104 --prefix="" Prefix to append to variable names
105
106
107 -R, --recursive=false Process the directory used in -f, --filename
108 recursively. Useful when you want to manage related manifests organized
109 within the same directory.
110
111
112 --resolve=false If true, show secret or configmap references when
113 listing variables
114
115
116 -l, --selector="" Selector (label query) to filter on
117
118
119 --show-managed-fields=false If true, keep the managedFields when
120 printing objects in JSON or YAML format.
121
122
123 --template="" Template string or path to template file to use when
124 -o=go-template, -o=go-template-file. The template format is golang tem‐
125 plates [http://golang.org/pkg/text/template/#pkg-overview].
126
127
128
130 --add-dir-header=false If true, adds the file directory to the
131 header of the log messages
132
133
134 --alsologtostderr=false log to standard error as well as files
135
136
137 --application-metrics-count-limit=100 Max number of application
138 metrics to store (per container)
139
140
141 --as="" Username to impersonate for the operation
142
143
144 --as-group=[] Group to impersonate for the operation, this flag
145 can be repeated to specify multiple groups.
146
147
148 --azure-container-registry-config="" Path to the file containing
149 Azure container registry configuration information.
150
151
152 --boot-id-file="/proc/sys/kernel/random/boot_id" Comma-separated
153 list of files to check for boot-id. Use the first one that exists.
154
155
156 --cache-dir="/builddir/.kube/cache" Default cache directory
157
158
159 --certificate-authority="" Path to a cert file for the certificate
160 authority
161
162
163 --client-certificate="" Path to a client certificate file for TLS
164
165
166 --client-key="" Path to a client key file for TLS
167
168
169 --cloud-provider-gce-l7lb-src-cidrs=130.211.0.0/22,35.191.0.0/16
170 CIDRs opened in GCE firewall for L7 LB traffic proxy health
171 checks
172
173
174 --cloud-provider-gce-lb-src-cidrs=130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16
175 CIDRs opened in GCE firewall for L4 LB traffic proxy health
176 checks
177
178
179 --cluster="" The name of the kubeconfig cluster to use
180
181
182 --container-hints="/etc/cadvisor/container_hints.json" location of
183 the container hints file
184
185
186 --containerd="/run/containerd/containerd.sock" containerd endpoint
187
188
189 --containerd-namespace="k8s.io" containerd namespace
190
191
192 --context="" The name of the kubeconfig context to use
193
194
195 --default-not-ready-toleration-seconds=300 Indicates the tolera‐
196 tionSeconds of the toleration for notReady:NoExecute that is added by
197 default to every pod that does not already have such a toleration.
198
199
200 --default-unreachable-toleration-seconds=300 Indicates the tolera‐
201 tionSeconds of the toleration for unreachable:NoExecute that is added
202 by default to every pod that does not already have such a toleration.
203
204
205 --disable-root-cgroup-stats=false Disable collecting root Cgroup
206 stats
207
208
209 --docker="unix:///var/run/docker.sock" docker endpoint
210
211
212 --docker-env-metadata-whitelist="" a comma-separated list of envi‐
213 ronment variable keys matched with specified prefix that needs to be
214 collected for docker containers
215
216
217 --docker-only=false Only report docker containers in addition to
218 root stats
219
220
221 --docker-root="/var/lib/docker" DEPRECATED: docker root is read
222 from docker info (this is a fallback, default: /var/lib/docker)
223
224
225 --docker-tls=false use TLS to connect to docker
226
227
228 --docker-tls-ca="ca.pem" path to trusted CA
229
230
231 --docker-tls-cert="cert.pem" path to client certificate
232
233
234 --docker-tls-key="key.pem" path to private key
235
236
237 --enable-load-reader=false Whether to enable cpu load reader
238
239
240 --event-storage-age-limit="default=0" Max length of time for which
241 to store events (per type). Value is a comma separated list of key val‐
242 ues, where the keys are event types (e.g.: creation, oom) or "default"
243 and the value is a duration. Default is applied to all non-specified
244 event types
245
246
247 --event-storage-event-limit="default=0" Max number of events to
248 store (per type). Value is a comma separated list of key values, where
249 the keys are event types (e.g.: creation, oom) or "default" and the
250 value is an integer. Default is applied to all non-specified event
251 types
252
253
254 --global-housekeeping-interval=1m0s Interval between global house‐
255 keepings
256
257
258 --housekeeping-interval=10s Interval between container housekeep‐
259 ings
260
261
262 --insecure-skip-tls-verify=false If true, the server's certificate
263 will not be checked for validity. This will make your HTTPS connections
264 insecure
265
266
267 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
268 quests.
269
270
271 --log-backtrace-at=:0 when logging hits line file:N, emit a stack
272 trace
273
274
275 --log-cadvisor-usage=false Whether to log the usage of the cAdvi‐
276 sor container
277
278
279 --log-dir="" If non-empty, write log files in this directory
280
281
282 --log-file="" If non-empty, use this log file
283
284
285 --log-file-max-size=1800 Defines the maximum size a log file can
286 grow to. Unit is megabytes. If the value is 0, the maximum file size is
287 unlimited.
288
289
290 --log-flush-frequency=5s Maximum number of seconds between log
291 flushes
292
293
294 --logtostderr=true log to standard error instead of files
295
296
297 --machine-id-file="/etc/machine-id,/var/lib/dbus/machine-id"
298 Comma-separated list of files to check for machine-id. Use the
299 first one that exists.
300
301
302 --match-server-version=false Require server version to match
303 client version
304
305
306 -n, --namespace="" If present, the namespace scope for this CLI
307 request
308
309
310 --one-output=false If true, only write logs to their native sever‐
311 ity level (vs also writing to each lower severity level)
312
313
314 --password="" Password for basic authentication to the API server
315
316
317 --profile="none" Name of profile to capture. One of
318 (none|cpu|heap|goroutine|threadcreate|block|mutex)
319
320
321 --profile-output="profile.pprof" Name of the file to write the
322 profile to
323
324
325 --referenced-reset-interval=0 Reset interval for referenced bytes
326 (container_referenced_bytes metric), number of measurement cycles after
327 which referenced bytes are cleared, if set to 0 referenced bytes are
328 never cleared (default: 0)
329
330
331 --request-timeout="0" The length of time to wait before giving up
332 on a single server request. Non-zero values should contain a corre‐
333 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
334 out requests.
335
336
337 -s, --server="" The address and port of the Kubernetes API server
338
339
340 --skip-headers=false If true, avoid header prefixes in the log
341 messages
342
343
344 --skip-log-headers=false If true, avoid headers when opening log
345 files
346
347
348 --stderrthreshold=2 logs at or above this threshold go to stderr
349
350
351 --storage-driver-buffer-duration=1m0s Writes in the storage driver
352 will be buffered for this duration, and committed to the non memory
353 backends as a single transaction
354
355
356 --storage-driver-db="cadvisor" database name
357
358
359 --storage-driver-host="localhost:8086" database host:port
360
361
362 --storage-driver-password="root" database password
363
364
365 --storage-driver-secure=false use secure connection with database
366
367
368 --storage-driver-table="stats" table name
369
370
371 --storage-driver-user="root" database username
372
373
374 --tls-server-name="" Server name to use for server certificate
375 validation. If it is not provided, the hostname used to contact the
376 server is used
377
378
379 --token="" Bearer token for authentication to the API server
380
381
382 --update-machine-info-interval=5m0s Interval between machine info
383 updates.
384
385
386 --user="" The name of the kubeconfig user to use
387
388
389 --username="" Username for basic authentication to the API server
390
391
392 -v, --v=0 number for the log level verbosity
393
394
395 --version=false Print version information and quit
396
397
398 --vmodule= comma-separated list of pattern=N settings for
399 file-filtered logging
400
401
402 --warnings-as-errors=false Treat warnings received from the server
403 as errors and exit with a non-zero exit code
404
405
406
408 # Update deployment 'registry' with a new environment variable
409 kubectl set env deployment/registry STORAGE_DIR=/local
410
411 # List the environment variables defined on a deployments 'sample-build'
412 kubectl set env deployment/sample-build --list
413
414 # List the environment variables defined on all pods
415 kubectl set env pods --all --list
416
417 # Output modified deployment in YAML, and does not alter the object on the server
418 kubectl set env deployment/sample-build STORAGE_DIR=/data -o yaml
419
420 # Update all containers in all replication controllers in the project to have ENV=prod
421 kubectl set env rc --all ENV=prod
422
423 # Import environment from a secret
424 kubectl set env --from=secret/mysecret deployment/myapp
425
426 # Import environment from a config map with a prefix
427 kubectl set env --from=configmap/myconfigmap --prefix=MYSQL_ deployment/myapp
428
429 # Import specific keys from a config map
430 kubectl set env --keys=my-example-key --from=configmap/myconfigmap deployment/myapp
431
432 # Remove the environment variable ENV from container 'c1' in all deployment configs
433 kubectl set env deployments --all --containers="c1" ENV-
434
435 # Remove the environment variable ENV from a deployment definition on disk and
436 # update the deployment config on the server
437 kubectl set env -f deploy.json ENV-
438
439 # Set some of the local shell environment into a deployment config on the server
440 env | grep RAILS_ | kubectl set env -e - deployment/registry
441
442
443
444
446 kubectl-set(1),
447
448
449
451 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
452 com) based on the kubernetes source material, but hopefully they have
453 been automatically generated since!
454
455
456
457Manuals User KUBERNETES(1)(kubernetes)