Restart container within pod

前端 未结 9 1092
日久生厌
日久生厌 2020-12-04 07:04

I have a pod test-1495806908-xn5jn with 2 containers. I\'d like to restart one of them called container-test. Is it possible to restart a single co

9条回答
  •  时光取名叫无心
    2020-12-04 07:26

    All the above answers have mentioned deleting the pod...but if you have many pods of the same service then it would be tedious to delete each one of them...

    Therefore, I propose the following solution, restart:

    • 1) Set scale to zero :

       kubectl scale deployment <> --replicas=0 -n service 
      

      The above command will terminate all your pods with the name <>

    • 2) To start the pod again, set the replicas to more than 0

      kubectl scale deployment <> --replicas=2 -n service
      

      The above command will start your pods again with 2 replicas.

提交回复
热议问题