Skip to content

Instantly share code, notes, and snippets.

@robkooper
Created October 24, 2022 14:21
Show Gist options
  • Save robkooper/52674b186ad97f0fe9c3355dc2836bdd to your computer and use it in GitHub Desktop.
Save robkooper/52674b186ad97f0fe9c3355dc2836bdd to your computer and use it in GitHub Desktop.
convert kube cluster from m1 to gp flavors
#!/bin/bash
. ~/Work/radiant/openstack.sh
export OS_CLOUD=cinet
kubectx cinet
for n in $(kubectl get no | awk '/controlplane/ { print $1}'); do
echo "-- $n"
FLAVOR=$(openstack server show $n | awk '/flavor/ { print $4}')
NEW_FLAVOR=$(echo $FLAVOR | sed 's/m1/gp/')
if [ "$FLAVOR" != "$NEW_FLAVOR" ]; then
echo "Resize $FLAVOR -> $NEW_FLAVOR"
kubectl drain --ignore-daemonsets --delete-emptydir-data $n
ssh $n 'sudo yum -y update'
openstack server resize --flavor $NEW_FLAVOR $n
while [ "$(openstack server show $n | awk '/ status / { print $4 }')" != "VERIFY_RESIZE" ]; do
sleep 1
done
openstack server resize confirm $n
while [ "$(openstack server show $n | awk '/ status / { print $4 }')" != "ACTIVE" ]; do
sleep 1
done
kubectl uncordon $n
sleep 10
fi
done
for n in $(kubectl get no | awk '/worker/ { print $1}'); do
echo "-- $n"
FLAVOR=$(openstack server show $n | awk '/flavor/ { print $4}')
NEW_FLAVOR=$(echo $FLAVOR | sed 's/m1/gp/')
if [ "$FLAVOR" != "$NEW_FLAVOR" ]; then
echo "Resize $FLAVOR -> $NEW_FLAVOR"
kubectl drain --ignore-daemonsets --delete-emptydir-data $n
ssh $n 'sudo yum -y update'
openstack server resize --flavor $NEW_FLAVOR $n
while [ "$(openstack server show $n | awk '/ status / { print $4 }')" != "VERIFY_RESIZE" ]; do
sleep 1
done
openstack server resize confirm $n
while [ "$(openstack server show $n | awk '/ status / { print $4 }')" != "ACTIVE" ]; do
sleep 1
done
kubectl uncordon $n
sleep 10
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment