Repository navigation
Description
Mesh-wide outage: expired SPIRE workload SVIDs make all gateway-routed services return HTTP 503 (localtest.me URLs unreachable)
Summary
On a long-running Kind cluster (~27h old), every service exposed through the Istio
gateway became unreachable, returning HTTP 503 Service Unavailable. This includes
http://mlflow.localtest.me:8080/, http://kagenti-ui.localtest.me:8080/,
http://kagenti-api.localtest.me:8080/, and others.
The trigger that surfaced it was MLflow, but MLflow is not the cause — the failure is
mesh-wide. The root cause is that Istio Ambient workload mTLS certificates (SPIFFE SVIDs,
issued by SPIRE) expired and stopped rotating. This happened because the host machine was
suspended for ~16 hours (laptop sleep), during which every time-bound SPIRE credential
expired at once — the agent's own SVID, its 2h Kubernetes service-account token, and even the
24h CA. On resume the spire-agent hit a credential-expiry deadlock (it needs a valid SA
token to re-attest and obtain a new SVID, but that token had also expired) and crashed. It
later recovered, but the Ambient data plane (ztunnel + waypoints) never re-fetched the fresh
SVIDs and kept serving expired certs.
This is a reliability/lifecycle bug: a freshly deployed cluster works, but a cluster that
is left idle/suspended longer than the SVID/CA + SA-token lifetime can silently lose all mesh
connectivity and not self-heal.
Impact
- All HTTP routes behind the
httpgateway inkagenti-systemreturn503. - Inter-service mesh traffic fails (e.g.
otel-collector → mlflow, agent → agent). - The cluster looks healthy on the surface: all pods are
Running, the gateway pod is
1/1, theHTTPRoute/Gatewaystatus isAccepted/ResolvedRefs/ResolvedWaypoints,
and DNS resolves. Nothing inkubectl get podsindicates a problem — making this hard to
diagnose without reading ztunnel logs.
Environment
- Deployment: Kind, via
./.github/scripts/local-setup/kind-full-test.sh - Cluster age at time of failure: ~27h
- Mesh: Istio Ambient (ztunnel + waypoint proxies)
- Workload identity: SPIRE (
zero-trust-workload-identity-managerfor the server,
spire-systemfor the agent + SPIFFE CSI driver)
Symptoms / how to reproduce
-
Deploy a Kind cluster and leave it running for longer than the SVID lifetime
(see TTLs below — in practice this surfaces several hours in, not immediately). -
Hit any gateway URL:
$ curl -s -w "\nHTTP %{http_code}\n" -H "Host: mlflow.localtest.me" http://127.0.0.1:8080/ upstream connect error or disconnect/reset before headers. reset reason: connection termination HTTP 503
The same 503 occurs for
kagenti-ui.localtest.me,kagenti-api.localtest.me, etc.
Theserver: istio-envoyresponse header confirms Envoy is reached and is itself
returning the 503 — the request is not failing to route.
Diagnosis (evidence)
1. The 503 is an upstream connection failure, not a routing failure
HTTPRoute mlflow and the http Gateway are healthy:
- Gateway listener:
attachedRoutes: 9, no listener errors. - Route status:
Accepted,ResolvedRefs,ResolvedWaypointsallTrue. - Backend
Service mlflow(:5000) and pod (mlflow-5b8bc89d4b-...,1/1 Running) exist.
The 503 body — upstream connect error or disconnect/reset before headers. reset reason: connection termination — means Envoy found the route and tried to connect upstream, but the
connection was terminated. In Ambient, that hop goes gateway → ztunnel → backend over mTLS.
2. ztunnel is rejecting connections on expired certificates
kubectl logs -n istio-system ztunnel-<id> shows, at current timestamps:
error access connection complete src.workload="otel-collector-..." dst.service="mlflow.kagenti-system.svc.cluster.local"
dst.workload="mlflow-waypoint-..." direction="outbound"
error="io error: invalid peer certificate: certificate expired:
verification time 1781176674 (UNIX), but certificate is not valid after 1781162862 (13820 seconds ago)"
warn access connection failed direction="inbound"
error="tls handshake error: Custom { kind: InvalidData, error: AlertReceived(CertificateExpired) }"
- Cert
not valid after=1781162862= 2026-06-11 07:27:42 UTC. - Verification time ≈ 2026-06-11 11:18 UTC → certificates expired ~3h50m before the failures.
Every mesh hop fails the same way, which is why all gateway-routed services return 503.
3. Root cause: a host suspend (~16h) expired all SPIRE credentials simultaneously, deadlocking the agent on resume
Correction: an earlier version of this issue stated that the agent crashed and then
failed to re-attest, implying a SPIRE defect. That causality was backwards. The crash was a
consequence of credential expiry, and the initiating event was the host machine being
suspended (laptop sleep) for ~16 hours. SPIRE behaved correctly given expired inputs.
Evidence — a ~16-hour dead zone in both the agent and the server logs.
The agent normally renews SVIDs every ~10–30s, and the server logs continuously. Yet there
is near-total silence on both from 2026-06-10 14:56 UTC to 2026-06-11 06:45 UTC, and they
both resume in the same second (06:45):
- spire-agent: last renewal line
2026-06-10T14:56:10Z, next line2026-06-11T06:45:52Z. - spire-server: only 5 log lines total in the entire
2026-06-10 15:00 → 2026-06-11 07:00
window, then a burst at06:45:54Z.
When a single component is unhealthy, you see one side quiet and the other logging connection
errors. Here both sides stopped together and resumed together — the signature of the whole
Kind/Docker VM being paused, not a SPIRE failure. (This is a local Kind cluster on a laptop;
the gap aligns with an overnight suspend.)
On resume, every time-bound credential SPIRE needs had expired at once:
- The agent's own node X509-SVID (
default_x509_svid_ttl: 4h) — expired. - The agent's projected Kubernetes SA token (
spire-tokenvolume,expirationSeconds: 7200
= 2h) — expired. - Even the server's signing CA (
ca_ttl: 24h) had lapsed — the server re-minted it on resume:
X509 CA prepared ... issued_at="2026-06-11 06:45:54".
The deadlock. With its SVID expired, the agent must re-attest to the server via the
k8s_psat node attestor, which presents the projected SA token. But that token had also
expired during the sleep, so the server rejected it and the agent had no path to a new SVID:
# spire-agent
level=error msg="Could not reattest agent"
error="...nodeattestor(k8s_psat): unable to validate token with TokenReview API:
token review API response contains an error: [invalid bearer token, service account token has expired]"
level=error msg="Cache manager crashed"
error="current SVID has already expired and reattest agent failed: ..."
level=error msg="Agent crashed"
error="current SVID has already expired and reattest agent failed: ..."
# spire-server (same instant)
level=error msg="Nodeattestor(k8s_psat): unable to validate token with TokenReview API:
... [invalid bearer token, service account token has expired]" method=AttestAgent
This is a chicken-and-egg / credential-expiry deadlock on resume-from-suspend: the agent
needs a valid SA token to obtain a valid SVID, but both expired during the same idle window.
The agent process exited (Error, exitCode 1, 2026-06-11 06:45:52 UTC).
Recovery. Kubernetes restarted the agent pod; the kubelet eventually projected a fresh
SA token, the agent re-attested (Successfully reattested node, 10:30:54 UTC) and resumed
issuing SVIDs. But the already-issued workload SVIDs had expired at 07:27 UTC in the
meantime, and ztunnel and the waypoint proxies never re-fetched the fresh SVIDs — they
kept serving the expired certs, which is the 503 symptom observed at ~11:18 UTC.
SPIRE server TTLs for reference (spire-server ConfigMap):
ca_ttl: "24h"default_x509_svid_ttl: "4h"default_jwt_svid_ttl: "1h"
The binding constraint is the 2h SA-token TTL combined with the host being idle long
enough that the token cannot be refreshed before the agent must use it to re-attest.
The agent has since recovered (Successfully reattested node at 10:30:54 UTC) and is now
issuing fresh, future-valid SVIDs (e.g. expires_at="2026-06-11T14:30:30Z"). However,
ztunnel and the waypoint proxies do not automatically re-fetch the new SVIDs — they keep
serving the old expired certs. The expired-cert errors in ztunnel are stamped at current
time even though SPIRE has fresh certs available, confirming the data plane is stuck.
Immediate remediation (restores the current cluster)
SPIRE is healthy again; the data-plane proxies just need to pull the new SVIDs:
# ztunnel — the node proxy all mesh traffic flows through
kubectl rollout restart daemonset/ztunnel -n istio-system
# waypoint proxies (L7, e.g. mlflow-waypoint)
kubectl rollout restart deployment/mlflow-waypoint -n kagenti-system
# (or all mesh-managed waypoints:)
# kubectl rollout restart deployment -n kagenti-system -l gateway.networking.k8s.io/managed-by=istio.io-mesh-controller
# gateway, to be safe
kubectl rollout restart deployment/http-istio -n kagenti-systemThen verify:
curl -s -o /dev/null -w "HTTP %{http_code}\n" -H "Host: mlflow.localtest.me" http://127.0.0.1:8080/Note: this only fixes the running cluster. The defect will recur on any cluster that is
suspended/idle past the SA-token + SVID lifetime.
Proposed durable fixes (for discussion)
Two distinct defects compound here: (a) a host suspend longer than the SA-token TTL puts the
SPIRE agent into a credential-expiry deadlock that crashes it, and (b) once SVIDs lapse, the
Ambient data plane never re-fetches fresh SVIDs on its own. Options, roughly in order of
preference:
-
Survive resume-from-suspend without a deadlock. The initiating event is the host being
suspended for ~16h (laptop sleep), which expires both the agent SVID (4h) and its
projected SA token (7200s= 2h) at once, so the agent cannot re-attest on resume. Options:- Increase the
spire-tokenprojected-tokenexpirationSecondsso a typical idle/suspend
window doesn't outlive it, and rely on the kubelet to refresh it on resume. - Confirm the agent's restart path always picks up a freshly projected token (it eventually
did here, ~3h45m later — too slow).
- Increase the
-
Self-heal the data plane when SVIDs rotate. Even after SPIRE recovered, ztunnel and the
waypoint proxies kept serving expired certs and required a manualrollout restart. The
data plane should detect expired/replaced SVIDs and re-fetch, or be auto-restarted, rather
than silently serving 503s. This is arguably the more important fix, since it turns a
transient SPIRE hiccup into a self-correcting event instead of a hard outage. -
Add a watchdog / readiness gating on the agent so a SPIRE agent that cannot re-attest is
restarted with a fresh token promptly, instead of crashing and recovering hours later. -
Document expected behavior for laptop/dev clusters. Suspending a Kind cluster host for
longer than the SVID/CA lifetime is a normal thing developers do overnight. Either document
that long-idle clusters need a mesh data-plane restart (with the commands above), or treat
recreate-on-resume as the supported path. -
Right-size TTLs for long-lived dev clusters. A 4h X509 SVID TTL, 1h JWT TTL, and 24h CA
TTL on a cluster that is routinely left running (and suspended) for a day+ guarantees this
class of failure if rotation ever hiccups. Consider longer dev TTLs, or document that
long-lived Kind clusters are expected to be recreated. -
Detection / observability. This was invisible to
kubectl get podsand to Gateway/Route
status — it only showed up in ztunnel logs. Consider:- A
k8s:health/ preflight check that flags expired or near-expiry workload SVIDs. - Surfacing certificate-expiry errors from ztunnel as an alert or a documented troubleshooting
entry (e.g. in the MLflow / Ambient docs and thekagenti:ui-debug502/503 skill).
- A
Diagnostic one-liners (for whoever picks this up)
# Is it a mesh cert problem? (look for CertificateExpired / expired peer certificate)
kubectl logs -n istio-system -l app=ztunnel --tail=100 | grep -iE "certificate expired|CertificateExpired"
# Is the SPIRE agent failing to re-attest?
kubectl logs -n spire-system -l app=spire-agent --tail=100 | grep -iE "reattest|service account token has expired"
# SVID / CA TTLs
kubectl get cm spire-server -n zero-trust-workload-identity-manager -o jsonpath='{.data}' \
| grep -oE '"(ca_ttl|default_x509_svid_ttl|default_jwt_svid_ttl)":[^,]*'
# Agent SA token expiry and last restart reason
kubectl get pod -n spire-system -l app=spire-agent -o jsonpath='{.items[0].status.containerStatuses[0].lastState.terminated.reason}{"\n"}'
# Why did the agent crash? (previous container shows the credential-expiry deadlock)
kubectl logs -n spire-system -l app=spire-agent --previous --tail=20 | grep -iE "Agent crashed|Cache manager crashed|reattest"Assisted-By: Claude Code
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
pdettori commentedon Jun 22, 2026
Moving to v0.7.0 as we need more discussion and won't be able to work on this by this week
cwiklik commentedon Jul 9, 2026
Picking up the "needs more discussion" flag — I dug into where this failure actually sits, and it changes how we should split the work. Sharing findings + workaround options for you to weigh in on before anyone starts coding.
Finding: the mesh certs are istiod-issued, not SPIRE SVIDs
I traced how the Ambient data plane gets its identity on a live Kind cluster (and cross-checked the charts):
istio-token,istiod-ca-cert,cni-ztunnel-sock-dir,tmp— nocsi.spiffe.io/ SPIRE workload-api socketPILOT_CERT_PROVIDERistiodistio-ca-secret(istio.io/ca-root), self-signedO=cluster.local— not SPIRE-rootedcaAddress/ISTIO_META_ENABLE_SPIFFE/ spiffe-csi mount on ztunnel anywhereztunnel and the waypoints fetch their mTLS certs from istiod via SDS. SPIRE is a parallel identity plane — its Workload-API socket is mounted only into application workloads (AuthBridge
spiffe-helper) and SPIRE/SPIKE, never into the mesh data plane.Consequence: two independent failures that coincided
The suspend expired everything at once, which made them look like one bug. They aren't:
Practical implication: tuning SPIRE TTLs will not fix the 503. The two need different owners.
Where the long-term fix belongs
expirationSecondsand SVID/CA TTLs, scoped to AuthBridge.Workarounds we can own now (choices)
Since the durable mesh fix is upstream, I'd treat our side as detection + recovery. Three tiers:
k8s:health: detect via an active probe (curl a gateway host, expect non-503) +istioctl ztunnel-config certificates, then one-commandrollout restartof ztunnel/waypoints/gateway. Zero risk, immediately useful.Constraint for B/C: the remediator must run outside ambient (its own API calls can't traverse the broken ztunnel), and it's subject to the same suspend — it can only act after the kubelet reprojects its SA token on resume.
Proposed split
@pdettori — how would you like to proceed? Happy to spec whichever tier you prefer (I lean toward A + the CronJob in B).
Assisted-By: Claude Code
pdettori commentedon Jul 9, 2026
@cwiklik yes, I agree - let's go for A + B
feat(k8s): mesh self-heal detect+recover for post-suspend 503 (Part of …
Merge pull request #2179 from cwiklik/feat/mesh-selfheal-preflight-1899
2 remaining items
fix(mesh): make self-heal CronJob runnable — Events, image, non-root (r…
feat(mesh): feature-flagged mesh self-heal CronJob (Part of #1899)
docs(spec): fix MD018 markdownlint (reflow rossoctl#4/rossoctl#5/ross…
docs(spec): mesh self-heal proactive detection + TTL right-sizing + 5…
feat(mesh): proactive trust-bundle CA near-expiry check (Part of #1899)
feat(mesh): CronJob emits MeshNearExpiry Warning on rc=4 (Part of #1899)
fix(kind): right-size SPIRE CA/SVID TTLs to survive host suspend (Par…
docs(mesh): document post-suspend 503 recovery + proactive detection …
fix(mesh): skipped cert-expiry check stays neutral; reset near-expiry…
fix(mesh): near-expiry check reads real workload SVID, not the 10y ro…
Merge pull request #2464 from cwiklik/fix/mesh-selfheal-detection-ttl…
cwiklik commentedon Aug 25, 2026
All in-repo mitigations for this issue are now shipped on
mainvia three "Part of #1899" PRs:scripts/k8s/mesh-recover.sh+ thek8s:health/istio:mesh-selfhealskills. Reactive detect + recover (rollout-restart ztunnel/waypoints/gateway so the Ambient data plane re-fetches fresh certs).config_dump; advisoryWARN/exit 4, no restart; surfaced on the manualk8s:healthpath), Kind SPIRE TTL right-sizing (CA24h→168h, x509 SVID→24h, so a normal overnight suspend no longer expires every credential at once), and a 503-after-suspend troubleshooting doc.Root cause remains upstream. The durable fix — the data plane not re-fetching certs after a lifecycle event / clock jump — belongs in Istio/ztunnel and is tracked at istio/ztunnel#1679. Everything shipped here is dev/Kind mitigation (detect, auto-recover, TTL headroom, docs), not the underlying fix.
Closing as the rossoctl-side mitigations are complete. The durable fix is tracked upstream (ztunnel#1679).
Minor follow-up noted during the work (not blocking):
check_spire_agentinmesh-recover.shuses-l app=spire-agent, which matches no pods on the current chart (real labelapp.kubernetes.io/name=agent); it only runs under--include-spire.