calicoctl convert

This sections describes the calicoctl convert command.

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

calicoctl convert - 图1note

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 convert’ command

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

  1. Usage:
  2. calicoctl convert --filename=<FILENAME>
  3. [--output=<OUTPUT>] [--ignore-validation]
  4. Examples:
  5. # Convert the contents of policy.yaml to a Calico v3 policy.
  6. calicoctl convert -f ./policy.yaml -o yaml
  7. # Convert a policy based on the JSON passed into stdin.
  8. cat policy.json | calicoctl convert -f -
  9. Options:
  10. -h --help Show this screen.
  11. -f --filename=<FILENAME> Filename to use to create the resource. If set to
  12. "-" loads from stdin.
  13. -o --output=<OUTPUT FORMAT> Output format. One of: yaml or json.
  14. [Default: yaml]
  15. --ignore-validation Skip validation on the converted manifest.
  16. Description:
  17. Convert config files from Calico v1 or Kubernetes to Calico v3 API versions. Both YAML and JSON formats are accepted.
  18. The default output will be printed to stdout in YAML format.

calicoctl convert - 图2note

Currently the only Kubernetes API resource supported for conversion is NetworkPolicy.

Examples

  1. Convert a set of resources (of mixed type) from Calico v1 or Kubernetes to Calico v3 APIs using the data in resources.yaml.

    1. calicoctl convert -f multi-resource-v1.yaml -o yaml > multi-resource-v3.yaml

    calicoctl convert - 图3tip

    By default convert command outputs the converted resources to stdout, but it can be redirected to a file.

  2. Convert a policy based on the JSON passed into stdin.

    1. cat policy.json | calicoctl convert -f -

    Result will be printed to stdout.

Options

  1. -f --filename=<FILENAME> Filename to use to convert the resource. If set to
  2. "-" loads from stdin.
  3. -o --output=<OUTPUT FORMAT> Output format. One of: yaml or json.
  4. [Default: yaml]
  5. --ignore-validation Skip validation on the converted manifest.

See also