Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ialidzhikov/b8056130ebb3dbeb8de4979f0a9073d6 to your computer and use it in GitHub Desktop.

Select an option

Save ialidzhikov/b8056130ebb3dbeb8de4979f0a9073d6 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
TMP_DIR=$(mktemp -d -t run-XXXXXXXXXX)
echo "TMP_DIR=$TMP_DIR"
SHOOTS=$(kubectl -n garden get shoots -o json | jq -r '.items[] | select(.status.hibernated == false) | .metadata.namespace + "," + .metadata.name')
for SHOOT in $SHOOTS
do
sleep 1s
echo "> Checking $SHOOT"
TOKENS=(${SHOOT//,/ })
NAMESPACE=${TOKENS[0]}
NAME=${TOKENS[1]}
kubectl -n $NAMESPACE get secret $NAME.kubeconfig -o jsonpath='{.data.kubeconfig}' | base64 -d > $TMP_DIR/$NAME.yaml
echo "Checking..."
OUTPUT=$(kubectl --kubeconfig=$TMP_DIR/$NAME.yaml get mr -A --field-selector metadata.name=extension-controlplane-shoot -o json | jq '.items[].status | select(.resources != null) | .resources[] | select(.kind == "CustomResourceDefinition")')
echo "OUTPUT=$OUTPUT"
if [ -n "$OUTPUT" ]
then
echo "Found output - $OUTPUT!"
exit 1
fi
done
rm -rf $TMP_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment