Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kubectl rollout status for ALL deployments in a namespace

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.

like image 540
LIvanov Avatar asked Sep 20 '19 07:09

LIvanov


2 Answers

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.

like image 134
Mark Avatar answered Nov 15 '22 07:11

Mark


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
like image 38
LIvanov Avatar answered Nov 15 '22 08:11

LIvanov