calicoctl delete

This sections describes the calicoctl delete command.

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

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

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

  1. Usage:
  2. calicoctl delete ( (<KIND> [<NAME...>]) |
  3. --filename=<FILE>) [--recursive] [--skip-empty]
  4. [--skip-not-exists] [--config=<CONFIG>] [--namespace=<NS>]
  5. Examples:
  6. # Delete a policy using the type and name specified in policy.yaml.
  7. calicoctl delete -f ./policy.yaml
  8. # Delete a policy based on the type and name in the YAML passed into stdin.
  9. cat policy.yaml | calicoctl delete -f -
  10. # Delete policies with names "foo" and "bar"
  11. calicoctl delete policy foo bar
  12. Options:
  13. -h --help Show this screen.
  14. -s --skip-not-exists Skip over and treat as successful, resources that
  15. don't exist.
  16. -f --filename=<FILENAME> Filename to use to delete the resource. If set to
  17. "-" loads from stdin. If filename is a directory, this command is
  18. invoked for each .json .yaml and .yml file within that directory,
  19. terminating after the first failure.
  20. -R --recursive Process the filename specified in -f or --filename recursively.
  21. --skip-empty Do not error if any files or directory specified using -f or --filename contain no
  22. data.
  23. -c --config=<CONFIG> Path to the file containing connection
  24. configuration in YAML or JSON format.
  25. [default: /etc/calico/calicoctl.cfg]
  26. -n --namespace=<NS> Namespace of the resource.
  27. Only applicable to NetworkPolicy and WorkloadEndpoint.
  28. Uses the default namespace if not specified.
  29. --context=<context> The name of the kubeconfig context to use.
  30. Description:
  31. The delete command is used to delete a set of resources by filename or stdin,
  32. or by type and identifiers. JSON and YAML formats are accepted for file and
  33. stdin format.
  34. Valid resource types are:
  35. * bgpConfiguration
  36. * bgpPeer
  37. * felixConfiguration
  38. * globalNetworkPolicy
  39. * hostEndpoint
  40. * ipPool
  41. * networkPolicy
  42. * node
  43. * profile
  44. * workloadEndpoint
  45. The resource type is case insensitive and may be pluralized.
  46. Attempting to delete a resource that does not exists is treated as a
  47. terminating error unless the --skip-not-exists flag is set. If this flag is
  48. set, resources that do not exist are skipped.
  49. When deleting resources by type, only a single type may be specified at a
  50. time. The name is required along with any and other identifiers required to
  51. uniquely identify a resource of the specified type.
  52. The output of the command indicates how many resources were successfully
  53. deleted, and the error reason if an error occurred. If the --skip-not-exists
  54. flag is set then skipped resources are included in the success count.
  55. The resources are deleted in the order they are specified. In the event of a
  56. failure deleting a specific resource it is possible to work out which
  57. resource failed based on the number of resources successfully deleted.

Examples

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

    1. calicoctl delete -f ./resources.yaml

    Results indicate that 8 resources were successfully deleted.

    1. Successfully deleted 8 resource(s)
  2. Delete a policy resource by name. The policy is called “policy1”.

    1. bin/calicoctl delete policy policy1

    Results indicate success.

    1. Successfully deleted 1 'policy' resource(s)

Options

  1. -s --skip-not-exists Skip over and treat as successful, resources that
  2. don't exist.
  3. -f --filename=<FILENAME> Filename to use to delete the resource. If set to
  4. "-" loads from stdin.
  5. -n --namespace=<NS> Namespace of the resource.
  6. Only applicable to NetworkPolicy and WorkloadEndpoint.
  7. Uses the default namespace if not specified.

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