calicoctl get

    Read the calicoctl command line interface user reference for a full list of calicoctl commands.

    note

    The available actions for a specific resource type may be limited based on the datastore used for Calico (etcdv3 / Kubernetes API). Please refer to the for details about each resource type.

    Run calicoctl get --help to display the following help menu for the command.

    1. -h --help Show this screen.
    2. -f --filename=<FILENAME> Filename to use to get the resource. If set to
    3. "-" loads from stdin.
    4. -o --output=<OUTPUT FORMAT> Output format. One of: yaml, json, ps, wide,
    5. custom-columns=..., go-template=...,
    6. go-template-file=... [Default: ps]
    7. -n --namespace=<NS> Namespace of the resource.
    8. Only applicable to NetworkPolicy, NetworkSet, and WorkloadEndpoint.
    9. Uses the default namespace if not specified.
    10. all namespaces.
    11. --export If present, returns the requested object(s) stripped of
    12. cluster-specific information. This flag will be ignored
    13. if the resource name is not specified.
    1. -c --config=<CONFIG> Path to the file containing connection
    2. configuration in YAML or JSON format.

    ps

    This is the default output format. It displays output in ps-style table output with sufficient columns to uniquely identify the resource.

    The headings displayed for each resource type is fixed. However, we wide option for displaying additional columns, and custom-columns for selecting which columns to display.

    1. calicoctl get hostEndpoint

    Response:

    wide

    Similar to the ps format, the wide option displays output in ps-style table output but with additional columns.

    The headings displayed for each resource type is fixed. See custom-columns for selecting which columns to display.

    Example:

    1. calicoctl get hostEndpoint --output=wide

    Response:

    1. NAME NODE INTERFACE IPS PROFILES
    2. endpoint1 host1 1.2.3.4,0:bb::aa prof1,prof2
    3. myhost-eth0 myhost profile1

    custom-columns

    Similar to the ps format, the custom-columns option displays output in ps-style table output but allows the user to specify and ordered, comma-separated list of columns to display in the output. The valid heading names for each resource type is documented in the guide.

    1. calicoctl get hostEndpoint --output=custom-columns=NAME,IPS

    Response:

    yaml / json

    The yaml and json options display the output as a list of YAML documents or JSON dictionaries. The fields for resource type are documented in the guide.

    The output from either of these formats may be used as input for all of the resource management commands.

    Example:

    1. calicoctl get hostEndpoint --output=yaml

    Response:

    1. - apiVersion: projectcalico.org/v3
    2. kind: HostEndpoint
    3. labels:
    4. type: database
    5. spec:
    6. node: host1
    7. expectedIPs:
    8. - 1.2.3.4
    9. - 0:bb::aa
    10. profiles:
    11. - prof1
    12. - prof2
    13. - apiVersion: projectcalico.org/v3
    14. kind: HostEndpoint
    15. metadata:
    16. name: myhost-eth0
    17. spec:
    18. node: myhost
    19. profiles:
    20. - profile1

    go-template / go-template-file

    The go-template and go-template-file options display the output using a golang template specified as a string on the CLI, or defined in a separate file. When writing a template, be aware that the data passed to the template is a golang slice of resource-lists. The resource-lists are defined in the and there is a resource-list defined for each resource type. A resource-list contains an Items field which is itself a slice of resources. Thus, to output the “Name” field from the supplied data, it is necessary to enumerate over the slice of resource-lists and the items within that list.

    1. endpoint1,eth0,

    See also

    • .
    • NetworkPolicy for details on the Calico selector-based policy model