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

ccictl get

Scenario

Display one or more resources.

Print a table that contains the most important information related to a specified resource. You can use a label selector and the --selector flag to filter the list. If the requested resource type is namespaced, you will only see the result in the current namespace unless you pass the --all-namespaces parameter.

By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter the attributes of the fetched resources.

Use ccictl api-resources to obtain a complete list of supported resources.

ccictl get [(-o|--output=)json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file|custom-columns|custom-columns-file|wide] (TYPE[.VERSION][.GROUP] [NAME | -l label] | TYPE[.VERSION][.GROUP]/NAME ...) [flags]

Examples

# List all pods in ps output format.
ccictl get pods

# List all pods in ps output format and provide more information (such as pod IP addresses).
ccictl get pods -o wide

# List a single pod with a specified name in ps output format.
ccictl get po web

# List Deployments in the v2 version of the cci API group in JSON format.
ccictl get deployments.v2.cci -o json

# List a single pod in JSON format.
ccictl get -o json pod web-pod-13je7

# List a pod identified by type and name specified in pod.yaml in JSON output format.
ccictl get -f pod.yaml -o json

# Return only the phase value of the specified pod.
ccictl get -o template pod/web-pod-13je7 --template={{.status.phase}}

# List the resource information in custom columns
ccictl get pod test-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image

# List all Deployments and Services in ps output format.
ccictl get deploy,services

# List one or more resources by type and name.
ccictl get deploy/web service/frontend pods/web-pod-13je7

# List all Deployments in the backend namespace.
ccictl get deployments --namespace backend

# List all pods in all namespaces.
ccictl get pods --all-namespaces

Options

-A, --all-namespaces

If this flag exists, the requested object is listed across all namespaces. Even if a namespace is specified using --namespace, the namespace in the current context is ignored.

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

--chunk-size int     Default: 500

Return large lists in chunks rather than all at once. The value 0 indicates that the function is disabled.

--field-selector string

Selector used for filtering (field query). The value can be =, ==, or !=, for example, --field-selector key1=value1,key2=value2. The server only supports a limited number of field queries per type.

-f, --filename strings

List of file names, directories, or file URLs, which are used to identify the resource to be obtained from the server.

-h, --help

Help information for get

--ignore-not-found

If the requested object does not exist, the command returns the exit code 0.

-L, --label-columns strings

Accept a comma-separated list of labels that will be used as different columns in the printed table. The names are case sensitive. You can also use multiple flag options, for example, -L label1 -L label2...

--no-headers

When the default or custom column output format is used, do not print the headers (which are printed by default).

-o, --output string

Output format. The value options include json, yaml, name, go-template, go-template-file, template, templatefile, jsonpath, jsonpath-as-json, jsonpath-file, custom-columns, custom-columns-file, and wide. For details, refer to Custom Columns, Golang template (http://golang.org/pkg/text/template/#pkg-overview), and JSONPath Support in the JSONPath template.

--output-watch-events

When --watch or --watch-only is used, the watched event object is output. Existing objects are output as initial ADDED events.

--raw string

Raw URI to request from the server. Use the transfer mode specified in the cliconfig file.

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

--server-print     Default: true

If the value is true, the server returns the appropriate table output. Extended APIs and CRDs are supported.

--show-kind

If this flag is present, the resource types of the requested objects are listed.

--show-labels

During printing, all labels are displayed in the last column (which is hidden by default).

--sort-by string

If the value is not empty, this column is used to sort the list type. The field specification is expressed as a JSONPath expression (for example, {.metadata.name}). The field in the API resource specified by the JSONPath expression must be an integer or a string.

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

-w, --watch

After listing or obtaining the requested objects, watch their changes.

--watch-only

Watch for the changes to the requested objects, without listing or getting the objects first.

The following ccictl options can also be used in subcommands:

Parent command options