Skip to content

Instantly share code, notes, and snippets.

@heim
Last active January 24, 2017 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heim/3881e4c62a01f17255f9 to your computer and use it in GitHub Desktop.
Save heim/3881e4c62a01f17255f9 to your computer and use it in GitHub Desktop.
#! /bin/bash
_container=$1
cat > controller.yaml <<EOF
---
kind: ReplicationController
apiVersion: v1
metadata:
name: some-app
spec:
replicas: 1
selector:
app: some-app
template:
metadata:
labels:
app: some-app
spec:
containers:
- name: some-app
imagePullPolicy: Always
image: $_image
EOF
#auth kubernetes
#check dependencies
_image="path-to-image:$_sha"
./create-rc.sh $_image
kubectl get rc some-app > /dev/null 2>&1;
if [ $? -ne 0 ]; then
echo "Replication controller does not exist, creating.";
kubectl create -f controller.yaml;
else
echo "Updating rc and performing rolling update";
kubectl apply -f controller.yaml;
sleep 2;
kubectl rolling-update some-app --image=$_image --update-period=30s --timeout=1m30s;
if [ $? -ne 0 ]; then
echo "Could not perform rolling update"
exit 1;
fi;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment