I want to update the image for the k8s deployment and I found two RESTAPI in k8s to update the deployment: PATCH
and PUT
. I found out, that the PATCH
is for updating and the PUT
is for replacing in the official document but after testing with the two command:
kubectl patch -p ...
kubectl replace -f ...
it seems to has no differences between the two method.
Both of them can rollback and name of the new pod changed.
I wondered if it is only different in the request body for this two commands? (patch only need the changed part and put need the whole parts)
According to the documenation:
kubectl patch
is to change the live configuration of a Deployment object. You do not change the configuration file that you originally used to create the Deployment object.
kubectl replace
If replacing an existing resource, the complete resource spec must be provided.
replace
is a full replacement. You have to have ALL the fields present. patch
is partial.