Skip to content
9 min read

Vault Goroutine Leak Silently Broke All 32 ExternalSecrets

A missing RBAC grant made Vault's Kubernetes service registration retry a 403 forever, leaking 160,000 goroutines until port 8200 stopped answering.


Disclosure: This post contains Amazon affiliate links (marked with *). As an Amazon Associate I earn from qualifying purchases. Buying through them costs you nothing extra.

For about 20 days, every one of the 32 ExternalSecret objects in my k3s cluster reported SecretSyncedError, and vault-0 sat at 0/1 Ready. Nothing alerted, no app broke, and I only found it on 2026-09-30 while chasing an unrelated alert. The cause was two faults stacked together: Vault’s Kubernetes service registration had no RBAC, so it retried a 403 every five seconds, and each retry leaked a goroutine until the server stopped answering on port 8200. A pod restart plus a namespaced Role fixed it. The missing alert took another five weeks.

View the complete homelab infrastructure source on GitHub

What It Looked Like

Every ExternalSecret showed the same condition:

Ready: SecretSyncedError - could not get secret data from provider

When all 32 fail at once, the individual secrets are not the problem. The provider is. My setup is the one described in External Secrets Operator + HashiCorp Vault: one ClusterSecretStore pointing at a single standalone Vault pod, vault-0, with raft storage on a local-path PVC.

The “20 days” figure is not a guess from logs. It comes from Prometheus, kube_pod_status_ready for vault/vault-0, which shows the pod dropping out of Ready and never coming back.

The uncomfortable part: Prometheus knew. KubeStatefulSetReplicasMismatch and KubePodNotReady both fired for the whole window. So did KubeJobFailed and TargetDown, for unrelated reasons, and had been for long enough that I had stopped reading any of them as incidents. The Vault signal was in the pile with the noise.

Wedged, Not Sealed

A sealed Vault is the usual failure after a restart, and it is what the polling unseal sidecar exists to handle. This was different. Vault was wedged, not merely sealed:

  • The process was alive, with 5h50m of accumulated CPU time.
  • The data-vault-0 PVC was Bound.
  • wget and vault status against the pod timed out. They were not refused.

That last point narrows things down. A refused connection means nothing holds the port. A timeout means something still does, but the process behind it never gets around to answering. Vault was alive and holding its listener, yet too busy with something else to serve. So I sent the Vault process a SIGQUIT, which makes the Go runtime dump every goroutine’s stack before exiting.

The dump had over 160,000 goroutines. Every one was parked in [select, 29459 minutes], which is 20.5 days, and every one had been spawned from the same function:

serviceregistration/kubernetes/client.(*Client).do

That matched the Prometheus readiness timeline almost to the day.

One note on my own evidence from that night: I also checked /proc/net/tcp for port 8200 and wrote down that there was no entry. The check looked for 0x2014, which is port 8212. Port 8200 is 0x2008. That observation proves nothing either way, so this post doesn’t rely on it.

Why Service Registration Was Retrying

Vault’s standalone config in kubernetes/system/vault/application.yml enables Kubernetes service registration with an empty block:

storage "raft" {
  path = "/vault/data"
  node_id = "vault-0"
}
service_registration "kubernetes" {}

With service registration on, Vault keeps labels on its own pod (vault-sealed, vault-active, vault-initialized and so on) so a Service selector can route to the active node. To do that it has to read and patch its own pod object. The Vault docs say the ServiceAccount needs get, update and patch on pods.

The chart did not grant it. The only binding it created for the vault ServiceAccount was system:auth-delegator, which covers tokenreviews and subjectaccessreviews and nothing about pods. So every attempt failed, and the log carried this line every five seconds for the life of the process:

service_registration.kubernetes: unable to set initial state due to GET .../namespaces/vault/pods/vault-0 giving up after 1 attempt(s): bad status code ... 403, will retry

The 403 on its own is a harmless, noisy log line. The leak is what turned it into an outage: each failed retry left a goroutine behind in (*Client).do, nothing ever released them, and after 20 days the process could no longer serve its listener. Fault 2 (no RBAC) is what made fault 1 (the leak) unbounded.

The Fix: Restart, Then RBAC

I fixed both halves, not only the visible one.

Restart the wedged pod. I snapshotted VM 211 first (vault-hang-pre-snapshot), then deleted the pod. No data was touched; the raft store lives on data-vault-0. Vault came back sealed: false within 10 seconds, unsealed by the existing sidecar without help. That was the check that mattered: the sidecar recovered a real wedge with no manual step.

Grant the RBAC. PR #804 added kubernetes/system/vault/rbac.yml and put it in the vault-manifests ArgoCD Application’s include list:

include: "{unseal,network-policies,certificate,rbac}.yml"

