Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save germainlefebvre4/5753cd6f14cc3a37face2c790f481617 to your computer and use it in GitHub Desktop.
Save germainlefebvre4/5753cd6f14cc3a37face2c790f481617 to your computer and use it in GitHub Desktop.
#!/usr/bin/python2
import subprocess
from time import sleep
APP_NAME="app-python"
APP_VERSION="v1"
# Get current pods
COMMAND="kubectl get pods | grep %s | awk '{print $1}'" % (APP_NAME)
pods_old = subprocess.check_output(COMMAND, shell=True)[:-1].split("\n")
print(pods_old)
# Apply changes
COMMAND="kubectl apply -f %s.yaml" % APP_VERSION
kube_apply=subprocess.check_output(COMMAND, shell=True)
print(kube_apply)
sleep(5)
COMMAND="kubectl get pods | grep %s | awk '{print $1}'" % (APP_NAME)
pods = subprocess.check_output(COMMAND, shell=True)[:-1].split("\n")
print(pods)
pods_new = [item for item in pods if item not in pods_old]
print(pods_new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment