We can restart kubernetes deployment using kubectl rollout restart. I want to perform same action using kubernetes api server.
CodePudding user response:
You can use this Curl to restart using the API
curl --location --request PATCH 'http://<K8s cluster IP>:6443/apis/apps/v1/namespaces/<Namespace name>/deployments/<Deployment name>?fieldManager=kubectl-rollout&pretty=true' \
--header 'Content-Type: application/strategic-merge-patch json' \
--data-raw '{
"spec": {
"template": {
"metadata": {
"annotations": {
"kubectl.kubernetes.io/restartedAt": <time.Now()>
}
}
}
}
}'
this will inject the annotation in deployment and restart the deployment.