Restart pods in Kubernetes.

Pods are the smallest deployable units in Kubernetes. A Pod  is a group of one or more containers that has shared storage and network resources. They are always setup in such way that they are always co-located and co-scheduled, and run in a shared context.

How To To Restart Pods In Kubernetes

This tutorial is for you if you are looking to restart pods in Kubernotes. Follow the given instruction so that you can get the ideas about the restarting process.

Run the minikube cluster by using the following command.

minikube start

Now run the following commands so that you can  list out the available pods.

 kubectl get pods

Run the following command to create a deployment and before that build a configuration file for deployment with the following command. The file will be created in your home directory.

touch deployment.YAML

With the following kubectl command,  you can create the deployment:

kubectl create –f deployment.yaml

Method 1

Restart Pods In Kubernetes

Run the following command to restart the pod.

kubectl rollout restart deployment deployment_name

Method 2

Run the following command to restart the pod. In this method, you can force the pod to restart with the modifications made by setting or changing an environment variable

kubectl set env  deployment deployment-name DEPLOY_DATE "< $(date) "

Just in case if you want to delete Kubernotes then:

Kubernetes is an open-source container that is used for automating containerized software deployment, scaling, and management. In this Kubernetes tutorial post, we are going to show you the multiple methods to delete the Kubernetes deployment.

Bonus:

How to delete Kubernetes Deployment

If you are using Kubernetes regularly for the deployment of your containerized application then deleting Kubernetes deployment is a regular job. You can easily delete the deployments.

You can run the following command to delete the Kubernetes deployment:

kubectl delete deployment deployment-name

What if you don’t know the Kubernetes deployment name?

Run the following command to know the Kubernetes deployment name.

kubectl get deployments

You will see the output something like this:

NAME     READY   UP-TO-DATE   AVAILABLE   AGE
itsubuntu-dep   4/4     4            4           52m05s

Easily delete your Kubernetes deployment:

kubectl delete deployments itsubuntu-dep

What if you want to delete Kubernetes Deployment from a specific namespace?

Don’t worry about this too as we will guide you through the process of deleting Kubernetes deployment from the namespace. You can list all the deployments from all the namespaces with the following command:

kubectl get deployments --all-namespaces

Now, you can easily delete the Kubernetes deployment from the specified namespace.

For example:

kubectl delete deployments --namespace=testapps testapps-dep
deployment.apps "testapps-dep" deleted

What if you want to delete the multiple deployments in Kuberntes?

Run the following command to delete multiple deployments

kubectl delete deployment its-dep its-dep-2 --namespace=default

Leave a comment

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