Skip to content

Mesh-wide 503: expired SPIRE workload SVIDs break all gateway-routed services on long-running Kind clusters #1899

Closed

Description

@yoavkatz

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 http gateway in kagenti-system return 503.
  • 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, the HTTPRoute/Gateway status is Accepted / ResolvedRefs / ResolvedWaypoints,
    and DNS resolves. Nothing in kubectl get pods indicates 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-manager for the server,
    spire-system for the agent + SPIFFE CSI driver)

Symptoms / how to reproduce

  1. 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).

  2. 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.
    The server: istio-envoy response 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, ResolvedWaypoints all True.
  • 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 line 2026-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 at 06: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-token volume, 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-system

Then 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:

  1. 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-token projected-token expirationSeconds so 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).
  2. Self-heal the data plane when SVIDs rotate. Even after SPIRE recovered, ztunnel and the
    waypoint proxies kept serving expired certs and required a manual rollout 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.

  3. 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.

  4. 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.

  5. 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.

  6. Detection / observability. This was invisible to kubectl get pods and 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 the kagenti:ui-debug 502/503 skill).

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

Activity

  1. added this to the Release v0.6.1 milestone on Jun 11, 2026
  2. pdettori commented on Jun 22, 2026

    @pdettori
    Member

    Moving to v0.7.0 as we need more discussion and won't be able to work on this by this week

  3. moved this from New/ToDo to Backlog in Rossoctl Issue Prioritizationon Jun 26, 2026
  4. cwiklik commented on Jul 9, 2026

    @cwiklik
    Contributor

    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):

    Check Result
    ztunnel volumes istio-token, istiod-ca-cert, cni-ztunnel-sock-dir, tmp — no csi.spiffe.io / SPIRE workload-api socket
    PILOT_CERT_PROVIDER istiod
    istio CA secret istio-ca-secret (istio.io/ca-root), self-signed O=cluster.local — not SPIRE-rooted
    repo wiring no caAddress / ISTIO_META_ENABLE_SPIFFE / spiffe-csi mount on ztunnel anywhere

    ztunnel 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:

    1. Mesh 503 — the expired certs ztunnel/waypoints served are istiod-issued workload certs. After the clock jump the data plane never re-fetched → 503. This is an Istio-Ambient / istiod↔istio-agent rotation-after-suspend problem.
    2. SPIRE agent reattest deadlock — real, but it breaks AuthBridge / token-exchange identity, not mesh routing.

    Practical implication: tuning SPIRE TTLs will not fix the 503. The two need different owners.

    Where the long-term fix belongs

    Workarounds we can own now (choices)

    Since the durable mesh fix is upstream, I'd treat our side as detection + recovery. Three tiers:

    • A — Manual skill/CLI. Fold into k8s:health: detect via an active probe (curl a gateway host, expect non-503) + istioctl ztunnel-config certificates, then one-command rollout restart of ztunnel/waypoints/gateway. Zero risk, immediately useful.
    • B — CronJob remediator (hands-off). Periodic active-probe + gated restart, running outside the mesh so it never depends on the broken data plane; feature-flagged off by default, dev/Kind-scoped, with cooldown/max-restarts + loud Events. Good fit for the overnight-suspend case (fires on the first tick after resume). This is my preferred default.
    • C — Controller/watcher pod. Seconds-latency self-heal, but more privilege/complexity and a standing restarter; overkill for the suspend scenario and still just a stopgap for the upstream fix.

    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

    1. Now (ours): ship A, and — if you're comfortable — B behind a feature flag for dev clusters.
    2. Upstream: file/track the ztunnel cert-recovery-after-expiry case (link to AuthBridge demo docs: outdated paths, missing deploy steps, wrong OAuth clients #1679).
    3. Config (ours): right-size the SPIRE/AuthBridge SA-token + SVID TTLs to close the deadlock window.

    @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

  5. pdettori commented on Jul 9, 2026

    @pdettori
    Member

    @cwiklik yes, I agree - let's go for A + B

  6. added
    ready-for-ai-review
    on Jul 13, 2026
  7. moved this from Backlog to In progress in Rossoctl Issue Prioritizationon Jul 13, 2026
  8. added 2 commits that reference this issue on Jul 13, 2026
  9. removed
    ready-for-ai-review
    on Jul 20, 2026
  10. 2 remaining items

  11. moved this from In progress to In review / Needs Testing in Rossoctl Issue Prioritizationon Aug 21, 2026
  12. cwiklik commented on Aug 25, 2026

    @cwiklik
    Contributor

    All in-repo mitigations for this issue are now shipped on main via three "Part of #1899" PRs:

    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_agent in mesh-recover.sh uses -l app=spire-agent, which matches no pods on the current chart (real label app.kubernetes.io/name=agent); it only runs under --include-spire.

  13. moved this from In review / Needs Testing to Done in Rossoctl Issue Prioritizationon Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions