Is there a way in kubernetes to wait on daemonset ready

9/27/2018

I'm not sure if there is a ready condition in DaemonSet. By that, I mean all pods owned by that DaemonSet are ready.

I'm aware of kubectl wait, but it seems can not check the readiness of DaemonSet.

-- xudifsd
kubernetes

2 Answers

9/27/2018

I would suggest to get pods from your DaemonSet by using following command:

kubectl get pods -l <daemonset-selector-key>=<daemonset-selector-value>

And then check status of those pods in loop looking if they are ready.

-- Jakub Bujny
Source: StackOverflow

4/29/2020

Try this out

function wait-for-daemonset(){
    retries=10
    while [[ $retries -ge 0 ]];do
        sleep 3
        ready=$(kubectl -n $1 get daemonset $2 -o jsonpath="{.status.numberReady}")
        required=$(kubectl -n $1 get daemonset $2 -o jsonpath="{.status.desiredNumberScheduled}")
        if [[ $ready -eq $required ]];then
            #echo "Succeeded"
            break
        fi
        ((retries--))
    done
}
-- Anup Ash
Source: StackOverflow