Created
June 12, 2019 16:12
-
-
Save germainlefebvre4/5753cd6f14cc3a37face2c790f481617 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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