diff --git a/bin/aws-cluster-postsync-hook.sh b/bin/aws-cluster-postsync-hook.sh new file mode 100755 index 0000000..ff5cb86 --- /dev/null +++ b/bin/aws-cluster-postsync-hook.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -e + +RELEASE_NAME="${1}" +NAMESPACE="${2:-aws}" +LIMIT="${3:-1200}" + +GO_TEMPLATE=' + {{- range .items -}} + {{- if eq .kind "Cluster" -}} + {{- if ne .status.phase "Provisioned" }}0{{- end }} + {{- if not .status.controlPlaneReady }}0{{- end }} + {{- if not .status.infrastructureReady }}0{{- end }} + {{- end -}} + {{- if eq .kind "AWSManagedCluster" -}} + {{- if not .status.ready }}0{{- end }} + {{- end -}} + {{- if eq .kind "AWSManagedControlPlane" -}} + {{- if not .status.ready }}0{{- end }} + {{- if not .status.initialized }}0{{- end }} + {{- end -}} + {{- if eq .kind "AWSManagedMachinePool" -}} + {{- if not .status.ready }}0{{- end -}} + {{- end -}} + {{- if eq .kind "MachinePool" -}} + {{- if ne .status.phase "Running" }}0{{- end }} + {{- if not .status.bootstrapReady }}0{{- end }} + {{- if not .status.infrastructureReady }}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/aws-cluster-uninstall-hook.sh b/bin/aws-cluster-uninstall-hook.sh new file mode 100755 index 0000000..a717433 --- /dev/null +++ b/bin/aws-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}" diff --git a/bin/azure-cluster-postsync-hook.sh b/bin/azure-cluster-postsync-hook.sh index 4c8aa7e..519889b 100755 --- a/bin/azure-cluster-postsync-hook.sh +++ b/bin/azure-cluster-postsync-hook.sh @@ -10,6 +10,8 @@ GO_TEMPLATE=' {{- range .items -}} {{- if eq .kind "Cluster" -}} {{- if ne .status.phase "Provisioned" }}0{{- end }} + {{- if not .status.controlPlaneReady }}0{{- end }} + {{- if not .status.infrastructureReady }}0{{- end }} {{- end -}} {{- if eq .kind "AzureManagedCluster" -}} {{- if not .status.ready }}0{{- end }} @@ -21,6 +23,11 @@ GO_TEMPLATE=' {{- if eq .kind "AzureManagedMachinePool" -}} {{- if not .status.ready }}0{{- end -}} {{- end -}} + {{- if eq .kind "MachinePool" -}} + {{- if ne .status.phase "Running" }}0{{- end }} + {{- if not .status.bootstrapReady }}0{{- end }} + {{- if not .status.infrastructureReady }}0{{- end }} + {{- end -}} {{- end -}} ' diff --git a/bin/azure-cluster-presync-hook.sh b/bin/azure-cluster-presync-hook.sh deleted file mode 100755 index 45b64da..0000000 --- a/bin/azure-cluster-presync-hook.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/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