Açıklaması şöyle
This method is the recommended first port of call as it will not introduce downtime as pods will be functioning. A rollout restart will kill one pod at a time, then new pods will be scaled up. This method can be used as of K8S v1.15.
Şöyle yaparız. Kesinti (downtime) gerektirmez
kubectl rollout restart deployment <deployment_name> -n <namespace>
2. kubectl scale
Açıklaması şöyle
This method will introduce an outage and is not recommended. If downtime is not an issue, this method can be used as it can be a quicker alternative to the kubectl rollout restart method (your pod may have to run through a lengthy Continuous Integration / Continuous Deployment Process before it is redeployed).If there is no YAML file associated with the deployment, you can set the number of replicas to 0.This terminates the pods. Once scaling is complete the replicas can be scaled back up as needed (to at least 1)
Şöyle yaparız. Kesinti (downtime) gerektirir
kubectl scale deployment <deployment name> -n <namespace> --replicas=0 kubectl scale deployment <deployment name> -n <namespace> --replicas=3
3. kubectl delete pod and kubectl delete replicaset
Şöyle yaparız
kubectl delete pod <pod_name> -n <namespace> or kubectl delete pod -l “app:myapp” -n <namespace> or kubectl delete replicaset <name> -n <namespace>
4. kubectl get pod | kubectl replace
Açıklaması şöyle
The pod to be replaced can be retrieved using the kubectl get pod to get the YAML statement of the currently running pod and pass it to the kubectl replace command with the --force flag specified in order to achieve a restart. This is useful if there is no YAML file available and the pod is started.
Şöyle yaparız
kubectl get pod <pod_name> -n <namespace> -o yaml | kubectl replace --force -f -
5. kubectl set env
Açıklaması şöyle
Setting or changing an environment variable associated with the pod will cause it to restart to take the change. The example below sets the environment variable DEPLOY_DATE to the date specified, causing the pod to restart.
Şöyle yaparız
kubectl set env deployment <deployment name> -n <namespace> DEPLOY_DATE="$(date)"
6. kill the main process of a specific container
Açıklaması şöyle
This method will allow you to kill the main process of a specific container which will trigger a restart of that container without K8S killing the pod and recreating it.This will send a SIGTERM signal to process 1, which is the main process running in the container. All other processes will be children of process 1, and will be terminated after process 1 exits. See the kill manpage for other signals you can send.
Şöyle yaparız
kubectl exec -it <pod_name> -c <container_name> --/bin/sh -c "kill 1"
Hiç yorum yok:
Yorum Gönder