Skip to content

Commit 5a19182

Browse files
committed
fix: Implement two-phase deployment for ExaMon, enhancing reliability with a wait loop for K8ssandra operator webhook readiness and improved Helm upgrade commands.
1 parent f04deb9 commit 5a19182

1 file changed

Lines changed: 33 additions & 8 deletions

File tree

scripts/k8s-local-setup.sh

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ echo "==> Updating Helm chart dependencies..."
8383
cd "${REPO_ROOT}/deploy/helm/examon"
8484
helm dependency update
8585

86-
# Deploy ExaMon (k8ssandra-operator is installed as part of the umbrella chart)
86+
# Deploy ExaMon using a two-phase approach:
87+
# Phase 1: deploy the K8ssandra operator (and Grafana, Mosquitto) but skip
88+
# the K8ssandraCluster CR. The operator's validating webhook must
89+
# be ready before the CR is submitted.
90+
# Phase 2: enable the CR (and remaining services) via helm upgrade.
8791
echo "==> Deploying ExaMon with local values..."
8892
kubectl create namespace "${NAMESPACE}" 2>/dev/null || true
8993

@@ -94,14 +98,35 @@ if [[ -f "$SECRET_FILE" ]]; then
9498
HELM_SET_ARGS+=(-f "$SECRET_FILE")
9599
fi
96100

97-
helm upgrade --install examon "${REPO_ROOT}/deploy/helm/examon" \
98-
-f "${REPO_ROOT}/deploy/helm/examon/values-local.yaml" \
99-
"${HELM_SET_ARGS[@]+"${HELM_SET_ARGS[@]}"}" \
100-
-n "${NAMESPACE}" --wait --timeout 10m
101+
CHART="${REPO_ROOT}/deploy/helm/examon"
102+
VALUES=(-f "${REPO_ROOT}/deploy/helm/examon/values-local.yaml" "${HELM_SET_ARGS[@]+"${HELM_SET_ARGS[@]}"}")
103+
104+
echo " Phase 1: deploying operator and independent services..."
105+
helm upgrade --install examon "$CHART" \
106+
"${VALUES[@]}" \
107+
--set cassandra.createCluster=false \
108+
-n "${NAMESPACE}" --wait --timeout 5m
109+
110+
echo " Waiting for K8ssandra operator webhook..."
111+
for i in $(seq 1 60); do
112+
EP=$(kubectl get endpoints examon-k8ssandra-operator-webhook-service \
113+
-n "${NAMESPACE}" -o jsonpath='{.subsets[0].addresses[0].ip}' 2>/dev/null || true)
114+
if [[ -n "$EP" ]]; then
115+
echo " Webhook endpoint ready at $EP."
116+
break
117+
fi
118+
if [[ $i -eq 60 ]]; then
119+
echo "ERROR: K8ssandra webhook did not become ready in 5 minutes."
120+
kubectl get endpoints -n "${NAMESPACE}"
121+
exit 1
122+
fi
123+
sleep 5
124+
done
101125

102-
# Cassandra credentials: examon-server and kairosdb read them automatically
103-
# from the K8ssandra-generated secret (examon-cassandra-superuser) via
104-
# secretKeyRef env vars. No second helm upgrade is needed.
126+
echo " Phase 2: deploying full stack (Cassandra + all services)..."
127+
helm upgrade examon "$CHART" \
128+
"${VALUES[@]}" \
129+
-n "${NAMESPACE}" --wait --timeout 10m
105130

106131
echo ""
107132
echo "=== ExaMon local deployment complete! ==="

0 commit comments

Comments
 (0)