Updated on 2025-04-03 GMT+08:00

ccictl set env

Scenario

Update environment variables in a pod template.

List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates (within replication controllers or Deployment configurations). View or modify the environment variable definitions on all containers in the specified pods or pod templates, or just those that match a wildcard.

If --env - is passed, environment variables can be read from stdin using the standard env syntax.

Possible resources include (case insensitive):

pods (po) and Deployments (deploy)

ccictl set env RESOURCE/NAME KEY_1=VAL_1 ... KEY_N=VAL_N

Examples

# Update the registry Deployment with a new environment variable.
ccictl set env deployment/registry STORAGE_DIR=/local

# List the environment variables defined on the sample-build Deployment.
ccictl set env deployment/sample-build --list

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

# Output a modified Deployment in YAML without altering the object on the server.
ccictl set env deployment/sample-build STORAGE_DIR=/data -o yaml

# Update all containers in all replication controllers in the project to have ENV=prod.
ccictl set env deploy --all ENV=prod

# Import the environment from a secret.
ccictl set env --from=secret/mysecret deployment/myapp

# Import the environment from a ConfigMap with a prefix.
ccictl set env --from=configmap/myconfigmap --prefix=MYSQL_ deployment/myapp

# Import a specific key from a ConfigMap.
ccictl set env --keys=my-example-key --from=configmap/myconfigmap deployment/myapp

# Remove the environment variable ENV from the c1 container in all Deployment configurations.
ccictl set env deployments --all --containers="c1" ENV-

# Remove the environment variable ENV from a Deployment definition on the disk and update the Deployment configuration on the server.
ccictl set env -f deploy.json ENV-

# Set some local Shell environment variables into the Deployment configuration on the server.
env | grep RAILS_ | ccictl set env -e - deployment/registry

Options

--all

If the value is true, all resources in the namespace of the specified resource type are selected.

--allow-missing-template-keys     Default: true

If the value is true, the error in the template is ignored when a field or mapping key is missing in the template. This option applies only to the Golang and JSONPath output formats.

-c, --containers string     Default: "*"

Names of the containers to be changed in the selected pod template. Wildcard characters can be used.

-e, --env strings

Specify a key-value pair for an environment variable to set into each container.

-f, --filename strings

List of file names, directories, or file URLs, which are used to identify the resources whose environments are to be updated.

--from string

Name of a resource from which to inject environment variables

-h, --help

Help information for set env

--keys strings

List of comma-separated keys to be imported from the specified resource

--list

If the value is true, the environment and all changes are displayed in the standard format. This flag is removed when the ccictl view env command is used.

--local

If the value is true, set env will not communicate with the API server and will run locally.

-o, --output string

Output format. The value options include json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, and jsonpath-file.

--overwrite     Default: true

If the value is true, the environment can be overwritten. Otherwise, the update to overwrite the existing environment is rejected.

--prefix string

Prefix to be added to the variable names

-R, --recursive

Process the directory used in -f or --filename recursively. This option is useful when you want to manage related manifests organized within the same directory.

--resolve

If the value is true, the secret or ConfigMap reference is displayed when the variable is listed.

-l, --selector string

Selector used for filtering (label query). The value can be =, ==, or !=, for example, -l key1=value1,key2=value2. Matched objects must meet all specified label constraints.

--template string

Template character string or template file path used when -o is set to go-template or go-template-file. The Golang template format is [http://golang.org/pkg/text/template/#pkg-overview].

The following ccictl options can also be used in subcommands:

Parent command options