kubectl rollout restart
Although method 1 is a faster approach, the rollout restart command is the easiest way to restart Kubernetes pods.
Step 1: Using the ReplicaSet to scale up additional pods until they are all younger than when the controller restarted, the controller kills one pod at a time. Since your application won’t be impacted or crash, rolling out restart is the best way to restart your pods.
Step 2: To initiate a restart, use the subsequent command:
kubectl rollout restart deployment <deployment_name> -n <namespace>
Step 3: Here, in our example the deployment name is my-app-deployment and namespace is default
As shown in the example, the output of the command is that the container was restarted.
How to Restart Container in Kubernetes?
Kubernetes is a platform for container orchestration created to simplify application deployment, scaling, and administration. Suppose you have a big package of LEGO parts and you want to use them to make something very spectacular. But as your LEGO creation becomes larger, it becomes harder to organize and keep track of every component. This is where Kubernetes comes into play. Kubernetes is like a really smart LEGO manager. It helps you maintain control over an organization over all the different parts of your LEGO creation, making sure that everything is working and placed correctly.
Not LEGO blocks, but software programs and the real-world devices they run on, are the subject of our discussion. To ensure correct operation, scalability in response to changing conditions, and availability in the case of a computer breakdown, Kubernetes helps with the administration of these applications.