KUBERNETES(1)(kubernetes)

πŸ’– KUBERNETES(1) β€” the kubernetes manual, section 1 πŸ’–

okay bestie, sit DOWN, because this is kubectl set env and it's literally the glow-up your pod templates have been waiting for. no cap. 🫢


✨ NAME ✨

kubectl set env β€” Update environment variables on a pod template

🌸 SYNOPSIS 🌸

kubectl set env [OPTIONS]

πŸ¦‹ DESCRIPTION πŸ¦‹

Update environment variables on a pod template. that's the whole vibe. πŸ’…

You can list environment variable definitions in one or more pods or pod templates. You can add, update, or remove container environment variable definitions in one or more pod templates β€” and yes, that includes the ones chillin' inside replication controllers or deployment configurations. And you can view or modify the environment variable definitions on all the containers in the pods or pod templates you picked, or just the ones that match a wildcard. picky? valid. 😌

If "--env -" is passed, environment variables can be read from STDIN using the standard env syntax. yes queen, pipe it in. πŸ“

Possible resources include (case insensitive):

pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)

✨ OPTIONS ✨

  • --all=false β€” If true, select all resources in the namespace of the specified resource types. all of them. every single 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. forgiving energy fr fr.
  • -c, --containers="*" β€” The names of containers in the selected pod templates to change β€” may use wildcards. the * said "all of y'all". ✨
  • --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. manifesting without committing, iykyk. πŸ™ˆ
  • -e, --env=[] β€” Specify a key-value pair for an environment variable to set into each container.
  • --field-manager="kubectl-set" β€” Name of the manager used to track field ownership. it's giving "who touched this last". πŸŽ€
  • -f, --filename=[] β€” Filename, directory, or URL to files the resource to update the env.
  • --from="" β€” The name of a resource from which to inject environment variables.
  • --keys=[] β€” Comma-separated list of keys to import from specified resource.
  • -k, --kustomize="" β€” Process the kustomization directory. This flag can't be used together with -f or -R. pick a lane bestie, they do NOT coexist. 🚫
  • --list=false β€” If true, display the environment and any changes in the standard format. this flag will removed when we have kubectl view env.
  • --local=false β€” If true, set env will NOT contact api-server but run locally. introvert mode activated. 🧚
  • -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 β€” If true, allow environment to be overwritten, otherwise reject updates that overwrite existing environment. choose your fighter.
  • --prefix="" β€” Prefix to append to variable names.
  • -R, --recursive=false β€” Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. go deep. 🌈
  • --resolve=false β€” If true, show secret or configmap references when listing variables. the receipts, revealed. πŸ”₯
  • -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. ALL of them. no partial credit. πŸ’€
  • --show-managed-fields=false β€” If true, keep the managedFields when printing objects in JSON or YAML format.
  • --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.

πŸŽ€ OPTIONS INHERITED FROM PARENT COMMANDS πŸŽ€

these are the family heirlooms, passed down from the parent command. iconic behavior. πŸ’œ

  • --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="/home/username/.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. ⚠️ okay so this one is literally the "trust me bro" flag, do NOT just leave it on, that's a security situation, be careful bestie.
  • --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.
  • --password="" β€” Password for basic authentication to the API server.
  • --profile="none" β€” Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace).
  • --profile-output="profile.pprof" β€” Name of the file to write the profile to.
  • --proxy-url="" β€” Proxy URL to use for requests to the API server.
  • --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.
  • --username="" β€” Username for basic authentication to the API server.
  • --version=false β€” --version, --version=raw prints version information and quits; --version=vX.Y.Z... sets the reported version.
  • --warnings-as-errors=false β€” Treat warnings received from the server as errors and exit with a non-zero exit code. no warning is a small warning to this flag. πŸ’€

🌟 EXAMPLE 🌟

the receipts, the demo, the tutorial era. watch and learn. ✨

# Update deployment 'registry' with a new environment variable
kubectl set env deployment/registry STORAGE_DIR=/local

# List the environment variables defined on a deployments 'sample-build'
kubectl set env deployment/sample-build --list

# List the environment variables defined on all pods
kubectl set env pods --all --list

# Output modified deployment in YAML, and does not alter the object on the server
kubectl set env deployment/sample-build STORAGE_DIR=/data -o yaml

# Update all containers in all replication controllers in the project to have ENV=prod
kubectl set env rc --all ENV=prod

# Import environment from a secret
kubectl set env --from=secret/mysecret deployment/myapp

# Import environment from a config map with a prefix
kubectl set env --from=configmap/myconfigmap --prefix=MYSQL_ deployment/myapp

# Import specific keys from a config map
kubectl set env --keys=my-example-key --from=configmap/myconfigmap deployment/myapp

# Remove the environment variable ENV from container 'c1' in all deployment configs
kubectl set env deployments --all --containers="c1" ENV-

# Remove the environment variable ENV from a deployment definition on disk and
# update the deployment config on the server
kubectl set env -f deploy.json ENV-

# Set some of the local shell environment into a deployment config on the server
env | grep RAILS_ | kubectl set env -e - deployment/registry

that ENV- at the end? that's the "remove it" move. the minus sign is doing all the work and it ate. πŸ”₯


πŸ‘‘ SEE ALSO πŸ‘‘

kubectl-set(1),


πŸ’– HISTORY πŸ’–

January 2015, Originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material, but hopefully they have been automatically generated since!


and that's the whole page, bestie. this came out of the kubernetes manual (section 1), and yeah β€” it's from the Manuals / User corner of the world, stamped KUBERNETES(1)(kubernetes), dated way back in Jan 2015, originally hand-compiled by Eric Paris. absolute legend behavior for real. now go set some env vars, you main character. πŸ’…πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from