Skip to content

Instantly share code, notes, and snippets.

@samuelb
Last active October 1, 2019 07:33
Show Gist options
  • Save samuelb/4b8c0c6337ba0bea9b633e913ad39996 to your computer and use it in GitHub Desktop.
Save samuelb/4b8c0c6337ba0bea9b633e913ad39996 to your computer and use it in GitHub Desktop.
PoC - Wait for helm `install/update` deployments to be finished. Takes `helm template ...` from stdin.
#!/usr/bin/env python3
""" Usage: helm template ... | python thisscript.py """
import sys
import yaml
import subprocess
docs = yaml.load_all(sys.stdin, Loader=yaml.Loader)
# get all objects names of kind Deployment, DaemonSet, StatefulSet
for doc in docs:
if doc['kind'].lower() in ('deployment', 'daemonset', 'statefulset'):
# call `kubectl rollout status` for each. It will block util the rollout is finished.
subprocess.call(['kubectl', 'rollout', 'status', doc['kind'], doc['metadata']['name']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment