ccictl delete
Scenario
Delete resources based on the file name, stdin, resource, and name, or based on the resource and label selector.
Both JSON and YAML are supported. Only one type of argument can be specified: file name, resource and name, or resource label selector.
Some resources (such as pods) support graceful deletion. These resources define the default duration (grace period) before a forcible termination, but you can override the value using the --grace-period flag or pass --now to set the grace period to 1. Deletion may not be confirmed immediately because these resources usually represent entities in the cluster. If the API server is not accessible, the termination time may be much longer than the grace period. To force the deletion of a resource, you must specify the --force flag. Note: Only some resources support graceful deletion. If graceful deletion is not supported, the --grace-period flag will be ignored.
Important: If you forcibly delete a pod, the system does not wait for the pod process to be terminated. As a result, the pod process may continue to run until the node detects the deletion request and completes graceful deletion. You can forcibly delete a pod only when you are sure that the pod has been terminated or your application can tolerate multiple copies of the same pod running at the same time.
Note that the delete command does not check the resource version. If someone submits an update to a resource right when you submit a deletion request, their update will be lost along with the rest of the resource.
ccictl delete ([-f FILENAME] | TYPE [(NAME | -l label | --all)])
Examples
# Delete a pod using the type and name specified in pod.json. ccictl delete -f ./pod.json # Delete resources based on the content in the directory. ccictl delete -f dir/ # Delete the resources in all files that end with .json. ccictl delete -f '*.json' # Delete a pod based on the type and name transferred to stdin in JSON. cat pod.json | ccictl delete -f - # Delete the pods and Services named baz and foo. ccictl delete pod,service baz foo # Delete the pod and Service with the name=myLabel label. ccictl delete pods,services -l name=myLabel # Delete a pod with the minimum delay. ccictl delete pod foo --now # Forcibly delete a pod. ccictl delete pod foo --force # Delete all pods. ccictl delete pods --all
Options
--all
Delete all resources in the namespace of a specified resource type.
-A, --all-namespaces
If this option is present, all objects requested across namespaces are listed. Even if a namespace is specified using --namespace, the namespace in the current context is ignored.
--cascade string[="background"] Default: "background"
Select the cascading policy for deleting dependent objects (for example, pods created by Deployment). The value must be background, orphan, or foreground, and the default value is background.
--field-selector string
Selector used for filtering (field query). The value can be =, ==, or !=, for example, --field-selector key1=value1,key2=value2. The server only supports a limited number of field queries per type.
-f, --filename strings
Names of the files that contain the resources to be deleted
--force
If the value is true, the resource is immediately removed from the API, and the graceful deletion process is bypassed. Note that deleting some resources immediately may cause inconsistency or data loss, and you need to confirm the operation.
--grace-period int Default: -1
Period of time given to the resource to terminate gracefully, in seconds. If the value is a negative number, it is ignored. If the value is 1, the resource is immediately terminated. This parameter can only be set to 0 when --force is set to true (forcible deletion).
-h, --help
Help information for delete
--ignore-not-found
"resource not found" is considered as a successful deletion. When the --all parameter is specified, the default value is true.
--now
If the value is true, the resource will be marked for immediate shutdown (equivalent to --grace-period=1).
-o, --output string
Output mode. Use -o name to obtain a shorter output (resource/name).
--raw string
Raw URI to request from the server. Use the transfer mode specified in the cliconfig file.
-R, --recursive
Process the directory used in -f or --filename recursively. This option is useful when you want to manage related manifests organized within the same directory.
-l, --selector string
Selector used for filtering (label query). The value can be =, ==, or !=, for example, -l key1=value1,key2=value2. Matched objects must meet all specified label constraints.
--timeout duration
The length of time to wait before the deletion is canceled. The value 0 indicates that the timeout duration is determined based on the object size.
--wait Default: true
If the value is true, the resource is returned after it disappears. This waits for the finalizer.
The following ccictl options can also be used in subcommands:
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot