fix(kubernetes): bound init wait and reword fail-fast message

Cap the wait-for-kubeconfig init container at 20m. If Kamaji genuinely
fails to produce the admin-kubeconfig Secret (misconfigured tenant,
etcd outage after the guard already passed, Kamaji crash-loop), the
pod now exits non-zero and goes CrashLoopBackOff so the failure is
visible in dashboards, instead of silently sleeping in Init forever
and leaving only the flux helm-wait timeout to surface the problem.

Reword the etcd DataStore guard to reference the parent Tenant
application's etcd flag (not .Values.etcd of the Kubernetes chart,
which is a different chart). Update the helm unittest errorPattern
accordingly.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin 2026-04-16 20:55:17 +03:00
parent 97696b2b03
commit 6afc0eb370
No known key found for this signature in database
GPG key ID: 7988329FDF395282
5 changed files with 17 additions and 2 deletions

View file

@ -31,7 +31,12 @@ spec:
- -c
- |
set -eu
deadline=$(( $(date +%s) + 1200 ))
until [ -s /etc/kubernetes/kubeconfig/super-admin.svc ]; do
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "admin kubeconfig was not provisioned within 20m; exiting so the pod goes CrashLoopBackOff and surfaces in dashboards" >&2
exit 1
fi
echo "waiting for admin kubeconfig to be provisioned by Kamaji..."
sleep 5
done

View file

@ -1,6 +1,6 @@
{{- $etcd := .Values._namespace.etcd }}
{{- if not $etcd }}
{{- fail "Kubernetes tenant requires a parent tenant with etcd enabled: set .Values.etcd=true on tenant-root (or any ancestor tenant), wait for the etcd HelmRelease to reconcile (DataStore CR appears in the tenant namespace), then retry." }}
{{- fail "Kubernetes tenant requires a parent Tenant application with etcd: true so the etcd module deploys a DataStore CR in the tenant namespace. Set spec.etcd: true on the root Tenant (or any ancestor Tenant), wait for the etcd HelmRelease to reconcile and the DataStore CR to appear, then retry." }}
{{- end }}
{{- $ingress := .Values._namespace.ingress }}
{{- $host := .Values._namespace.host }}

View file

@ -32,7 +32,12 @@ spec:
- -c
- |
set -eu
deadline=$(( $(date +%s) + 1200 ))
until [ -s /etc/kubernetes/kubeconfig/super-admin.svc ]; do
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "admin kubeconfig was not provisioned within 20m; exiting so the pod goes CrashLoopBackOff and surfaces in dashboards" >&2
exit 1
fi
echo "waiting for admin kubeconfig to be provisioned by Kamaji..."
sleep 5
done

View file

@ -30,7 +30,12 @@ spec:
- -c
- |
set -eu
deadline=$(( $(date +%s) + 1200 ))
until [ -s /etc/kubernetes/kubeconfig/super-admin.svc ]; do
if [ "$(date +%s)" -ge "$deadline" ]; then
echo "admin kubeconfig was not provisioned within 20m; exiting so the pod goes CrashLoopBackOff and surfaces in dashboards" >&2
exit 1
fi
echo "waiting for admin kubeconfig to be provisioned by Kamaji..."
sleep 5
done

View file

@ -116,4 +116,4 @@ tests:
host: ""
asserts:
- failedTemplate:
errorPattern: "requires a parent tenant with etcd enabled"
errorPattern: "requires a parent Tenant application with etcd: true"