diff --git a/bin/azure-cluster-postsync-hook.sh b/bin/azure-cluster-postsync-hook.sh new file mode 100755 index 0000000..3d8ca53 --- /dev/null +++ b/bin/azure-cluster-postsync-hook.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +set -e + +RELEASE_NAME="${1}" +NAMESPACE="${2:-azure}" + +LIMIT=1200 + +GO_TEMPLATE=' + {{- range .items -}} + {{- if eq .kind "Cluster" -}} + {{- if ne .status.phase "Provisioned" }}0{{- end }} + {{- end -}} + {{- if eq .kind "AzureManagedCluster" -}} + {{- if not .status.ready }}0{{- end }} + {{- end -}} + {{- if eq .kind "AzureManagedControlPlane" -}} + {{- if not .status.ready }}0{{- end }} + {{- if not .status.initialized }}0{{- end }} + {{- end -}} + {{- if eq .kind "AzureManagedMachinePool" -}} + {{- if not .status.ready }}0{{- end -}} + {{- end -}} + {{- end -}} +' + +COUNT=1 +while true; do + STATUS="$(kubectl --namespace "${NAMESPACE}" get cluster-api \ + --selector "app.kubernetes.io/instance=${RELEASE_NAME}" \ + --output "go-template=${GO_TEMPLATE}")" + if [[ "${STATUS}" != "" && "${COUNT}" -le "${LIMIT}" ]]; then + sleep 1 + ((++COUNT)) + elif [[ "${COUNT}" -gt "${LIMIT}" ]]; then + >2& echo "Limit exceeded." + exit 1 + else + echo + kubectl --namespace "${NAMESPACE}" get cluster-api --selector "app.kubernetes.io/instance=${RELEASE_NAME}" + break + fi +done diff --git a/bin/azure-cluster-presync-hook.sh b/bin/azure-cluster-presync-hook.sh new file mode 100755 index 0000000..45b64da --- /dev/null +++ b/bin/azure-cluster-presync-hook.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e + +# Cluster-api settings +export EXP_AKS=true +export EXP_MACHINE_POOL=true +export EXP_CLUSTER_RESOURCE_SET=false + +clusterctl init --infrastructure azure --wait-providers diff --git a/bin/azure-cluster-uninstall-hook.sh b/bin/azure-cluster-uninstall-hook.sh new file mode 100755 index 0000000..a717433 --- /dev/null +++ b/bin/azure-cluster-uninstall-hook.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +CLUSTER_NAME="${1}" +NAMESPACE="${2}" +WAIT_FOR_CLUSTER_DELETION="${3:-false}" + +kubectl --namespace "${NAMESPACE}" delete cluster "${CLUSTER_NAME}" "--wait=${WAIT_FOR_CLUSTER_DELETION}"