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

ccictl create configmap

Scenario

Create a ConfigMap based on a file, directory, or specified literal value.

A ConfigMap can contain one or more key-value pairs.

When creating a ConfigMap based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key, you may specify an alternate key.

When creating a ConfigMap based on a directory, each file whose basename is a valid key in the directory will be packaged into the ConfigMap. Any directory entries (such as subdirectories, symlinks, devices, pipes) except regular files are ignored.

ccictl create configmap NAME [--from-file=[key=]source] [--from-literal=key1=value1]

Examples

# Create a ConfigMap named my-config based on the bar folder.
ccictl create configmap my-config --from-file=path/to/bar

# Create a ConfigMap named my-config with specified keys instead of the names on the disk.
ccictl create configmap my-config --from-file=key1=/path/to/bar/file1.txt --from-file=key2=/path/to/bar/file2.txt

# Create a ConfigMap named my-config with key1=config1 and key2=config2.
ccictl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2

# Create a ConfigMap named my-config from the key-value pair in the file.
ccictl create configmap my-config --from-file=path/to/bar

# Create a ConfigMap named my-config from env files.
ccictl create configmap my-config --from-env-file=path/to/foo.env --from-env-file=path/to/bar.env

Options

--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.

--append-hash

Append a hash of the ConfigMap to its name.

--from-env-file strings

Specify the file path to read lines of key=val pairs to create a ConfigMap.

--from-file strings

The key file can be specified using its file path. In this case, the base name of the file is used as the key of the ConfigMap. In addition, the key file can be specified using the key and file path. In this case, the specified key is used. Specifying a directory will traverse all named files in this directory (with valid ConfigMap keys as their base names).

--from-literal strings

Specify a key and literal value (for example, mykey=somevalue) to insert in the ConfigMap.

-h, --help

Help information for create configmap

-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.

--save-config

If the value is true, the configuration of the object is saved in its annotation. Otherwise, the annotation remains unchanged. This flag is useful when you want to run the ccictl apply command on the object.

--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