kubernetesamazon-eksdaemonset

How to do a rolling restart of daemonset in K8


I have a K8 cluster with daemonset. In the daemonset manifest, the container image is configured with <image_name>:latest . How can I do a rolling update of my daemonset when I have a new image in the image_registry.

I know that if the image version is used, I could have changed the image version and K8 will do a rolling restart with

kubectl edit ds/<my_dn_name> -n my_ns

In my case, I am using :latest. so there is no change for me to do in the manifest file.

I can delete the daemonset pod, so that it will get re-created with new image. But I am looking for rolling restart/update option

updateStrategy.type is configured as "RollingUpdate"


Solution

  • You need to set imagePullPolicy: Always in your pod spec. using kubectl edit ds my-ds

    or

    kubectl patch ds my-ds -p '{"spec": {"template": {"spec":{"containers":[{"name": "xxxxxxx", "imagePullPolicy":"Always"}]}}}}'
    

    then you can use:

    kubectl rollout restart ds my-ds

    and use

    kubectl rollout status ds my-ds to watch the procedure.