Akshay Gopani
Akshay Gopani

Reputation: 491

How to Restart Kubernetes deployment using API Server

We can restart kubernetes deployment using kubectl rollout restart. I want to perform same action using kubernetes api server.

Upvotes: 4

Views: 1427

Answers (1)

Harsh Manvar
Harsh Manvar

Reputation: 30083

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.

Upvotes: 4

Related Questions