k8s重启pod方式
本文最后更新于:2022年6月6日 下午
Rolling Restart Method
Kubernetes now allows you to execute a rolling restart of your deployment as of version 1.15. This is the quickest restart mechanism in Kubernetes, as it is a new addition. The command given above shuts down and restarts each container in your deployment one by one. Because most of the containers are still functioning, your app will be accessible.
1 |
|
Environment Variable Method
Another option is to force pods to restart and sync with your changes by setting or changing an environment variable. You can, for instance, alter the date of container deployment:
In the scenario above, set env modifies the environment variables, deployment [deployment name] selects your deployment, and DEPLOY DATE=”$(date)” modifies the deployment date and causes the pod to resume.
1 |
|
Scale Command to Change Replicas
You can modify the number of clones of the defective pod by using the scale command. When you set this value to 0, the pod is effectively turned off:
1 |
|
To restart the pod, provide the following command with a number of replicas greater than zero:
1 |
|