|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +RELEASE_NAME="${1}" |
| 6 | +NAMESPACE="${2:-capop-system}" |
| 7 | +LIMIT="${3:-3600}" |
| 8 | + |
| 9 | +GO_TEMPLATE=' |
| 10 | + {{- range .items -}} |
| 11 | + {{- if eq .kind "Cluster" -}} |
| 12 | + {{- if ne .status.phase "Provisioned" }}0{{- end }} |
| 13 | + {{- if not .status.controlPlaneReady }}0{{- end }} |
| 14 | + {{- if not .status.infrastructureReady }}0{{- end }} |
| 15 | + {{- end -}} |
| 16 | + {{- if eq .kind "K3SCluster" -}} |
| 17 | + {{- if ne .status.phase "Provisioned" }}0{{- end }} |
| 18 | + {{- if not .status.ready }}0{{- end }} |
| 19 | + {{- end -}} |
| 20 | + {{- if eq .kind "K3SControlPlane" -}} |
| 21 | + {{- if ne .status.phase "Provisioned" }}0{{- end }} |
| 22 | + {{- if not .status.ready }}0{{- end }} |
| 23 | + {{- if not .status.initialized }}0{{- end }} |
| 24 | + {{- end -}} |
| 25 | + {{- if eq .kind "K3SRemoteMachine" -}} |
| 26 | + {{- if ne .status.phase "Installed" }}0{{- end }} |
| 27 | + {{- if not .status.ready }}0{{- end -}} |
| 28 | + {{- end -}} |
| 29 | + {{- if eq .kind "Machine" -}} |
| 30 | + {{- if ne .status.phase "Running" }}0{{- end }} |
| 31 | + {{- if not .status.bootstrapReady }}0{{- end }} |
| 32 | + {{- if not .status.infrastructureReady }}0{{- end }} |
| 33 | + {{- end -}} |
| 34 | + {{- end -}} |
| 35 | +' |
| 36 | + |
| 37 | +COUNT=1 |
| 38 | +while true; do |
| 39 | + STATUS="$(kubectl --namespace "${NAMESPACE}" get cluster-api \ |
| 40 | + --selector "app.kubernetes.io/instance=${RELEASE_NAME}" \ |
| 41 | + --output "go-template=${GO_TEMPLATE}")" |
| 42 | + if [[ "${STATUS}" != "" && "${COUNT}" -le "${LIMIT}" ]]; then |
| 43 | + sleep 1 |
| 44 | + ((++COUNT)) |
| 45 | + elif [[ "${COUNT}" -gt "${LIMIT}" ]]; then |
| 46 | + >2& echo "Limit exceeded." |
| 47 | + exit 1 |
| 48 | + else |
| 49 | + echo |
| 50 | + kubectl --namespace "${NAMESPACE}" get cluster-api --selector "app.kubernetes.io/instance=${RELEASE_NAME}" |
| 51 | + break |
| 52 | + fi |
| 53 | +done |
0 commit comments