Skip to content

Instantly share code, notes, and snippets.

@timroster
Last active February 2, 2021 02:39
Show Gist options
  • Save timroster/7eb49e14495347f5d5d5a7cbd5d959fd to your computer and use it in GitHub Desktop.
Save timroster/7eb49e14495347f5d5d5a7cbd5d959fd to your computer and use it in GitHub Desktop.
Short script to recover etcd on crc when it gets misconfigured
#!/bin/sh
# address CRC issues like: https://github.com/code-ready/crc/issues/1888
# run this script from the crc vm - something like (switch to id_rsa on crc <= 1.20):
# scp -i ~/.crc/machines/crc/id_ecdsa fixcrc.sh core@192.168.130.11:fixcrc.sh
# ssh -i ~/.crc/machines/crc/id_ecdsa core@192.168.130.11 "chmod +x ./fixcrc.sh ; sudo ./fixcrc.sh"
ETCD_POD_DIR=$(ls -rt /etc/kubernetes/static-pod-resources | grep etc | tail -1)
sed -i 's/192.168.130.11/192.168.126.11/g' /etc/kubernetes/manifests/etcd-pod.yaml
sed -i 's/192.168.130.11/192.168.126.11/g' /etc/kubernetes/static-pod-resources/$ETCD_POD_DIR/configmaps/etcd-pod/pod.yaml
sed -i 's/192.168.130.11/192.168.126.11/g' /etc/kubernetes/static-pod-resources/$ETCD_POD_DIR/etcd-pod.yaml
echo "restarting kubelet..."
systemctl restart kubelet
echo "loop for crc node to become ready..."
while KUBECONFIG=/opt/kubeconfig kubectl get nodes | grep --silent Ready ; [ $? -ne 0 ] ; do
echo "still not ready waiting 20 seconds"
sleep 20
done
echo "crc node is coming back online, use 'crc status' to follow"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment