Mar*_*tin 2 kubernetes kubectl
列出 K8s 中的所有 API 资源时,您会得到:
$ kubectl api-resources -owide
NAME SHORTNAMES APIGROUP NAMESPACED KIND VERBS
bindings true Binding [create]
componentstatuses cs false ComponentStatus [get list]
configmaps cm true ConfigMap [create delete deletecollection get list patch update watch]
endpoints ep true Endpoints [create delete deletecollection get list patch update watch]
events ev true Event [create delete deletecollection get list patch update watch]
limitranges limits true LimitRange [create delete deletecollection get list patch update watch]
namespaces ns false Namespace [create delete get list patch update watch]
nodes no false Node [create delete deletecollection get list patch update watch]
persistentvolumeclaims pvc true PersistentVolumeClaim [create delete deletecollection get list patch update watch]
persistentvolumes pv false PersistentVolume [create delete deletecollection get list patch update watch]
pods po true Pod [create delete deletecollection get list patch update watch]
podtemplates true PodTemplate [create delete deletecollection get list patch update watch]
replicationcontrollers rc true ReplicationController [create delete deletecollection get list patch update watch]
resourcequotas quota true ResourceQuota [create delete deletecollection get list patch update watch]
secrets true Secret [create delete deletecollection get list patch update watch]
serviceaccounts sa true ServiceAccount [create delete deletecollection get list patch update watch]
services svc true Service [create delete get list patch update watch]
mutatingwebhookconfigurations admissionregistration.k8s.io false MutatingWebhookConfiguration [create delete deletecollection get list patch update watch]
... etc ...
Run Code Online (Sandbox Code Playgroud)
许多人列出了deletecollection听起来有用的动词,但我不能运行它,例如
$ kubectl deletecollection
Error: unknown command "deletecollection" for "kubectl"
Run 'kubectl --help' for usage.
unknown command "deletecollection" for "kubectl"
Run Code Online (Sandbox Code Playgroud)
我也无法在文档中找到它,除非它出现在上面的 api-resources 输出中或作为动词提及。
有没有办法删除集合?
听起来它会比我通常最终做的 grep/awk/xargs 序列更好,如果它确实做了我认为应该做的事情。即删除某种类型的所有豆荚。
该delete动词是指删除单个资源,例如,单荚。该deletecollection动词是指同时删除多个资源,例如多个 Pod 使用标签或字段选择器或命名空间中的所有 Pod。
从 API 文档中给出一些示例:
DELETE /api/v1/namespaces/{namespace}/pods/{name}deletecollection):
DELETE /api/v1/namespaces/{namespace}/podsDELETE /api/v1/namespaces/{namespace}/pods?labelSelector=someLabel%3dsomeValue关于 kubectl:您不能deletecollection使用kubectl.
相反,kubectl将自行推断是使用delete还是deletecollection取决于您如何调用kubectl delete. 删除单个源 ( kubectl delete pod $POD_NAME) 时,kubectl 将使用delete调用,而当使用标签选择器或简单地删除所有 Pod (kubectl delete pods -l $LABEL=$VALUE或kubectl delete pods --all) 时,它将使用deletecollection动词。
| 归档时间: |
|
| 查看次数: |
2140 次 |
| 最近记录: |