Skip to content

Instantly share code, notes, and snippets.

@jakefhyde
Last active November 7, 2023 05:52
Show Gist options
  • Select an option

  • Save jakefhyde/d0ae3a46dbc6e9d30b9b14d8056ac206 to your computer and use it in GitHub Desktop.

Select an option

Save jakefhyde/d0ae3a46dbc6e9d30b9b14d8056ac206 to your computer and use it in GitHub Desktop.
Simulate user-node-remove issues before an upgrade
#!/bin/bash
PATCH=NO
NAMESPACE=$1
NODE=$2
NODEJSON=$(kubectl get -n $NAMESPACE node.management.cattle.io $NODE -o json)
echo $NODEJSON | jq -r '.metadata.finalizers += ["clusterscoped.controller.cattle.io/user-node-remove_abcde"]' | jq -r '.metadata.annotations += { cleanup.cattle.io/user-node-remove: null }' > node-0.json
cat node-0.json
echo "About to add old finalizer and remove annotation from node $NODE in namespace $NAMESPACE. Ready? If so, enter YES"
read -e PATCH
if [ "$PATCH" != "YES" ]; then
echo "Not modifying node."
exit 1
fi
PATCH=NO
kubectl apply -f node-0.yaml
echo "About to add delete node $NODE in namespace $NAMESPACE. Ready? If so, enter YES"
read -e PATCH
if [ "$PATCH" != "YES" ]; then
echo "Not deleting node."
exit 1
fi
kubectl delete node -n $NAMESPACE $NODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment