Kubernetes restart daemonset - kubectl | Devops Junction

In this quick article, let us learn how to restart the Kubernetes DaemonSet and all the pods created by the DaemonSet.

Before we move on to the objective, here are some basics. real quick.

DaemonSet is to deploy a specific application/feature to your Kubernetes cluster and to make sure it is available to all the nodes currently running and for those going to be added in future by cluster auto scaler or Karpenter

Some examples of DaemonSet are.

  • running a cluster storage daemon on every node - EFS Driver, CSI driver
  • running a logs collection daemon on every node - FluentD, DataDog, Splunk
  • running a node monitoring daemon on every node - Nodeexporter, Telegraf

Now it's time for the objective.

List the daemonset

First, let us take a quick look at how many Daemonsets we are having in our cluster

kubectl deaemonset restart

As you can see, we are listing all the Daemonsets in our cluster using the following command

kubectl get -A daemonset

-A is to list DaemonSets across all namespaces.

How to restart a Kubernetes daemonset

You can use the kubectl rollout restart command to restart the DaemonSet. Here is an example of how it works in real-time.

As you could have noticed in our previous listing screenshot. I have a datadog daemonset installed, for log collection and host monitoring.

Now let us restart the daemonset and see how it goes.

This is the command we are going to use to restart the datadog daemonset running in my cluster on the default namespace

kubectl rollout restart daemonset datadog -n default

I have created a terminal record of me doing a daemonset restart at my end

 

Check the progress of kubectl rollout restart

When we have executed the kubectl rollout restart command to restart the daemonset, we got the message it is restarted

But it actually takes a while before it can replace all the running pods with a new one.

To see the actual status and to stay updated on the status of how the restart is going on.

there is a kubectl command we can use to see the progress of rollout restart

kubectl rollout status ds/datadog -n default

Here is a screenshot  of this command while executed at my end

kubectl restart daemonset

Hope this helps

Access our other Kubernetes articles here

 

Cheers
Sarav AK

Follow me on Linkedin My Profile
Follow DevopsJunction onFacebook orTwitter
For more practical videos and tutorials. Subscribe to our channel

Buy Me a Coffee at ko-fi.com

Signup for Exclusive "Subscriber-only" Content

Loading