Sorry, maybe this is not a problem. Post data as below to url http://$ip:8080/apis/extensions/v1beta1/namespaces/default/deployments/deployment-1/rollback {"kind":"Deployment","apiVersion":"extensions\/v1beta1","name":"deployment-1","updatedAnnotations":"1111","rollbackTo":{"revision":0}}
return error:
{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Deployment in version \"v1beta1\" cannot be handled as a DeploymentRollback: converting (v1beta1.Deployment) to (extensions.DeploymentRollback): UpdatedAnnotations not present in src","reason":"BadRequest","code":400}
Is there anything wrong with my post data? Another question: If a Deployment has two pods, there're two container in each of pod. I want update one container's image(use the url http://$ip:8080/apis/extensions/v1beta1/namespaces/default/deployments/$deployment_name
). If i just change the first container's image, another container is gone! Is that right? It means that if I want update one containers' label or image I need define all the info of the containers which in the same pod?
I found the second question's answer Should use API like this :
curl --request PATCH --header "Content-Type:application/strategic-merge-patch+json" http://$ip:8080/apis/extensions/v1beta1/namespaces/default/deployments/deployment-patch --data '{"spec":{"template":{"spec":{"containers":[{"name":"mofang-web","image":"abc.com\/docker\/mofang-web-cc:stable"}]}}}}'
But I still don't understand the differences between this three method:
application/json-patch+json
application/merge-patch+json
application/strategic-merge-patch+json
UpdatedAnnotations should be a map[string]string
, so try something like:
{
"kind":"Deployment",
"apiVersion":"extensions\/v1beta1",
"name":"deployment-1",
"updatedAnnotations": {"label":"1111"},
"rollbackTo":{"revision":0}
}
For your second question, you should be able to PATCH just the container image that you want to change. If you use PUT (or kubectl apply
) you need to provide the full PodSpec, including the containers that you aren't changing.