Skip to main content
Calico Open Source 3.33 (latest) documentation

calicoctl apply

This sections describes the calicoctl apply command.

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 Resources section for details about each resource type.

Displaying the help text for 'calicoctl apply' command​

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

Create or update one or more Calico resources from a file, directory, or stdin,
in YAML or JSON format. Apply adds resources that don't exist yet and updates
those that do, so it's the right choice when you don't care whether the resource
is already present.

Usage:
calicoctl apply [flags]

Examples:
# Apply resources from a file.
calicoctl apply -f ./policy.yaml

# Apply resources from stdin.
cat policy.json | calicoctl apply -f -

Flags:
-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")
-f, --filename string Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.
-h, --help help for apply
-n, --namespace string Namespace of the resource.
-R, --recursive Process the filename specified in -f recursively.
--skip-empty Do not error if files contain no data.

Global Flags:
--allow-version-mismatch Allow client and cluster versions mismatch
--context string The name of the kubeconfig context to use
-l, --log-level string Set the log level (panic, fatal, error, warn, info, debug) (default "panic")

Examples​

  1. Apply a set of resources (of mixed type) using the data in resources.yaml.

    calicoctl apply -f ./resources.yaml

    Results indicate that 8 resources were successfully applied

    Successfully applied 8 resource(s)
  2. Apply two policy resources based on the JSON passed into stdin.

    cat policy.json | calicoctl apply -f -

    Results indicate success.

    Successfully applied 2 'policy' resource(s)

Options​

-f, --filename string Filename to use to create/apply/replace/delete the resource. Use '-' for stdin.
-n, --namespace string Namespace of the resource.

General options​

-c, --config string Path to the file containing connection configuration in YAML or JSON format. (default "/etc/calico/calicoctl.cfg")

See also​