2

I need to update all the pods(rolling updates), with env variable changes

I am not using kubectl, but using REST api.

Right not i am deleting the service and pods; And then recreating both services and pods. (It usually take around minutes, and there is downtime). Wanted similar with rolling update, without downtime.

3
  • "Rolling Update" with "Downtime" is a strange question to ask. Seems you didn't understand the Rolling Update concept properly. We follow Rolling Update to maintain zero downtime. Please take a look at kubernetes.io/docs/tutorials/kubernetes-basics/update/… Commented May 16, 2020 at 8:24
  • yeah,, i meant without downtime.. updated the question.. thanks Commented May 16, 2020 at 9:17
  • Use Deployment to create pods instead of creating raw pods. Once you update env vars in deployment manifest, it'll apply the changes and automatically restart pods in the rolling update method. Commented May 16, 2020 at 9:45

2 Answers 2

4

If you want to restart all pod attached to a deployment, then you can do that by running

$ curl -k --data '{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubrnetes.io/restartedAt":"'"$(date +%Y-%m-%dT%T%z)"'"}}}}}' -XPATCH   -H "Accept: application/json, */*" -H "Content-Type: application/strategic-merge-patch+json" localhost:8001/apis/extensions/v1beta1/namespaces/default/deployments/mydeployment

Sign up to request clarification or add additional context in comments.

3 Comments

wow, where can i find more docs for this .. is there some typo in cmd .. template or kubrnetes.
yeah. updated answer.I ran rollout command with --v=10 flag and notices the logs
3

Use deployment instead of pods.

Deployment has DeploymentStrategy , maxUnavailable, maxSurge using which you can achieve zero downtime upgrade.

For changing env just change it the deployment yaml and apply it to the cluster. It will rollout the deployment without any downtime.

Kubectl internally calls rest api exposed by Kubernetes API Server. You could check what rest call being sent by kubectl by increasing the verbosity. Once you know the rest api being called you could call those apis as well.

kubectl rollout restart deployment/frontend -v=10

2 Comments

i am not using deployment, just using service with pods, is it better to use deployment; i get the following error. I tried to do rollout restart on service error: services "service2" restarting is not supported. .. Also how can i override an env variable
yes deployment is better and rollout restart is only for deployments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.