Interestingly, there are many ways to restart a pod and different people prefer different ways. It is purely a subjective choice.

A pod is rarely created without being part of a deployment and is never recommended for production environments. A deployment will take care of spawning new pods if an existing pod fails or gets deleted. A deployment will take care of keeping the number of pods to match the number of replicas(default=1) defined at the deployment level. This is one of the self healing capabilities of Kubernetes.

I am aware of 3 different ways to restart a Kubernetes pod attached to a deployment and I have listed them in my order of preference.

  • Using rollout restart option
   kubectl rollout restart deployment/mariadb
  • Using scaling down and scaling up the deployments
   kubectl scale deployment mariadb --replicas=0
   kubectl scale deployment mariadb --replicas=1
  • Crude way is to simply delete the pod
   kubectl delete pod mariadb-59d4487ccf-89pdk

Please leave us a comment if you are aware of a 4th way or you have a certain preference to one of the above ways.

Leave a Reply

Your email address will not be published. Required fields are marked *