【发布时间】:2020-10-21 02:40:10
【问题描述】:
我想通过 kubernetes API 从节点或 pod 中删除标签,我的 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 添加一个新标签。 那么有没有人可以告诉我如何删除像使用命令这样的 pod 的标签:
kubectl label pod all-flow-0fbah key-
谢谢!
【问题讨论】:
标签: docker kubernetes