Tuesday, June 21, 2022

How to Restart the pods in Kubernetes

A pod is a collection of containers sharing a network, acting as the basic unit of deployment in Kubernetes. All containers in a pod are scheduled on the same node.

1: kubectl scale

Scale the number of replicas using the kubectl command scale and set the replicas flag to zero:

kubectl scale deployment <deployment_name> --replicas=0 -n <namespace>

Scale the number of replicas using the kubectl command scale and set the replicas flag to its original value:

kubectl scale deployment <deployment_name> --replicas=2 -n <namespace>


2: kubectl rollout restart

kubectl rollout restart deployment <deployment_name> -n <namespace>


3: kubectl delete pod

It will automatically recreate the pod to keep it consistent with the expected one.

kubectl delete pod <pod_name> -n <namespace>


No comments:

Post a Comment

Create Kubernetes ClusterIP Service Definition using YAML

A ClusterIP service is the default Kubernetes service. It gives you a service inside your cluster that other apps/pods inside your cluster c...