calicoctl replace

This sections describes the calicoctl replace command.

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

calicoctl replace - 图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 replace’ command

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

  1. Usage:
  2. calicoctl replace --filename=<FILENAME> [--recursive] [--skip-empty] [--config=<CONFIG>] [--namespace=<NS>]
  3. Examples:
  4. # Replace a policy using the data in policy.yaml.
  5. calicoctl replace -f ./policy.yaml
  6. # Replace a policy based on the JSON passed into stdin.
  7. cat policy.json | calicoctl replace -f -
  8. Options:
  9. -h --help Show this screen.
  10. -f --filename=<FILENAME> Filename to use to replace the resource. If set
  11. to "-" loads from stdin. If filename is a directory, this command is
  12. invoked for each .json .yaml and .yml file within that directory,
  13. terminating after the first failure.
  14. -R --recursive Process the filename specified in -f or --filename recursively.
  15. --skip-empty Do not error if any files or directory specified using -f or --filename contain no
  16. data.
  17. -c --config=<CONFIG> Path to the file containing connection
  18. configuration in YAML or JSON format.
  19. [default: /etc/calico/calicoctl.cfg]
  20. -n --namespace=<NS> Namespace of the resource.
  21. Only applicable to NetworkPolicy, NetworkSet, and WorkloadEndpoint.
  22. Uses the default namespace if not specified.
  23. --context=<context> The name of the kubeconfig context to use.
  24. Description:
  25. The replace command is used to replace a set of resources by filename or
  26. stdin. JSON and YAML formats are accepted.
  27. Valid resource types are:
  28. * bgpConfiguration
  29. * bgpPeer
  30. * felixConfiguration
  31. * globalNetworkPolicy
  32. * hostEndpoint
  33. * ipPool
  34. * networkPolicy
  35. * networkSet
  36. * node
  37. * profile
  38. * workloadEndpoint
  39. Attempting to replace a resource that does not exist is treated as a
  40. terminating error.
  41. The output of the command indicates how many resources were successfully
  42. replaced, and the error reason if an error occurred.
  43. The resources are replaced in the order they are specified. In the event of
  44. a failure replacing a specific resource it is possible to work out which
  45. resource failed based on the number of resources successfully replaced.
  46. When replacing a resource, the complete resource spec must be provided, it is
  47. not sufficient to supply only the fields that are being updated.

Examples

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

    1. calicoctl replace -f ./resources.yaml

    Results indicate that 8 resources were successfully replaced.

    1. Successfully replaced 8 resource(s)
  2. Replace a policy based on the JSON passed into stdin.

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

    Results indicate the policy does not exist.

    1. Failed to replace any 'policy' resources: resource does not exist: Policy(name=dbPolicy)

Options

  1. -f --filename=<FILENAME> Filename to use to replace the resource. If set
  2. to "-" loads from stdin.

General options

  1. -c --config=<CONFIG> Path to the file containing connection
  2. configuration in YAML or JSON format.
  3. [default: /etc/calico/calicoctl.cfg]

See also