The first version only granted get, list, watch on pods. GETs stopped returning 403, but Vault also PATCHes its pod to set those labels, so the PATCHes kept failing. PR #805 eight minutes later added update and patch. The final Role:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: vault-server
  namespace: vault
rules:
  - apiGroups: [""]
    resources: ["pods"]
    verbs: ["get", "list", "watch", "update", "patch"]
  - apiGroups: [""]
    resources: ["endpoints", "services", "pods/exec"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: vault-server
  namespace: vault
subjects:
  - kind: ServiceAccount
    name: vault
    namespace: vault
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: vault-server

It is a namespaced Role on purpose, not a ClusterRole. The only object this feature needs is Vault’s own pod, so the grant stays inside the vault namespace. Trivy later flagged two checks on this file (KSV-0053 and KSV-0056). Both grants are documented requirements here, so they are suppressed in .trivyignore with a comment saying why.

Verification was against the running system, not the pod status: all 32 ExternalSecrets went back to Ready=True, and the 403 line stopped appearing in vault-0’s logs.

Why Nothing Broke for 20 Days

ESO does not delete a target Secret when the provider fails. It just stops updating it. Every workload kept reading the last Secret that had synced before Vault wedged, so from the outside everything was fine.

That was luck. Any credential rotation in that window would never have reached the cluster, and anything that needed ESO to create a Secret from scratch (a new app, a recreated namespace) would have failed. A failing secret store with stale-but-valid Secrets is the worst kind of failure to have: the system degrades in a way that only shows up on the next change.

The memory limit is a second piece of luck. An earlier incident had already pushed vault-0’s limit from 512Mi to 1Gi (the comment is still in application.yml). At the time of the wedge the container was sitting at 1022Mi. The limit was the only thing still containing the leak, and the memory graph had been climbing long before the listener died.

The Alert I Wrote Down and Then Didn’t Add

ADR-046 ended with “Follow-up not done here: an alert on ExternalSecret Ready != 1.” That line sat there for five weeks.

On 2026-10-31 every ExternalSecret failed again, for an unrelated reason: an egress default-deny for the external-secrets namespace, applied by hand, whose Vault allow rule targeted a node IP instead of the Vault pod. Same symptom, same silence, workloads running on stale Secrets. It was fixed on 2026-11-04.

Writing the alert then exposed a second gap. The metric name I had noted in the ADR was not the one ESO exports, and it did not matter anyway: ESO’s ServiceMonitors lacked the release: kube-prometheus-stack label, so Prometheus never selected them and no ESO metric existed at all. PR #1010 added the label in the ESO Helm values and then the alert in silent-failure-alerts.yml:

- alert: ExternalSecretNotSyncing
  expr: externalsecret_status_condition{condition="Ready", status="False"} == 1
  for: 30m
  labels:
    severity: critical
- alert: ExternalSecretsMetricsMissing
  expr: absent(externalsecret_status_condition)
  for: 30m
  labels:
    severity: warning

The second rule is there because the first can only fire while ESO is being scraped. Without it, a missing ServiceMonitor label puts you right back where I was: an alert that looks like coverage and can never fire.

What I Check Now

  • All ExternalSecrets failing together means the store, not the secrets. First command: kubectl get clustersecretstore vault -o jsonpath='{.status.conditions}'. The alert annotation says the same thing, so I don’t have to remember it.
  • A timeout from a live process is a different bug from a refused connection. If the PID is alive and the port is gone, get a goroutine dump (SIGQUIT for any Go binary) before restarting. The restart destroys the evidence.
  • Read RBAC requirements for every optional Vault stanza. service_registration "kubernetes" {} looks like a no-op config line. It is a permanent API client that needs pod patch rights.
  • A follow-up in an ADR is not a fix. The alert that would have caught the second outage was written down in the first one’s ADR. What I’d do differently: ship the detection in the same PR as the fix, because the follow-up list is where it stalled.
  • Every new alert needs a “metrics present” partner. absent() on the series the alert depends on, so a broken scrape config fails loudly instead of making the alert silent.
  • Noisy alerts cost more than their own noise. KubePodNotReady for vault-0 fired for 20 days and I ignored it because it sat next to alerts I had learned to ignore. Fixing or silencing the chronic ones is what makes the real ones readable.

The timeout-versus-refused distinction is the part I’d have recognized sooner with more distributed-systems background. Designing Data-Intensive Applications* has a good chapter on exactly that: a remote node that does not respond tells you very little about whether it is dead, slow or stuck.

Was this helpful?
Share
DW

David Woitzik

Hybrid Cloud Engineer

I work mostly with Azure, Terraform, and Zero-Trust network design, and publish the Terraform templates and write-ups I wanted when I was solving the same problems.

Keep Reading

More Like This in Your Inbox

New Terraform modules and articles by email. No spam.