Skip to content

Instantly share code, notes, and snippets.

@chrislovecnm
Created February 24, 2017 21:01
Show Gist options
  • Save chrislovecnm/1cfc617aa0ab0258c14f5abfbcc2447e to your computer and use it in GitHub Desktop.
Save chrislovecnm/1cfc617aa0ab0258c14f5abfbcc2447e to your computer and use it in GitHub Desktop.
Testing rolling-updates
#!/bin/bash
set -x
export KOPS_STATE_STORE=s3://oscar-ai-k8s-dev
export KOPS_FEATURE_FLAGS="+DrainAndValidateRollingUpdate"
if [ "$#" -ne 1 ]; then
echo "please pass the yaml file as a command line arg"
exit 1
fi
KOPS_FILE=$1
CLUSTER_NAME=$(head -n 10 $KOPS_FILE | grep name | awk '{ print $2 }')
sed -i '' 's/1.5.3/1.5.2/' $KOPS_FILE
kops delete cluster $CLUSTER_NAME --yes
kops create -f $KOPS_FILE
kops create secret --name $CLUSTER_NAME sshpublickey admin -i ~/.ssh/id_rsa.pub
kops update cluster $CLUSTER_NAME --yes
until kops validate cluster $CLUSTER_NAME
do
echo "Cluster did not validate"
sleep 8
done
kubectl create -f $HOME/Workspace/src/k8s.io/kubernetes/examples/guestbook-go
kubectl scale --replicas 10 rc/guestbook
kubectl create -f $HOME/Workspace/src/k8s.io/kubernetes/examples/storage/cassandra/cassandra-service.yaml
kubectl create -f $HOME/Workspace/src/k8s.io/kubernetes/examples/storage/cassandra/cassandra-statefulset.yaml
while true; do
status=$(kubectl get po cassandra-4 -o json | jq -j '.status.phase')
if [ $status == "Running" ]; then
echo "Cassandra found pod"
break
fi
sleep 8
done
sed -i '' 's/1.5.2/1.5.3/' $KOPS_FILE
kops replace -f $KOPS_FILE
kops update cluster $CLUSTER_NAME --yes
kops rolling-update cluster $CLUSTER_NAME --yes -v 4
kops validate cluster $CLUSTER_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment