我想通过kubernetes API从我的kubernetes版本:1.24从节点或吊舱中删除标签
kubectl get pod --show-labels | grep all-flow-0fbah
all-flow-0fbah 1/1 Running 2 9d app=all-flow,op=vps1,version=1001
我使用如下命令:
curl --request PATCH --header "Content-Type:application/json-patch+json" http://10.93.78.11:8080/api/v1/namespaces/default/pods/all-flow-0fbah --data '{"metadata":{"labels":{"a":"b"}}}'
但这是行不通的。返回消息如下:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "the server responded with the status code 415 but did not return more information",
"details": {},
"code": 415
}
然后我像这样更改curl标头:
curl --request PATCH --header "Content-Type:application/merge-patch+json" http://10.93.78.11:8080/api/v1/namespaces/default/pods/all-flow-0fbah --data '{"meadata":{"labels":{"op":"vps3"}}}'
它不会删除标签,但会向该窗格添加新标签。那么有没有人可以告诉我如何删除pod的标签,例如use命令:
kubectl label pod all-flow-0fbah key-
谢谢!
正如workhardcc在评论中发布的那样,执行此操作的方法是
curl -k -v -XPATCH -H "Accept: application/json, /" -H "Content-Type: application/strategic-merge-patch+json" 10.10.10.10:443/api/v1/namespaces/default/pds/all-flow-946y0 --data '{"metadata":{"labels":{"$patch": "delete", "app":"all-flow"}}}'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句