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

ccictl apply

Scenario

Apply a configuration to a resource by file name or stdin. The resource name must be specified. If the resource does not exist, the resource will be created. To use the apply command, you should always use apply or create --save-config when initially creating the resource.

Both JSON and YAML are supported.

ccictl apply -f FILENAME

Examples

# Apply the configuration in pod.json to a pod.
ccictl apply -f ./pod.json

# Apply resources from the directory.
ccictl apply -f dir/

# Apply the JSON passed to stdin to a pod.
cat pod.json | ccictl apply -f -

# Apply the configurations in all files that end with .json.
ccictl apply -f '*.json'

Options

--all

Select all resources in the namespace of the specified resource types.

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

--cascade string[="background"]     Default: "background"

The value must be background, orphan, or foreground. This is to select the cascading policy for deleting dependent objects (for example, pods created by Deployment). The default value is background.

-f, --filename strings

Files that contain the configurations to be applied.

--force

If the value is true, the resource is immediately removed from the API, and the graceful deletion process is bypassed. Note that deleting some resources immediately may cause inconsistency or data loss, and you need to confirm the operation.

--grace-period int     Default: -1

Period of time given to the resource to terminate gracefully, in seconds. If the value is a negative number, it is ignored. If the value is 1, the resource is immediately terminated. This parameter can only be set to 0 when --force is set to true (forcible deletion).

-h, --help

Help information for apply

--openapi-patch     Default: true

If the value to true, OpenAPI is used to calculate the diff when OpenAPI exists, and resources can be found in the OpenAPI specifications. Otherwise, the built-in type is used.

-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

The value in the modified configuration is used to automatically resolve the conflict between the modified configuration and the real-time configuration.

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

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

--timeout duration

The length of time to wait before the deletion is canceled. The value 0 indicates that the timeout duration is determined based on the object size.

--validate string[="strict"]     Default: "strict"

The value must be one of the following: "strict" (or "true"), "warn", and "ignore" (or "false"). "true" or "strict" will use the pattern definition to validate the input. If the input is invalid, the request fails. "false" or "ignore" will not perform any schema definition checks, but will silently delete all unknown or duplicate fields.

--wait

If the value is true, the resource is returned after it disappears. This waits for the finalizer.

The following ccictl options can also be used in subcommands:

Parent command options