我可以按照here
所述向广告连播添加标签但同样创建注释也没有运气
$ KUBE_TOKEN=$(</var/run/secrets/kubernetes.io/serviceaccount/token)
$ cat > patch.json <<EOF
]
{
"op": "add", "path": "/metadata/annotations/test", "value": "world"
}
]
EOF
$ curl -sSk -H "Authorization: Bearer $KUBE_TOKEN" --request PATCH --data "$(cat patch.json)" -H "Content-Type:application/json-patch+json" https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/$POD_NAMESPACE/pods/$POD_NAME
回复是:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "jsonpatch add operation does not apply: doc is missing path: /metadata/annotations/test",
"code": 500
}
答案 0 :(得分:1)
AFAIR,您无法在现有资源上添加新注释。您只能更新现有的。
答案 1 :(得分:0)
该错误与不存在的路径有关。
[
{
"op": "add", "path": "/metadata/annotations/", "value": { "test" : "world" }
}
]