Skip to content

Instantly share code, notes, and snippets.

@pguelpa
Created December 5, 2014 19:49
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 pguelpa/0acc85530bd8722b89bb to your computer and use it in GitHub Desktop.
Save pguelpa/0acc85530bd8722b89bb to your computer and use it in GitHub Desktop.
Upgrade a Deis cluster that doesn't use the standard database or cache
#!/bin/bash -ue
#
# Rolling upgrade procedure
#
if test $# -lt 1; then
echo "Usage:"
echo " upgrade-deis seed-ip [number-of-routers]"
echo " by default the number-of-routers is 3"
echo ""
echo "Examples:"
echo " upgrade-deis 10.12.1.113"
echo " upgrade-deis 10.12.1.113 5"
exit 1
fi
export FLEETCTL_TUNNEL=$1
export DEISCTL_TUNNEL=$FLEETCTL_TUNNEL
VERSION=v1.0.2
NUM_ROUTERS=${2-3}
NON_CRITICAL_COMPONENTS="store-monitor store-daemon store-metadata store-gateway store-volume logger logspout registry controller builder"
#
# Update Units
#
echo 'Refreshing units'
deisctl refresh-units
#
# Shut down non-critical components
#
echo 'Uninstalling non-critical components'
echo $NON_CRITICAL_COMPONENTS | xargs -n 1 deisctl stop
echo $NON_CRITICAL_COMPONENTS | xargs -n 1 deisctl uninstall
#
# Set new version
#
echo "Setting version to ${VERSION}"
deisctl config platform set version=$VERSION
#
# Start non-critical components
#
echo 'Installing non-critical components'
echo $NON_CRITICAL_COMPONENTS | xargs -n 1 deisctl install
echo $NON_CRITICAL_COMPONENTS | xargs -n 1 deisctl start
#
# Roll the critical components
#
echo 'Pulling latest publisher container'
for server in $(fleetctl list-machines -fields=ip -no-legend=true); do
ssh core@${server} 'docker pull $(/run/deis/bin/get_image /deis/publisher); docker pull $(/run/deis/bin/get_image /deis/router)'
done
echo 'Uninstalling publisher'
deisctl stop publisher && deisctl uninstall publisher
echo 'Installing publisher'
deisctl install publisher && deisctl start publisher
for i in $(seq 1 $NUM_ROUTERS); do
echo "Uninstalling router ${i}"
deisctl stop router@${i} && deisctl uninstall router@${i}
echo "Installing router ${i}"
deisctl install router@${i} && deisctl start router@${i}
done
echo 'Complete'
@JamesAwesome
Copy link

Forgot to mention this: On line 32 deisctl refresh-units should take the option -t $VERSION else it may update the unit files past the deis version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment