kubectl rollout status for ALL deployments in a namespace

9/20/2019

I have a number of deployment objects in my namespace. I'd like to run kubectl rollout status for all of them at the same time. So, I'd like the command to exit, only when all rollouts are complete, or an error has occurred. How can I achieve that?

The only thing I got with so far is:

kubectl get deploy -o name | xargs -n1 -t kubectl rollout status

But I hope there's something smarter.

-- LIvanov
kubernetes
rollout

2 Answers

9/20/2019

You can use this simple check:

#!/bin/bash
deploy=$(kubectl get deploy -o name)
for i in $deploy; do kubectl rollout status $i -w --timeout=30s; done

You can also build more advanced script using clues in this post.

-- Hanx
Source: StackOverflow

9/23/2019

So I guess what I came up is the best there is.

kubectl get deploy --output name | \
  timeout -t 300 \
    xargs -n1 -t \
      kubectl rollout status
-- LIvanov
Source: StackOverflow