<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ramesh Yara</title>
    <description>The latest articles on DEV Community by Ramesh Yara (@ramesh-yara).</description>
    <link>https://dev.to/ramesh-yara</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4070124%2F1e527bdf-d0ce-43f6-a7b4-2d49f8e297d2.jpg</url>
      <title>DEV Community: Ramesh Yara</title>
      <link>https://dev.to/ramesh-yara</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ramesh-yara"/>
    <language>en</language>
    <item>
      <title>I Deleted kubectl apply From My Workflow. Here's What Replaced It.</title>
      <dc:creator>Ramesh Yara</dc:creator>
      <pubDate>Sun, 22 Nov 2026 21:01:06 +0000</pubDate>
      <link>https://dev.to/ramesh-yara/i-deleted-kubectl-apply-from-my-workflow-heres-what-replaced-it-4m7d</link>
      <guid>https://dev.to/ramesh-yara/i-deleted-kubectl-apply-from-my-workflow-heres-what-replaced-it-4m7d</guid>
      <description>&lt;p&gt;Before this migration, here was the state of my Kubernetes platform:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;7 Helm releases running on AWS EKS — kube-prometheus-stack, Tempo, Loki, Promtail, Chaos Mesh, plus the microservices overlay&lt;/li&gt;
&lt;li&gt;Each installed manually with &lt;code&gt;helm install&lt;/code&gt; or &lt;code&gt;kubectl apply -k&lt;/code&gt; from my laptop&lt;/li&gt;
&lt;li&gt;No drift detection: if a resource was patched directly in the cluster, I'd find out when something broke&lt;/li&gt;
&lt;li&gt;No audit trail: the deployment history was a mix of terminal history and my own memory&lt;/li&gt;
&lt;li&gt;Deployment ordering enforced by me running commands in the right sequence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how most Kubernetes platforms look after the "it works" phase. The cluster is functional but fragile. The state of your infrastructure lives in your head, not in git.&lt;/p&gt;

&lt;p&gt;This post documents how I changed that — using ArgoCD's app-of-apps pattern to migrate the entire platform to GitOps in a single session.&lt;/p&gt;




&lt;h2&gt;
  
  
  What ArgoCD App-of-Apps Actually Is
&lt;/h2&gt;

&lt;p&gt;The app-of-apps pattern is simpler than it sounds: you create one "root" ArgoCD Application that watches a directory in your git repository. Every YAML file in that directory is itself an ArgoCD Application manifest. When you push a new Application file to that directory, ArgoCD automatically creates the corresponding release. When you delete the file, ArgoCD prunes the release from the cluster.&lt;/p&gt;

&lt;p&gt;One directory. One git push. ArgoCD handles the rest.&lt;/p&gt;

&lt;p&gt;The root application for this platform is 34 lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;argoproj.io/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Application&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;platform-root&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;argocd&lt;/span&gt;
  &lt;span class="na"&gt;finalizers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;resources-finalizer.argocd.argoproj.io&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;project&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;default&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;repoURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/Rummy43/ai-microservices-platform.git&lt;/span&gt;
    &lt;span class="na"&gt;targetRevision&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HEAD&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;k8s/gitops/apps&lt;/span&gt;
  &lt;span class="na"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://kubernetes.default.svc&lt;/span&gt;
    &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;argocd&lt;/span&gt;
  &lt;span class="na"&gt;syncPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;automated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;prune&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="na"&gt;selfHeal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;syncOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;CreateNamespace=true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the entire bootstrap. One &lt;code&gt;kubectl apply -f k8s/gitops/app-of-apps.yaml&lt;/code&gt;. Everything after that is a git push.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;prune: true&lt;/code&gt; means ArgoCD deletes resources from the cluster when their definition is removed from git. &lt;code&gt;selfHeal: true&lt;/code&gt; means ArgoCD automatically reverts manual cluster changes back to the git state. These two flags together are what makes this GitOps rather than just "ArgoCD-managed deploys."&lt;/p&gt;




&lt;h2&gt;
  
  
  The Seven Child Applications
&lt;/h2&gt;

&lt;p&gt;Inside &lt;code&gt;k8s/gitops/apps/&lt;/code&gt;, there are seven Application manifests:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Application&lt;/th&gt;
&lt;th&gt;Namespace&lt;/th&gt;
&lt;th&gt;Deployment Type&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;kube-prometheus-stack&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;monitoring&lt;/td&gt;
&lt;td&gt;Helm multi-source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;tempo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;monitoring&lt;/td&gt;
&lt;td&gt;Helm multi-source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;loki&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;monitoring&lt;/td&gt;
&lt;td&gt;Helm multi-source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;observability-config&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;monitoring&lt;/td&gt;
&lt;td&gt;Kustomize&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;promtail&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;monitoring&lt;/td&gt;
&lt;td&gt;Helm multi-source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;chaos-mesh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;chaos-testing&lt;/td&gt;
&lt;td&gt;Helm multi-source&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;microservices&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;microservices&lt;/td&gt;
&lt;td&gt;Kustomize prod overlay&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;ArgoCD auto-detects the deployment type. If the target path contains a &lt;code&gt;kustomization.yaml&lt;/code&gt;, it uses Kustomize. If it contains &lt;code&gt;Chart.yaml&lt;/code&gt;, it uses Helm. No explicit type annotation required.&lt;/p&gt;

&lt;p&gt;The microservices application points directly at the production overlay that was already managing the platform services before this migration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;k8s/overlays/prod&lt;/span&gt;
  &lt;span class="na"&gt;syncPolicy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;automated&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;prune&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
      &lt;span class="na"&gt;selfHeal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="na"&gt;syncOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ApplyOutOfSyncOnly=true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ApplyOutOfSyncOnly=true&lt;/code&gt; is worth calling out: it tells ArgoCD to only apply resources that have actually drifted from git, rather than re-applying every resource on every sync cycle. For a Kustomize overlay with 20+ manifests, this matters for cluster stability — you don't want rolling restarts on every sync just because ArgoCD did a reconciliation pass.&lt;/p&gt;




&lt;h2&gt;
  
  
  Sync Waves: Encoding Deployment Order in YAML
&lt;/h2&gt;

&lt;p&gt;The observability stack must be ready before microservices start. Prometheus needs to be scraping before services emit metrics. Chaos Mesh needs to be installed before you run experiments against it. This ordering exists whether you encode it or not — the question is whether it lives in a Confluence page, in your head, or in the deployment system itself.&lt;/p&gt;

&lt;p&gt;ArgoCD sync waves encode it in the deployment system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Wave 0 — observability stack (must be ready first)
&lt;/span&gt;&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;argocd.argoproj.io/sync-wave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0"&lt;/span&gt;
&lt;span class="c1"&gt;# Applied to: kube-prometheus-stack, tempo, loki, observability-config
&lt;/span&gt;
&lt;span class="c1"&gt;# Wave 1 — log shipping and chaos tooling (needs observability running)
&lt;/span&gt;&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;argocd.argoproj.io/sync-wave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
&lt;span class="c1"&gt;# Applied to: promtail, chaos-mesh
&lt;/span&gt;
&lt;span class="c1"&gt;# Wave 2 — platform microservices (needs everything else ready)
&lt;/span&gt;&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;argocd.argoproj.io/sync-wave&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2"&lt;/span&gt;
&lt;span class="c1"&gt;# Applied to: microservices (user-service, notification-service, api-gateway)
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ArgoCD will not begin wave 1 until every application in wave 0 reports Healthy. It will not begin wave 2 until wave 1 is complete. If kube-prometheus-stack fails its health check, the microservices never start — which is correct behavior. You want to know about the observability failure before your services are running without metrics.&lt;/p&gt;

&lt;p&gt;The practical value goes beyond ordering. It eliminates an entire category of incidents that begin with "which order did you install things?" You don't answer that question from memory anymore. You read the wave number.&lt;/p&gt;




&lt;h2&gt;
  
  
  Multi-Source Helm: Separating Chart Version from Values Config
&lt;/h2&gt;

&lt;p&gt;Standard Helm with ArgoCD gives you one source: a chart from a Helm repository with values inlined or from a file in the same application repo. Multi-source, available from ArgoCD 2.6+, lets you reference a Helm chart from one repository and your values files from another.&lt;/p&gt;

&lt;p&gt;For kube-prometheus-stack:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repoURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://prometheus-community.github.io/helm-charts&lt;/span&gt;
    &lt;span class="na"&gt;chart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kube-prometheus-stack&lt;/span&gt;
    &lt;span class="na"&gt;targetRevision&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"91.8.0"&lt;/span&gt;
    &lt;span class="na"&gt;helm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;releaseName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kube-prometheus-stack&lt;/span&gt;
      &lt;span class="na"&gt;valueFiles&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;$values/k8s/helm/kube-prometheus-stack/values.yaml&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;$values/k8s/helm/kube-prometheus-stack/values-eks.yaml&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repoURL&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/Rummy43/ai-microservices-platform.git&lt;/span&gt;
    &lt;span class="na"&gt;targetRevision&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HEAD&lt;/span&gt;
    &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;values&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second source defines the &lt;code&gt;$values&lt;/code&gt; reference — a named pointer to your git repository. The first source uses &lt;code&gt;$values/path/to/file.yaml&lt;/code&gt; to load values from that reference.&lt;/p&gt;

&lt;p&gt;The same pattern applies to Tempo, Loki, Chaos Mesh, and Promtail — each has a base &lt;code&gt;values.yaml&lt;/code&gt; for local kind cluster configuration and a &lt;code&gt;values-eks.yaml&lt;/code&gt; for EKS-specific overrides (S3 backends, IRSA service accounts, gp3 storage classes).&lt;/p&gt;

&lt;p&gt;What this gives you:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Chart version pinned in git.&lt;/strong&gt; &lt;code&gt;targetRevision: "91.8.0"&lt;/code&gt; lives in a commit in your platform repo. Upgrading the chart is a PR with a diff, not a manual &lt;code&gt;helm repo update &amp;amp;&amp;amp; helm upgrade&lt;/code&gt;. Rollback is &lt;code&gt;git revert&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Environment-specific values separated cleanly.&lt;/strong&gt; The base chart never sees your EKS configuration. Your EKS values never pollute your local cluster setup. The two layers compose at deploy time — ArgoCD merges them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Drift detection on Helm values.&lt;/strong&gt; If someone runs &lt;code&gt;helm upgrade&lt;/code&gt; with modified values directly in the cluster, ArgoCD will detect the drift and self-heal back to the git state within minutes. Without GitOps, that modification is permanently invisible.&lt;/p&gt;




&lt;h2&gt;
  
  
  The 262KB Problem
&lt;/h2&gt;

&lt;p&gt;Chaos Mesh ships with large Custom Resource Definitions — the schemas that define &lt;code&gt;PodChaos&lt;/code&gt;, &lt;code&gt;NetworkChaos&lt;/code&gt;, &lt;code&gt;StressChaos&lt;/code&gt;, &lt;code&gt;IOChaos&lt;/code&gt;, and the rest of the fault injection primitives. When ArgoCD applies a large CRD using the standard &lt;code&gt;kubectl apply&lt;/code&gt; path, it stores the entire last-applied configuration as an annotation on the resource. For Chaos Mesh's CRDs, that annotation exceeds the 262KB limit that Kubernetes imposes on annotation values.&lt;/p&gt;

&lt;p&gt;The error on the first sync attempt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;metadata.annotations: Too long: may not be more than 262144 bytes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The fix is a single sync option in the ArgoCD Application manifest:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;syncOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ServerSideApply=true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server-side apply moves the apply logic from the client (ArgoCD/kubectl) to the Kubernetes API server. The &lt;code&gt;last-applied-configuration&lt;/code&gt; annotation is no longer stored on the resource, so the annotation size limit doesn't apply. The API server tracks field ownership in a different, more efficient way.&lt;/p&gt;

&lt;p&gt;This same fix was needed for &lt;code&gt;kube-prometheus-stack&lt;/code&gt; — the Prometheus Operator CRDs have the same characteristic. The pattern to remember: if an ArgoCD application fails to sync with an annotation size error, &lt;code&gt;ServerSideApply=true&lt;/code&gt; is the resolution. It's safe to enable for all Helm applications.&lt;/p&gt;




&lt;h2&gt;
  
  
  What "Healthy/Synced" Actually Looks Like
&lt;/h2&gt;

&lt;p&gt;After the bootstrap and the first automated sync cycle, the ArgoCD UI showed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;platform-root          Synced  Healthy
├── kube-prometheus-stack  Synced  Healthy   (wave 0)
├── tempo                  Synced  Healthy   (wave 0)
├── loki                   Synced  Healthy   (wave 0)
├── observability-config   Synced  Healthy   (wave 0)
├── promtail               Synced  Healthy   (wave 1)
├── chaos-mesh             Synced  Healthy   (wave 1)
└── microservices          Synced  Healthy   (wave 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Seven applications. All Healthy. All Synced. Wave ordering verified in the event timeline — wave 0 completed before wave 1 started; wave 1 completed before wave 2 started.&lt;/p&gt;

&lt;p&gt;The first real test came immediately after. I updated an image tag in a deployment manifest, committed, and pushed. ArgoCD detected the diff within 30 seconds. It applied only the changed resource (&lt;code&gt;ApplyOutOfSyncOnly=true&lt;/code&gt; in action), triggered a rolling update, and reported Healthy within two minutes of the push.&lt;/p&gt;

&lt;p&gt;No &lt;code&gt;kubectl apply&lt;/code&gt;. No &lt;code&gt;helm upgrade&lt;/code&gt;. No SSH into a bastion host. The git push was the deployment.&lt;/p&gt;




&lt;h2&gt;
  
  
  Two Gaps the Game Day Found
&lt;/h2&gt;

&lt;p&gt;GitOps solved the deployment pipeline. It didn't fix the gaps in the monitoring stack that the Phase 11 chaos engineering game day exposed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gap 1: Kafka consumer lag alerts need a lag exporter to have a data source.&lt;/strong&gt; The &lt;code&gt;PipelineConsumptionStalled&lt;/code&gt; alert rule is in git, properly formatted, correctly deployed via ArgoCD. But the metric it queries — &lt;code&gt;kafka_consumergroup_lag&lt;/code&gt; — does not exist in this cluster because no Kafka lag exporter is running. The alert rule evaluates to NaN and never fires. An alert with no metric source is a hypothesis, not a safeguard.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gap 2: SLO burn-rate alerts need real traffic to generate error budget burn.&lt;/strong&gt; &lt;code&gt;AvailabilityFastBurn&lt;/code&gt; fired correctly in prior testing. During the EKS game day, with only Prometheus scraping actuator endpoints as "traffic," there was no request error budget to consume. The burn rate calculation worked correctly — it correctly identified no errors — which masked the actual latency degradation.&lt;/p&gt;

&lt;p&gt;Both fixes will themselves be delivered via GitOps. The kafka-lag-exporter will be a new Application manifest in &lt;code&gt;k8s/gitops/apps/&lt;/code&gt;. The traffic generator will be a CronJob added to the microservices overlay. When those files are pushed, ArgoCD deploys them automatically.&lt;/p&gt;

&lt;p&gt;The irony of GitOps: it's very good at deploying your solutions. You still have to find the gaps first.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Changed
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deployment state lived in terminal history and my memory&lt;/li&gt;
&lt;li&gt;Helm releases were upgraded in place with no record of what values changed&lt;/li&gt;
&lt;li&gt;Ordering was enforced by convention and documentation&lt;/li&gt;
&lt;li&gt;Drift was invisible until something broke&lt;/li&gt;
&lt;li&gt;"What's running in production?" was a question that required interrogating the cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;After:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every resource in the cluster has a corresponding file in git&lt;/li&gt;
&lt;li&gt;Every change is a commit — with a diff, a reason, and a timestamp&lt;/li&gt;
&lt;li&gt;Deployment order is encoded in sync wave annotations, not in a runbook&lt;/li&gt;
&lt;li&gt;ArgoCD detects drift within minutes and self-heals automatically&lt;/li&gt;
&lt;li&gt;"What's running in production?" is &lt;code&gt;git log&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bootstrap was one command. Everything since has been &lt;code&gt;git push origin main&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you're running multiple Helm releases on Kubernetes and managing their state mentally, app-of-apps is the migration path. The pattern is straightforward once you've seen it once — the main decision is how to structure your sync waves to reflect the actual dependency order of your stack.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The platform source is at github.com/Rummy43/ai-microservices-platform. Phase 12 covers the kafka-lag-exporter and traffic generator — closing the game-day blind spots via, naturally, another git push.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>gitops</category>
      <category>argocd</category>
      <category>devops</category>
    </item>
    <item>
      <title>The Resilience Feature That Wasn't There</title>
      <dc:creator>Ramesh Yara</dc:creator>
      <pubDate>Thu, 22 Oct 2026 19:31:58 +0000</pubDate>
      <link>https://dev.to/ramesh-yara/the-resilience-feature-that-wasnt-there-2756</link>
      <guid>https://dev.to/ramesh-yara/the-resilience-feature-that-wasnt-there-2756</guid>
      <description>&lt;p&gt;When I finished Phase 6 of my event-driven microservices platform, I updated the architecture decision record.&lt;/p&gt;

&lt;p&gt;ADR-016 described a resilience layer: circuit breakers on outbound dependencies, rate limiting at the perimeter, and — the part that felt particularly clean — a &lt;em&gt;self-healing DLT pipeline&lt;/em&gt;. Dead-lettered events wouldn't sit in a table waiting for manual triage. A scheduled reprocessor would replay them with exponential backoff. A poison-message cap would prevent one bad event from blocking the rest. Dead letters would become an automatically draining queue.&lt;/p&gt;

&lt;p&gt;The ADR status: &lt;strong&gt;Accepted&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The README described it. The runbook referenced it. I committed both and moved on.&lt;/p&gt;

&lt;p&gt;Three months later, I was writing Phase 7 SLOs and noticed a Prometheus gauge I'd added: &lt;code&gt;dlt_unreprocessed&lt;/code&gt;. It was reading &lt;strong&gt;32&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I went to check what the scheduled reprocessor would do with those 32 events. There was no scheduled reprocessor. The table had been growing since Phase 5 failure tests. Nothing had ever drained it. The self-healing mechanism existed in three documents and in zero Java files.&lt;/p&gt;




&lt;h2&gt;
  
  
  How Documentation Gets Ahead of Implementation
&lt;/h2&gt;

&lt;p&gt;The ADR wasn't wrong — the design was correct. The outbox-to-DLT routing worked. When a Kafka message exhausted retries, &lt;code&gt;@DltHandler&lt;/code&gt; caught it, persisted it to &lt;code&gt;dead_letter_events&lt;/code&gt;, and that was it. Correct behavior. Durable failure record.&lt;/p&gt;

&lt;p&gt;The reprocessor was the second half of ADR-016. It got tagged as "Phase 7 polish" in the backlog because the routing worked and I'd moved into observability work. The backlog item never came back up. The ADR stayed at "Accepted."&lt;/p&gt;

&lt;p&gt;"Accepted" in an ADR means the team agreed the design is sound. It does not mean a deployment ran. It does not mean tests passed. It is not a CI gate.&lt;/p&gt;

&lt;p&gt;This is the failure mode: the document describes the design correctly, but describes it in the present tense — "a scheduled reprocessor replays dead-lettered events" — while the code implements only part of it. The gap is invisible until someone has to operate the thing.&lt;/p&gt;

&lt;p&gt;The gap became visible when I tried to write the &lt;code&gt;DltDepthHigh&lt;/code&gt; runbook.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Runbook Forced the Issue
&lt;/h2&gt;

&lt;p&gt;The runbook question is always: &lt;em&gt;what does an on-call engineer actually do when this fires?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My draft said: "The scheduled reprocessor will automatically replay pending events. Check &lt;code&gt;dlt_unreprocessed&lt;/code&gt; to confirm it's draining."&lt;/p&gt;

&lt;p&gt;To validate that claim, I had to check that the reprocessor existed and would actually drain the gauge. That's when I found the 32-event backlog that had been sitting untouched since Phase 5. There was no reprocessor to reference.&lt;/p&gt;

&lt;p&gt;The runbook is a correctness check for the alert. What I hadn't expected was that the runbook would become a correctness check for the &lt;em&gt;architecture documentation&lt;/em&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Naive Fix and Why It Falls Short
&lt;/h2&gt;

&lt;p&gt;The obvious approach is a &lt;code&gt;@Scheduled&lt;/code&gt; method that queries all unprocessed events, republishes them, and marks them done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Scheduled&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixedDelay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;60000&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Transactional&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;reprocess&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DeadLetterEvent&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findByReprocessedFalse&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;DeadLetterEvent&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;kafkaTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getTopic&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getPayload&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setReprocessed&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This works for the happy path. It breaks in every edge case that matters in production.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No backoff.&lt;/strong&gt; If the downstream system is unavailable, this fires every 60 seconds and hammers it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No poison-message detection.&lt;/strong&gt; If one event has a malformed payload, it stays in the &lt;code&gt;reprocessedFalse&lt;/code&gt; set forever and consumes a retry slot on every tick.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No observability.&lt;/strong&gt; Without tracking retry counts and failure reasons, you can't distinguish "transient failure, will clear soon" from "permanent failure, needs human attention."&lt;/p&gt;




&lt;h2&gt;
  
  
  The Production Implementation
&lt;/h2&gt;

&lt;p&gt;The production version adds retry accounting, a poison-message cap, and metrics.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="nd"&gt;@Slf4j&lt;/span&gt;
&lt;span class="nd"&gt;@RequiredArgsConstructor&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DltReprocessorService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="no"&gt;MAX_RETRY_COUNT&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;DeadLetterEventRepository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;KafkaTemplate&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;kafkaTemplate&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;MeterRegistry&lt;/span&gt; &lt;span class="n"&gt;meterRegistry&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Scheduled&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixedDelayString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"${dlt.reprocessor.interval-ms:60000}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nd"&gt;@Transactional&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;reprocess&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DeadLetterEvent&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;candidates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findByReprocessedFalseAndRetryCountLessThan&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;MAX_RETRY_COUNT&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;DeadLetterEvent&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;candidates&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;kafkaTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getTopic&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getPayload&lt;/span&gt;&lt;span class="o"&gt;()).&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
                &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setReprocessed&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
                &lt;span class="n"&gt;meterRegistry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"notifications.dlt.reprocessed"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;increment&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
                &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DLT reprocess success | eventId: {} | topic: {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getEventId&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getTopic&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setRetryCount&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRetryCount&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
                &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setLastRetryAt&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Instant&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;now&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
                &lt;span class="n"&gt;meterRegistry&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"notifications.dlt.reprocess.failed"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;increment&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
                &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;warn&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DLT reprocess failed | eventId: {} | attempt: {} | error: {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getEventId&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRetryCount&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getMessage&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key design decisions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retry count cap.&lt;/strong&gt; The query excludes events with &lt;code&gt;retryCount &amp;gt;= MAX_RETRY_COUNT&lt;/code&gt;. They remain in the table — visible in the &lt;code&gt;dlt_unreprocessed&lt;/code&gt; gauge — but the reprocessor stops attempting them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Synchronous send.&lt;/strong&gt; &lt;code&gt;kafkaTemplate.send(...).get()&lt;/code&gt; blocks until the broker acknowledges. For a low-volume scheduled job this ensures "sent" means the broker received it, not just that the message entered the producer buffer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Metrics in the loop.&lt;/strong&gt; Every success and failure increments a counter feeding the same Grafana panels and alert rules the SLO runbook references.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configurable interval.&lt;/strong&gt; &lt;code&gt;fixedDelayString&lt;/code&gt; with a property reference lets you adjust reprocessing frequency without a recompile.&lt;/p&gt;




&lt;h2&gt;
  
  
  Verifying the Drain
&lt;/h2&gt;

&lt;p&gt;After the first compile and restart, I watched the gauge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prometheus"&gt;&lt;code&gt;&lt;span class="n"&gt;dlt_unreprocessed&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;job&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"notification-service"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;
&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="mi"&gt;18&lt;/span&gt;
&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;
&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;notifications_dlt_reprocessed_total&lt;/code&gt; = 32. &lt;code&gt;_reprocess_failed_total&lt;/code&gt; = 0. Clean drain.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;DltDepthHigh&lt;/code&gt; alert — which had been firing since I'd added it — resolved and moved to &lt;strong&gt;INACTIVE&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now the runbook was honest.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. "ADR: Accepted" is not a deployment.&lt;/strong&gt;&lt;br&gt;
It records that the team agreed the design is right. Someone still has to write the code, wire the beans, and verify it runs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Runbooks are a correctness check for more than alerts.&lt;/strong&gt;&lt;br&gt;
Writing "the scheduled reprocessor will drain it" forced me to verify the reprocessor existed. Runbooks that describe operational behavior without verifying that behavior expose exactly these gaps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Poison-message caps are not optional.&lt;/strong&gt;&lt;br&gt;
A scheduled reprocessor without a retry cap will starve on unconvertible messages. The cap turns a potential infinite loop into a finite retry window with a known exit state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. A DLT without a reprocessor is a graveyard.&lt;/strong&gt;&lt;br&gt;
Events that land in a dead-letter table are durable — but durable and recoverable are not the same thing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Verify your own documentation.&lt;/strong&gt;&lt;br&gt;
Auditing the claim — "does this mechanism actually exist?" — is as important as auditing any external dependency assumption.&lt;/p&gt;




&lt;p&gt;The reprocessor is live. ADR-016 is now actually true. The &lt;code&gt;DltDepthHigh&lt;/code&gt; alert resolves on its own.&lt;/p&gt;

&lt;p&gt;The gap between &lt;em&gt;documented&lt;/em&gt; and &lt;em&gt;implemented&lt;/em&gt; is one of the least visible failure modes in a distributed system. Write the runbook. If you can't verify the claim it makes, you've found the gap.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The full implementation is in the &lt;a href="https://github.com/Rummy43/ai-microservices-platform" rel="noopener noreferrer"&gt;platform repository&lt;/a&gt; under &lt;code&gt;notification-service/src/main/java/.../DltReprocessorService.java&lt;/code&gt;. What's the most surprising gap you've found between an architecture document and the running code?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>distributedsystems</category>
      <category>microservices</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Three Layers Deep: Getting Confluent Schema Registry to Authenticate with MSK Serverless on EKS</title>
      <dc:creator>Ramesh Yara</dc:creator>
      <pubDate>Mon, 12 Oct 2026 19:01:56 +0000</pubDate>
      <link>https://dev.to/ramesh-yara/three-layers-deep-getting-confluent-schema-registry-to-authenticate-with-msk-serverless-on-eks-1fjh</link>
      <guid>https://dev.to/ramesh-yara/three-layers-deep-getting-confluent-schema-registry-to-authenticate-with-msk-serverless-on-eks-1fjh</guid>
      <description>&lt;h2&gt;
  
  
  The Setup
&lt;/h2&gt;

&lt;p&gt;When you deploy Confluent Schema Registry on EKS against an MSK Serverless cluster, you're combining three things that each have their own opinions about authentication:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Confluent's Docker image&lt;/strong&gt; — assumes it controls its own environment&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Kubernetes&lt;/strong&gt; — helpfully injects environment variables from service discovery&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MSK Serverless&lt;/strong&gt; — requires SASL/OAUTHBEARER (IAM) with a specific JAR on the JVM classpath&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In isolation, each is fine. Together, they'll fight you in exactly three layers. Here's what I found and how I fixed each one.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Environment
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;EKS 1.31 (Fargate managed node group)&lt;/li&gt;
&lt;li&gt;MSK Serverless (us-east-1)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;confluentinc/cp-schema-registry:7.5.0&lt;/code&gt; as the base image&lt;/li&gt;
&lt;li&gt;MSK IAM auth via IRSA (IAM Roles for Service Accounts)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aws-msk-iam-auth-2.3.2-all.jar&lt;/code&gt; for the SASL callback handler&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Layer 1: Kubernetes Poisons the Schema Registry Config
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Schema registry pod crashes immediately on startup. Logs show something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Schema Registry environment variables are not properly configured
SCHEMA_REGISTRY_PORT must be set to a valid port number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Root cause:&lt;/strong&gt; Kubernetes injects environment variables for every Service in the same namespace. If there's a service named &lt;code&gt;schema-registry&lt;/code&gt;, Kubernetes adds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;SCHEMA_REGISTRY_PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;tcp://10.100.200.50:8081
&lt;span class="nv"&gt;SCHEMA_REGISTRY_PORT_8081_TCP&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;tcp://10.100.200.50:8081
&lt;span class="nv"&gt;SCHEMA_REGISTRY_PORT_8081_TCP_ADDR&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.100.200.50
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confluent's startup scripts map any env var prefixed with &lt;code&gt;SCHEMA_REGISTRY_&lt;/code&gt; into the config file. So &lt;code&gt;SCHEMA_REGISTRY_PORT=tcp://10.100.200.50:8081&lt;/code&gt; gets translated to &lt;code&gt;port=tcp://10.100.200.50:8081&lt;/code&gt; — which is not a valid port number, causing the crash.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Add &lt;code&gt;enableServiceLinks: false&lt;/code&gt; to the pod spec:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;enableServiceLinks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;   &lt;span class="c1"&gt;# prevents K8s service env var injection&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;your-ecr/schema-registry:7.5.0-msk&lt;/span&gt;
          &lt;span class="c1"&gt;# ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells Kubernetes to skip environment variable injection from service discovery for this pod. Your own explicitly-defined env vars (like &lt;code&gt;SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS&lt;/code&gt;) are unaffected.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Same issue hits Kafka broker pods.&lt;/strong&gt; Any Confluent image that uses the &lt;code&gt;KAFKA_&lt;/code&gt; or &lt;code&gt;SCHEMA_REGISTRY_&lt;/code&gt; env var convention will be crashed by K8s service link injection. Always set &lt;code&gt;enableServiceLinks: false&lt;/code&gt; on these deployments.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Layer 2: The MSK IAM Auth JAR Doesn't Reach the JVM
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Schema registry starts but immediately fails to connect to MSK Serverless:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR org.apache.kafka.clients.NetworkClient - [Producer clientId=...] 
Connection to node -1 (b-1.xxx.kafka.us-east-1.amazonaws.com/...) failed 
authentication due to: SSL handshake failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or worse — it silently retries PLAINTEXT/SSL when what MSK Serverless requires is SASL/OAUTHBEARER.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Root cause:&lt;/strong&gt; MSK Serverless &lt;em&gt;only&lt;/em&gt; supports IAM (SASL/OAUTHBEARER). The Confluent 7.5 base image doesn't include the &lt;code&gt;aws-msk-iam-auth&lt;/code&gt; JAR. You need to add it to the JVM classpath. But there's a catch: &lt;strong&gt;Confluent's entrypoint scripts call &lt;code&gt;java&lt;/code&gt; directly and ignore the &lt;code&gt;CLASSPATH&lt;/code&gt; environment variable.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Setting &lt;code&gt;CLASSPATH=/path/to/aws-msk-iam-auth.jar&lt;/code&gt; in your deployment manifest does nothing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Build a custom image that bakes the JAR directly into the directory Confluent's scripts scan:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; confluentinc/cp-schema-registry:7.5.0&lt;/span&gt;

&lt;span class="c"&gt;# Confluent's kafka-run-class hardcodes /usr/share/java/schema-registry/*&lt;/span&gt;
&lt;span class="c"&gt;# and does NOT honour the CLASSPATH env var — the JAR must be here.&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; root&lt;/span&gt;
&lt;span class="k"&gt;ADD&lt;/span&gt;&lt;span class="s"&gt; https://repo1.maven.org/maven2/software/amazon/msk/aws-msk-iam-auth/2.3.2/aws-msk-iam-auth-2.3.2-all.jar \&lt;/span&gt;
    /usr/share/java/schema-registry/aws-msk-iam-auth.jar
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;644 /usr/share/java/schema-registry/aws-msk-iam-auth.jar
&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; appuser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;ADD&lt;/code&gt; with the Maven Central URL means you don't need to manage the JAR locally — Docker pulls it at build time. The &lt;code&gt;USER root&lt;/code&gt; / &lt;code&gt;USER appuser&lt;/code&gt; sandwich is required because Confluent's base image runs as &lt;code&gt;appuser&lt;/code&gt; (uid 1000) by default, but writing to &lt;code&gt;/usr/share/java/schema-registry/&lt;/code&gt; requires root.&lt;/p&gt;

&lt;p&gt;Then configure the SASL settings in your env vars:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;b-1.xxx.kafka.us-east-1.amazonaws.com:9098"&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SECURITY_PROTOCOL&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SASL_SSL"&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SASL_MECHANISM&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AWS_MSK_IAM"&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SASL_JAAS_CONFIG&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;software.amazon.msk.auth.iam.IAMLoginModule&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;required;"&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SASL_CLIENT_CALLBACK_HANDLER_CLASS&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;software.amazon.msk.auth.iam.IAMClientCallbackHandler"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key is that &lt;code&gt;/usr/share/java/schema-registry/&lt;/code&gt; is the directory Confluent's launch scripts automatically add to the JVM classpath via wildcard (&lt;code&gt;-cp /usr/share/java/schema-registry/*&lt;/code&gt;). Putting your JAR there means it's picked up without any script modification.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Why not CLASSPATH?&lt;/strong&gt; The Confluent Docker image uses launch scripts that construct the &lt;code&gt;java&lt;/code&gt; command internally. The &lt;code&gt;CLASSPATH&lt;/code&gt; env var is only used if &lt;code&gt;java&lt;/code&gt; is invoked without explicit &lt;code&gt;-cp&lt;/code&gt;/&lt;code&gt;-classpath&lt;/code&gt; flags. Confluent sets its own &lt;code&gt;-cp&lt;/code&gt;, so your &lt;code&gt;CLASSPATH&lt;/code&gt; override is ignored.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Layer 3: The Ensure Script Fails Pre-Flight Checks
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Symptom:&lt;/strong&gt; Pod starts, gets past the JAR loading, but then hangs for minutes before failing with a connectivity error — even though MSK is accessible. Or it fails immediately with an obscure error from the Confluent &lt;code&gt;ensure&lt;/code&gt; script.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Root cause:&lt;/strong&gt; The Confluent Docker image runs &lt;code&gt;/etc/confluent/docker/ensure&lt;/code&gt; as a pre-flight check before launching Schema Registry. This script attempts to connect to Kafka to verify bootstrap connectivity. In the EKS environment, it may run before your IRSA credentials are fully available, or it uses a different code path that doesn't pick up the IAM auth callback handler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Override the &lt;code&gt;ensure&lt;/code&gt; script with a no-op via a ConfigMap subPath mount:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ConfigMap&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ConfigMap&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-scripts&lt;/span&gt;
&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;ensure&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;#!/bin/bash&lt;/span&gt;
    &lt;span class="s"&gt;# No-op: pre-flight connectivity check skipped in EKS.&lt;/span&gt;
    &lt;span class="s"&gt;# IRSA credentials are injected at runtime; the ensure script&lt;/span&gt;
    &lt;span class="s"&gt;# runs before the IAM token exchange is complete.&lt;/span&gt;
    &lt;span class="s"&gt;exit 0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# In the Deployment spec&lt;/span&gt;
&lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-scripts&lt;/span&gt;
    &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/etc/confluent/docker/ensure&lt;/span&gt;
    &lt;span class="na"&gt;subPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ensure&lt;/span&gt;
&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-scripts&lt;/span&gt;
    &lt;span class="na"&gt;configMap&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-scripts&lt;/span&gt;
      &lt;span class="na"&gt;defaultMode&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0755&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;subPath: ensure&lt;/code&gt; mount replaces only that single file in the container's filesystem — the rest of &lt;code&gt;/etc/confluent/docker/&lt;/code&gt; is untouched. The &lt;code&gt;defaultMode: 0755&lt;/code&gt; ensures the script is executable.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Is this safe?&lt;/strong&gt; The &lt;code&gt;ensure&lt;/code&gt; script's job is to verify connectivity before startup. Since Schema Registry itself will retry connectivity on startup with proper retry/backoff logic, skipping the pre-flight check doesn't lose safety — it just removes a redundant check that doesn't understand your auth setup anyway.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Complete Custom Image
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; confluentinc/cp-schema-registry:7.5.0&lt;/span&gt;

&lt;span class="c"&gt;# Confluent's kafka-run-class hardcodes /usr/share/java/schema-registry/*&lt;/span&gt;
&lt;span class="c"&gt;# and does NOT honour the CLASSPATH env var — the JAR must be here.&lt;/span&gt;
&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; root&lt;/span&gt;
&lt;span class="k"&gt;ADD&lt;/span&gt;&lt;span class="s"&gt; https://repo1.maven.org/maven2/software/amazon/msk/aws-msk-iam-auth/2.3.2/aws-msk-iam-auth-2.3.2-all.jar \&lt;/span&gt;
    /usr/share/java/schema-registry/aws-msk-iam-auth.jar
&lt;span class="k"&gt;RUN &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;644 /usr/share/java/schema-registry/aws-msk-iam-auth.jar
&lt;span class="k"&gt;USER&lt;/span&gt;&lt;span class="s"&gt; appuser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build and push to ECR:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; &amp;lt;account-id&amp;gt;.dkr.ecr.us-east-1.amazonaws.com/ai-platform/schema-registry:7.5.0-msk &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-f&lt;/span&gt; docker/schema-registry/Dockerfile docker/schema-registry/

aws ecr get-login-password &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1 | &lt;span class="se"&gt;\&lt;/span&gt;
  docker login &lt;span class="nt"&gt;--username&lt;/span&gt; AWS &lt;span class="nt"&gt;--password-stdin&lt;/span&gt; &amp;lt;account-id&amp;gt;.dkr.ecr.us-east-1.amazonaws.com

docker push &amp;lt;account-id&amp;gt;.dkr.ecr.us-east-1.amazonaws.com/ai-platform/schema-registry:7.5.0-msk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Full Deployment Manifest
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;apps/v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry&lt;/span&gt;
  &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;microservices&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Recreate&lt;/span&gt;   &lt;span class="c1"&gt;# rolling update with 2 concurrent pods is toxic on MSK consumer groups&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;matchLabels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;enableServiceLinks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;   &lt;span class="c1"&gt;# Layer 1: prevents K8s service env var injection&lt;/span&gt;
      &lt;span class="na"&gt;serviceAccountName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-sa&lt;/span&gt;  &lt;span class="c1"&gt;# IRSA service account&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;&amp;lt;account-id&amp;gt;.dkr.ecr.us-east-1.amazonaws.com/ai-platform/schema-registry:7.5.0-msk&lt;/span&gt;
          &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8081&lt;/span&gt;
          &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_HOST_NAME&lt;/span&gt;
              &lt;span class="na"&gt;valueFrom&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="na"&gt;fieldRef&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                  &lt;span class="na"&gt;fieldPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;status.podIP&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_LISTENERS&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://0.0.0.0:8081"&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;b-1.xxx.kafka.us-east-1.amazonaws.com:9098"&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SECURITY_PROTOCOL&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;SASL_SSL"&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SASL_MECHANISM&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;AWS_MSK_IAM"&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SASL_JAAS_CONFIG&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;software.amazon.msk.auth.iam.IAMLoginModule&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;required;"&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SCHEMA_REGISTRY_KAFKASTORE_SASL_CLIENT_CALLBACK_HANDLER_CLASS&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;software.amazon.msk.auth.iam.IAMClientCallbackHandler"&lt;/span&gt;
          &lt;span class="na"&gt;startupProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/subjects&lt;/span&gt;
              &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8081&lt;/span&gt;
            &lt;span class="na"&gt;failureThreshold&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;
            &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;   &lt;span class="c1"&gt;# 300s total — _schemas topic sync can take a while&lt;/span&gt;
          &lt;span class="na"&gt;livenessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/subjects&lt;/span&gt;
              &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8081&lt;/span&gt;
            &lt;span class="na"&gt;initialDelaySeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60&lt;/span&gt;
            &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30&lt;/span&gt;
          &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-scripts&lt;/span&gt;
              &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/etc/confluent/docker/ensure&lt;/span&gt;
              &lt;span class="na"&gt;subPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ensure&lt;/span&gt;   &lt;span class="c1"&gt;# Layer 3: override ensure script&lt;/span&gt;
      &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-scripts&lt;/span&gt;
          &lt;span class="na"&gt;configMap&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;schema-registry-scripts&lt;/span&gt;
            &lt;span class="na"&gt;defaultMode&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0755&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Why Each Layer Was Non-Obvious
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;What made it hard to spot&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;enableServiceLinks: false&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The error message blames &lt;code&gt;SCHEMA_REGISTRY_PORT&lt;/code&gt; being invalid — doesn't mention Kubernetes service injection at all&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Custom Dockerfile with JAR&lt;/td&gt;
&lt;td&gt;The &lt;code&gt;CLASSPATH&lt;/code&gt; env var &lt;em&gt;looks&lt;/em&gt; like it should work; the fact that Confluent ignores it is undocumented&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No-op &lt;code&gt;ensure&lt;/code&gt; script&lt;/td&gt;
&lt;td&gt;The &lt;code&gt;ensure&lt;/code&gt; failure is a pre-flight check exit, which looks like a connection error — masks that IRSA credentials weren't ready&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The real lesson: when you combine a third-party container image with a managed cloud service and a container orchestrator, each one adds an invisible layer of convention. The debug process is peeling them back one at a time — which is exactly why the error messages never tell you the right thing.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Smoke Test
&lt;/h2&gt;

&lt;p&gt;After all three layers are resolved, Schema Registry starts clean and the MSK Serverless connection goes through IAM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# From inside the EKS cluster&lt;/span&gt;
kubectl &lt;span class="nb"&gt;exec&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; microservices deploy/user-service &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  curl &lt;span class="nt"&gt;-s&lt;/span&gt; http://schema-registry:8081/subjects
&lt;span class="c"&gt;# -&amp;gt; []  (empty on first boot, connection confirmed)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the full path: POST /api/v1/users through the ALB → user-service → MSK Serverless (via Schema Registry for Avro serialization) → notification-service consumer. HTTP 201.&lt;/p&gt;




&lt;p&gt;Have you run into similar layering conflicts when combining third-party container images with managed cloud services on Kubernetes? Which of these three layers caught you most off-guard?&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>aws</category>
      <category>kafka</category>
      <category>java</category>
    </item>
    <item>
      <title>Five Things Kubernetes Quietly Added to My Containers (And How Each One Broke a Confluent Service)</title>
      <dc:creator>Ramesh Yara</dc:creator>
      <pubDate>Mon, 07 Sep 2026 19:24:03 +0000</pubDate>
      <link>https://dev.to/ramesh-yara/five-things-kubernetes-quietly-added-to-my-containers-and-how-each-one-broke-a-confluent-service-108m</link>
      <guid>https://dev.to/ramesh-yara/five-things-kubernetes-quietly-added-to-my-containers-and-how-each-one-broke-a-confluent-service-108m</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@yara.ramesh/five-things-kubernetes-quietly-added-to-my-containers-and-how-each-one-broke-a-confluent-service-972d621916fd" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;When I moved a full Confluent Kafka stack into a Kubernetes cluster, five things broke. Each one looked like a configuration mistake I had made. None of them were.&lt;/p&gt;

&lt;p&gt;Every failure came from something Kubernetes added to my containers without being asked — a default behavior that is correct in the general case and a silent hazard for these specific images. Here is what each one did and the fix.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Kubernetes injected a variable that crashed the Kafka broker
&lt;/h3&gt;

&lt;p&gt;The broker came up for a few seconds, then died. The log said the advertised listener address was pointing to a TCP socket URL — something like &lt;code&gt;tcp://10.96.0.1:9092&lt;/code&gt; — instead of a hostname. I had set the advertised listener explicitly. Something had overridden it.&lt;/p&gt;

&lt;p&gt;Kubernetes had.&lt;/p&gt;

&lt;p&gt;By default, every pod in a namespace receives environment variables for every Service in that namespace. For a Service named &lt;code&gt;kafka&lt;/code&gt;, Kubernetes injects &lt;code&gt;KAFKA_PORT=tcp://10.96.0.1:9092&lt;/code&gt;, &lt;code&gt;KAFKA_SERVICE_HOST=10.96.0.1&lt;/code&gt;, and several more. This is a legacy feature from the Docker links era, on by default for backwards compatibility.&lt;/p&gt;

&lt;p&gt;The Confluent Kafka image maps every environment variable prefixed with &lt;code&gt;KAFKA_&lt;/code&gt; directly to a broker configuration key. The injected &lt;code&gt;KAFKA_PORT&lt;/code&gt; variable landed in that mapping, overrode the advertised listener I had configured, and produced an invalid broker config. The crash log blamed the configuration value — not the source of it.&lt;/p&gt;

&lt;p&gt;The Confluent Schema Registry image has the same convention with &lt;code&gt;SCHEMA_REGISTRY_*&lt;/code&gt; prefixed variables. A Service named &lt;code&gt;schema-registry&lt;/code&gt; injects &lt;code&gt;SCHEMA_REGISTRY_PORT&lt;/code&gt;, which the image reads as a configuration for its deprecated &lt;code&gt;PORT&lt;/code&gt; key.&lt;/p&gt;

&lt;p&gt;The fix is one field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;enableServiceLinks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both the broker and Schema Registry came up cleanly once service link injection was disabled on their pod specs.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. CPU limits without requests made every pod Pending
&lt;/h3&gt;

&lt;p&gt;After the broker came up, all eight pods went Pending simultaneously. &lt;code&gt;kubectl describe pod&lt;/code&gt; showed &lt;code&gt;Insufficient cpu&lt;/code&gt; on every one of them. The node had 2 CPU cores and nothing was running on it.&lt;/p&gt;

&lt;p&gt;The cause was how Kubernetes handles resource specs with only &lt;code&gt;limits&lt;/code&gt; defined. When a container specifies &lt;code&gt;resources.limits.cpu&lt;/code&gt; but omits &lt;code&gt;resources.requests.cpu&lt;/code&gt;, Kubernetes silently sets the request equal to the limit. With eight pods each carrying an implicit 500m CPU request, the scheduler saw 4000m of demand against a 2000m node. All eight were Unschedulable before a single one started.&lt;/p&gt;

&lt;p&gt;The fix is an explicit minimal request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1m&lt;/span&gt;
    &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512Mi&lt;/span&gt;
  &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;cpu&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;500m&lt;/span&gt;
    &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;1m&lt;/code&gt; is nominal — it tells the scheduler that the container needs one millicore of guaranteed scheduling capacity, not 500m. The scheduler placed all eight pods immediately.&lt;/p&gt;

&lt;p&gt;The rule generalizes: omitting &lt;code&gt;requests&lt;/code&gt; does not mean "no CPU requirement." It means "requirement equals limit." For a stack of JVM services alongside Kafka and a database, the implicit math almost always exhausts the node before a single pod starts.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. The default probe timeout was 1 second — and the JVM needed 3
&lt;/h3&gt;

&lt;p&gt;With pods scheduled, the next issue surfaced: MySQL and PostgreSQL were intermittently NotReady, causing cascading &lt;code&gt;Connection refused&lt;/code&gt; errors in the Spring Boot services.&lt;/p&gt;

&lt;p&gt;The default &lt;code&gt;timeoutSeconds&lt;/code&gt; for Kubernetes probes is 1 second. Under Docker Desktop and WSL2, &lt;code&gt;mysqladmin ping&lt;/code&gt; and &lt;code&gt;pg_isready&lt;/code&gt; routinely take 1–3 seconds to respond even on fully initialized databases. Overlayfs plus a constrained CPU budget introduces latency that doesn't exist on a local host process.&lt;/p&gt;

&lt;p&gt;When a 1-second timeout fires against a database that takes 1.5 seconds to respond, Kubernetes marks the pod NotReady and removes it from the Service endpoint list. Any connection pool — Hikari — that opens a connection during that window hits &lt;code&gt;Connection refused&lt;/code&gt; from the cluster's DNS resolver, not from the database itself. The error looks like a connectivity problem in the application.&lt;/p&gt;

&lt;p&gt;Raising the timeout resolved it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;timeoutSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;span class="na"&gt;startupProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;timeoutSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The 1-second default is appropriate for bare-metal or cloud clusters where probe responses are in the sub-100ms range. In a local WSL2 environment it fires spurious failures that cascade through every service that depends on the probed component.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Keycloak's health endpoint wasn't where the probe was looking
&lt;/h3&gt;

&lt;p&gt;Keycloak also had a probe problem, but a different one.&lt;/p&gt;

&lt;p&gt;In Keycloak's production mode (&lt;code&gt;start&lt;/code&gt;), the health endpoints live on the management port — port 9000. In development mode (&lt;code&gt;start-dev&lt;/code&gt;), only port 8080 is opened. Port 9000 is silent.&lt;/p&gt;

&lt;p&gt;My probe was checking &lt;code&gt;/health/ready&lt;/code&gt; on port 9000. It was timing out against a port that didn't exist, leaving Keycloak permanently NotReady.&lt;/p&gt;

&lt;p&gt;Fixing the port was necessary but not sufficient. &lt;code&gt;/health/ready&lt;/code&gt; on port 8080 returns 404 in both modes. The correct readiness signal for Keycloak in this setup is the realm endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;readinessProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/realms/ai-microservices&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The realm endpoint returns 200 only after Keycloak's Liquibase migration has run and the realm has been imported from the ConfigMap. It verifies that the actual downstream dependency — token issuance — is ready, not just that the process started.&lt;/p&gt;

&lt;p&gt;The startup window also needs to account for Keycloak's real initialization time. On WSL2, &lt;code&gt;start-dev&lt;/code&gt; takes 8–20 minutes from pod creation to a valid realm response. The startup probe failureThreshold needs to be set accordingly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;startupProbe&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;httpGet&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/realms/ai-microservices&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
  &lt;span class="na"&gt;failureThreshold&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;120&lt;/span&gt;
  &lt;span class="na"&gt;periodSeconds&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  5. A rolling update killed Schema Registry — permanently
&lt;/h3&gt;

&lt;p&gt;With everything stable, I issued a &lt;code&gt;kubectl apply&lt;/code&gt; to update the Schema Registry deployment. The new pod came up alongside the old one — standard rolling update behavior — and Schema Registry died in that window and never recovered.&lt;/p&gt;

&lt;p&gt;Schema Registry uses Kafka as its backing store and participates in a Kafka consumer group to elect a leader that coordinates reads and writes to the &lt;code&gt;_schemas&lt;/code&gt; topic. When two Schema Registry pods run simultaneously — even briefly during a rolling update — both attempt to join the consumer group. Kafka triggers a partition rebalance.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;KafkaGroupLeaderElector&lt;/code&gt; thread that manages Schema Registry's leadership does not survive that rebalance. It exits with &lt;code&gt;LEADER_NOT_AVAILABLE&lt;/code&gt; and does not restart. All subsequent requests to register or retrieve schemas fail until the pod is manually restarted.&lt;/p&gt;

&lt;p&gt;With a single replica, every rolling update creates a two-pod window. The fix is to use &lt;code&gt;Recreate&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;strategy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Recreate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Recreate&lt;/code&gt; terminates the old pod before starting the new one. No two-pod window, no rebalance. At single-replica scale the tradeoff is brief unavailability during the update — acceptable because the platform's transactional outbox absorbs the gap rather than losing events.&lt;/p&gt;




&lt;h3&gt;
  
  
  What these five have in common
&lt;/h3&gt;

&lt;p&gt;Each failure was documented Kubernetes behavior. None of them were bugs. Each one was a default designed for a broad set of workloads that happened to be wrong for this specific combination of images and topology.&lt;/p&gt;

&lt;p&gt;Service link injection exists to help containers discover other services. Implicit request-equals-limit exists to prevent pods from being unschedulable when only limits are set. The 1-second probe timeout exists because most health endpoints are fast. Rolling update semantics exist because most applications can run multiple instances during a deploy.&lt;/p&gt;

&lt;p&gt;Confluent images that interpret &lt;code&gt;KAFKA_*&lt;/code&gt; environment variables as configuration, JVM startup latency under WSL2, Keycloak's development-mode port behavior, and Schema Registry's single-leader election model are each correct on their own. The failures come from the intersection.&lt;/p&gt;

&lt;p&gt;The practical checklist that came out of this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;enableServiceLinks: false&lt;/code&gt; on every Confluent image (Kafka, Schema Registry) — and any image that reads its own name as an env var prefix.&lt;/li&gt;
&lt;li&gt;Explicit &lt;code&gt;requests.cpu&lt;/code&gt; on every container, even if it's nominal.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;timeoutSeconds: 5&lt;/code&gt; on readiness and startup probes in any local cluster.&lt;/li&gt;
&lt;li&gt;Read the image's health endpoint documentation, not the Kubernetes docs, to find the correct probe path and port for each version.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;strategy: Recreate&lt;/code&gt; for any single-replica service that participates in leader election.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All five are now set in every manifest I write for this stack.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This platform — Spring Boot 4, Java 21, Kafka, Keycloak, and a full in-cluster observability stack — is open-source: &lt;a href="https://github.com/Rummy43/ai-microservices-platform" rel="noopener noreferrer"&gt;github.com/Rummy43/ai-microservices-platform&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>kafka</category>
      <category>devops</category>
      <category>java</category>
    </item>
    <item>
      <title>The Outbox Pattern Is Not Enough</title>
      <dc:creator>Ramesh Yara</dc:creator>
      <pubDate>Mon, 17 Aug 2026 21:04:50 +0000</pubDate>
      <link>https://dev.to/ramesh-yara/the-outbox-pattern-is-not-enough-28g1</link>
      <guid>https://dev.to/ramesh-yara/the-outbox-pattern-is-not-enough-28g1</guid>
      <description>&lt;p&gt;The textbook version of the transactional outbox is tight. You save the domain entity and an outbox row in one local transaction. A background scheduler picks up &lt;code&gt;PENDING&lt;/code&gt; rows and publishes them to Kafka. You never publish inside the request thread — no dual-write, no atomicity breach. The pattern closes the consistency gap.&lt;/p&gt;

&lt;p&gt;Then you load-test it.&lt;/p&gt;

&lt;p&gt;I ran 1,000 authenticated requests through my event-driven platform in 70 seconds. The gateway returned &lt;code&gt;201&lt;/code&gt; for every one of them. The outbox absorbed every row. The consumer drained everything. By every visible metric the system looked healthy. Underneath that health, I found three production-grade problems the textbook never mentioned.&lt;/p&gt;




&lt;h2&gt;
  
  
  What a correct implementation looks like
&lt;/h2&gt;

&lt;p&gt;Before the problems, the shape of the solution. The outbox publisher runs on a &lt;code&gt;@Scheduled&lt;/code&gt; virtual-thread worker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Scheduled&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fixedDelay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Transactional&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;publishPendingEvents&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;OutboxEvent&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;outboxRepository&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findTop20ByStatusOrderByCreatedAtAsc&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OutboxStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PENDING&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OutboxEvent&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;batch&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setStatus&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OutboxStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PROCESSING&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;outboxRepository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;save&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;kafkaTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getTopic&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getPayload&lt;/span&gt;&lt;span class="o"&gt;()).&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setStatus&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OutboxStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PUBLISHED&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;incrementRetryCount&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRetryCount&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="no"&gt;MAX_RETRIES&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setStatus&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OutboxStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;FAILED&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setStatus&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OutboxStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PENDING&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
            &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;outboxRepository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;save&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is correct. The &lt;code&gt;PROCESSING&lt;/code&gt; state prevents another scheduler instance from claiming the same row. The retry cap prevents infinite cycling. The &lt;code&gt;PENDING&lt;/code&gt; fallback on transient errors gives the event another chance. The dual-write problem is genuinely closed.&lt;/p&gt;

&lt;p&gt;Here is what that correctness does not cover.&lt;/p&gt;




&lt;h2&gt;
  
  
  Gap 1: Your throughput ceiling is a config line
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;fixedDelay = 5000&lt;/code&gt; means the scheduler runs every 5 seconds. &lt;code&gt;findTop20&lt;/code&gt; means it picks up 20 rows per cycle.&lt;/p&gt;

&lt;p&gt;Maximum publish throughput: &lt;strong&gt;20 events ÷ 5 seconds = 4 events per second.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That number does not appear in your unit tests. It does not appear in your monitoring unless you specifically look for it. It is a ceiling determined by two config values chosen without measurement.&lt;/p&gt;

&lt;p&gt;During the 1,000-event baseline run, the gateway processed ~14.3 requests per second. The publisher was draining at 4 per second. The backlog grew to 720 rows before the burst ended and the scheduler caught up. &lt;code&gt;outbox_oldest_pending_age_seconds&lt;/code&gt; — the gauge that measures the age of the oldest &lt;code&gt;PENDING&lt;/code&gt; row — peaked at &lt;strong&gt;191 seconds&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[outbox burst profile]
t=0s    → 1,000 requests fire at 14.3 req/s
t=70s   → all 1,000 return HTTP 201; 720 rows queued
t=70s+  → publisher drains at 4 ev/s (~3 minutes to clear)
         outbox_oldest_pending_age_seconds peak: 191s
t=250s  → backlog reaches 0; gauge returns to 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;&lt;code&gt;outbox_oldest_pending_age_seconds&lt;/code&gt; — a 200-request parallel burst. Age climbs to 110s as inbound rate outpaces the publisher, then drops to zero. The 07-17 baseline (1,000 requests at 14.3 req/s) peaked at 191s and took 3 minutes to drain.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The system worked correctly. No events were lost. No data was corrupted. But the freshness SLO — "events delivered within 30 seconds of creation" — was structurally impossible to meet at any input rate above 4 req/s. The ceiling isn't a bug. It's a design constant hiding in plain sight.&lt;/p&gt;

&lt;p&gt;The honest version of a freshness SLO for this system is: &lt;em&gt;"Events are delivered within 30 seconds, given input rates below 4 req/s."&lt;/em&gt; That constraint belongs in your SLO catalog, not buried in two config lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# SLO catalog entry — what honest capacity accounting looks like&lt;/span&gt;
&lt;span class="na"&gt;freshness_slo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;target&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;99.9% of events published within 30s of creation&lt;/span&gt;
  &lt;span class="na"&gt;constraint&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;input rate ≤ 4 ev/s (fixedDelay=5000ms × batchSize=20)&lt;/span&gt;
  &lt;span class="na"&gt;at_higher_rates&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;freshness degrades proportionally; availability unaffected&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Gap 2: The alert you write will fire for the wrong reason
&lt;/h2&gt;

&lt;p&gt;The natural monitoring instinct for the outbox is an age threshold:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OutboxBacklogAgeHigh&lt;/span&gt;
  &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;outbox_oldest_pending_age_seconds &amp;gt; &lt;/span&gt;&lt;span class="m"&gt;60&lt;/span&gt;
  &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5m&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;page&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During the 720-row burst, &lt;code&gt;outbox_oldest_pending_age_seconds&lt;/code&gt; crossed 191 seconds. The threshold is 60 seconds. Two rules went &lt;code&gt;pending&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Neither fired.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;for: 5m&lt;/code&gt; clause — which distinguishes a transient burst from a sustained incident — held. The burst resolved in under 5 minutes. Both rules sat pending through the whole event and silently cleared when the backlog drained.&lt;/p&gt;

&lt;p&gt;That is the correct behavior. But it is only correct if you understand why the window exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The naive response to a pending alert is to shorten the window.&lt;/strong&gt; Drop &lt;code&gt;for:&lt;/code&gt; from 5 minutes to 30 seconds to "catch problems faster." What you actually get is pages for every deployment spike, every cold-start burst, every Schema Registry restart. The alert stops being a signal and becomes noise that engineers learn to dismiss — which is worse than no alert at all.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;for:&lt;/code&gt; duration is where you encode your operational definition of incident. The 720-row burst at 191 seconds is a &lt;em&gt;load event&lt;/em&gt;: the system is processing work faster than it can publish, and it will self-resolve when the input rate drops. A broker offline for 7 minutes is an &lt;em&gt;incident&lt;/em&gt;: the backlog grows indefinitely and the oldest-age gauge only increases.&lt;/p&gt;

&lt;p&gt;You cannot calibrate that boundary by intuition. You need to run a burst that is definitively not an incident — a known-finite load, system otherwise healthy — and measure the oldest-age peak. Then set &lt;code&gt;for:&lt;/code&gt; so that peak does not fire. In this system: 191s peak, 5-minute &lt;code&gt;for:&lt;/code&gt; window, zero false positives across every deployment and cold-start since.&lt;/p&gt;




&lt;h2&gt;
  
  
  Gap 3: The terminal state is invisible by design
&lt;/h2&gt;

&lt;p&gt;This is the one that costs you.&lt;/p&gt;

&lt;p&gt;When the publisher exhausts its retry budget, the row becomes &lt;code&gt;FAILED&lt;/code&gt; and the scheduler never touches it again. Your &lt;code&gt;outbox_oldest_pending_age_seconds&lt;/code&gt; goes back to zero — there are no more &lt;code&gt;PENDING&lt;/code&gt; rows to report age for. Your backlog count goes to zero. Your age alert stays silent.&lt;/p&gt;

&lt;p&gt;The event is gone. No notification was sent. No audit trail was written downstream. Nothing alerted.&lt;/p&gt;

&lt;p&gt;This happened on my platform. During the cluster's first night, Schema Registry took approximately four minutes to become ready after a pod restart. The outbox publisher started immediately and encountered &lt;code&gt;Error registering Avro schema&lt;/code&gt; for every publish attempt. After five retries, five rows were marked &lt;code&gt;FAILED&lt;/code&gt; permanently.&lt;/p&gt;

&lt;p&gt;The Grafana dashboard showed a healthy system. The Prometheus alerts list showed no active rules. The &lt;code&gt;outbox_failed&lt;/code&gt; gauge was plotted on the business dashboard and showing 5. No one had wired a rule to it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Left: MySQL terminal FAILED rows. Right: Grafana outbox panel — &lt;code&gt;failed=5&lt;/code&gt;, no active alert. The "looks healthy" beat.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Those rows sat there for 24 hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The gauge without an alert is a decoration.&lt;/strong&gt; The &lt;code&gt;outbox_failed&lt;/code&gt; metric existed. It had a panel. It had a y-axis label. It had no operational consequence. The fix wasn't adding a new gauge — it was adding the rule that should have been there from the start:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;alert&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OutboxPublishTerminalFailure&lt;/span&gt;
  &lt;span class="na"&gt;expr&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;outbox_failed &amp;gt; &lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;
  &lt;span class="na"&gt;for&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2m&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;severity&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;page&lt;/span&gt;
    &lt;span class="na"&gt;slo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;outbox_integrity&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runbook&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://docs.internal/runbooks/outbox-failed&lt;/span&gt;
    &lt;span class="na"&gt;summary&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Terminal&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;FAILED&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;outbox&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;rows&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;detected&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;—&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;events&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;permanently&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;blocked"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;for: 2m&lt;/code&gt; gives the scheduler one extra cycle to confirm before paging. The severity is &lt;code&gt;page&lt;/code&gt; because &lt;code&gt;FAILED&lt;/code&gt; is a permanent state — unlike &lt;code&gt;PENDING&lt;/code&gt;, it never self-heals. The runbook names the re-drive query: update rows to &lt;code&gt;PENDING&lt;/code&gt;, identify the root cause (Schema Registry, broker auth, schema incompatibility), resolve it, let the publisher retry.&lt;/p&gt;

&lt;p&gt;Live-fire verified against a real condition: the FAILED rows described above triggered &lt;code&gt;OutboxPublishTerminalFailure&lt;/code&gt; after 2 minutes. Alertmanager delivered &lt;code&gt;[active] OutboxPublishTerminalFailure | severity=page | slo=outbox_integrity&lt;/code&gt;. Rows deleted. Alert auto-resolved in 30 seconds.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alertmanager: &lt;code&gt;OutboxPublishTerminalFailure&lt;/code&gt; ACTIVE — severity=page, slo=outbox_integrity, namespace=microservices. The pager delivery moment.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  The operational layer, assembled
&lt;/h2&gt;

&lt;p&gt;Three concrete additions on top of a correct outbox implementation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Name the throughput ceiling in your SLO catalog.&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;fixedDelay&lt;/code&gt; and &lt;code&gt;batchSize&lt;/code&gt; are not internal implementation details. They are your freshness SLO's capacity constraint. Make them visible, version them, and review them when input load changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Calibrate the age alert against measured burst data.&lt;/strong&gt;&lt;br&gt;
Run a known-safe burst. Record the oldest-age peak. Set &lt;code&gt;for:&lt;/code&gt; so the burst doesn't page. Re-run the calibration whenever you change the batch size or schedule interval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Alert unconditionally on FAILED, with severity page.&lt;/strong&gt;&lt;br&gt;
The terminal state has exactly the property that makes it most dangerous: it looks like a healthy system. Wire the rule, write the runbook, and treat every FAILED row as a lost event until the runbook says otherwise.&lt;/p&gt;




&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;p&gt;Everything above came from a 70-second load run on a JWT-authenticated, fully containerized platform:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Requests&lt;/td&gt;
&lt;td&gt;1,000 POST &lt;code&gt;/api/v1/users&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP 201&lt;/td&gt;
&lt;td&gt;1,000 (100%)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Availability SLI&lt;/td&gt;
&lt;td&gt;1.0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Latency SLI&lt;/td&gt;
&lt;td&gt;0.999&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p99 gateway / user-service&lt;/td&gt;
&lt;td&gt;186ms / 177ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Peak backlog&lt;/td&gt;
&lt;td&gt;720 rows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oldest-age peak&lt;/td&gt;
&lt;td&gt;191 seconds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Publisher rate&lt;/td&gt;
&lt;td&gt;~4 ev/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Consumer drain rate&lt;/td&gt;
&lt;td&gt;~150 ev/s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;False-positive alerts during burst&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Terminal failure was live-fired separately: synthetic &lt;code&gt;FAILED&lt;/code&gt; row inserted directly into the outbox table → &lt;code&gt;OutboxPublishTerminalFailure&lt;/code&gt; pending at &lt;code&gt;t=0&lt;/code&gt;, FIRING at &lt;code&gt;t=2m&lt;/code&gt; → Alertmanager severity=page delivered → row deleted → alert auto-resolved in 30 seconds.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The outbox closes the dual-write problem; it opens an operational one.&lt;/strong&gt; "Works correctly" and "is observable and bounded" are different properties.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your throughput ceiling is determined by two config values that most implementations never name.&lt;/strong&gt; Instrument it, measure it, put it in your SLO catalog.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;for:&lt;/code&gt; duration is where you define "incident."&lt;/strong&gt; Shortening it to catch faster is how alerts become noise. Calibrate it against real burst data, not intuition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A gauge without an alert is a decoration.&lt;/strong&gt; The terminal &lt;code&gt;FAILED&lt;/code&gt; state has exactly the property that makes it most dangerous: it looks like a healthy system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;FAILED rows never self-heal.&lt;/strong&gt; Alert on them unconditionally, with severity page, and with a runbook that names the re-drive query.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Honest SLOs require measurement.&lt;/strong&gt; A freshness target that doesn't name its throughput constraint is either vacuous or untested.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;The full implementation — outbox publisher, status lifecycle, &lt;code&gt;PENDING&lt;/code&gt;/&lt;code&gt;FAILED&lt;/code&gt; gauges, alert rules, and runbooks — is in the open-source repository:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Rummy43/ai-microservices-platform" rel="noopener noreferrer"&gt;https://github.com/Rummy43/ai-microservices-platform&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What's the throughput ceiling of your outbox implementation, and have you measured it?&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>distributedsystems</category>
      <category>microservices</category>
      <category>springboot</category>
    </item>
    <item>
      <title>Who Did This? Identity Across Async Boundaries</title>
      <dc:creator>Ramesh Yara</dc:creator>
      <pubDate>Sun, 09 Aug 2026 18:20:05 +0000</pubDate>
      <link>https://dev.to/ramesh-yara/who-did-this-identity-across-async-boundaries-1n4n</link>
      <guid>https://dev.to/ramesh-yara/who-did-this-identity-across-async-boundaries-1n4n</guid>
      <description>&lt;p&gt;You put a lot of work into authentication. A gateway validates the Keycloak JWT, maps realm roles to authorities, checks that the caller is allowed. By the time a request reaches your service, you know exactly who is calling.&lt;/p&gt;

&lt;p&gt;Then the request crosses into async land, and all of that evaporates.&lt;/p&gt;

&lt;p&gt;This is the story of the point where identity quietly disappears in an event-driven system, why the dead-letter queue is the worst possible place for it to disappear, and how I made the acting user as durable and replay-safe as the event itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  The flow everyone believes is fine
&lt;/h3&gt;

&lt;p&gt;The platform is a set of Spring Boot services: an API gateway in front, a &lt;code&gt;user-service&lt;/code&gt; on MySQL, a &lt;code&gt;notification-service&lt;/code&gt; on PostgreSQL, and Kafka carrying events between them. A user is created, an event is published, a notification is sent.&lt;/p&gt;

&lt;p&gt;Authentication is handled at the edge. The gateway is an OAuth2 Resource Server; it validates the token once and propagates the caller's identity downstream as headers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// api-gateway — IdentityPropagationFilter (@Order(2), after security)&lt;/span&gt;
&lt;span class="nc"&gt;IdentityContext&lt;/span&gt; &lt;span class="n"&gt;identity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;identityContextExtractor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;extract&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jwt&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Always set all three headers (empty when absent) to mask any spoofed values.&lt;/span&gt;
&lt;span class="n"&gt;enrichedRequest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;putHeader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IdentityHeaders&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;USER_NAME&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;nullToEmpty&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;identity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;span class="n"&gt;enrichedRequest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;putHeader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IdentityHeaders&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;USER_EMAIL&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nullToEmpty&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;identity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="o"&gt;()));&lt;/span&gt;
&lt;span class="n"&gt;enrichedRequest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;putHeader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IdentityHeaders&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;USER_ROLES&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;identity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;rolesAsString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;DELIM&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One detail here matters more than it looks. The headers are &lt;strong&gt;always overwritten&lt;/strong&gt;, even when a claim is absent. If a client tries to inject &lt;code&gt;X-User-Name: admin&lt;/code&gt; on the inbound request, the gateway stomps it with the validated value (or empty). Downstream trust in those headers is only safe because the perimeter guarantees they cannot be forged. Miss that, and you've built an impersonation API.&lt;/p&gt;

&lt;p&gt;So far, so good. The synchronous hop carries identity. The problem starts one line later.&lt;/p&gt;

&lt;h3&gt;
  
  
  The hidden failure: the thread boundary
&lt;/h3&gt;

&lt;p&gt;I don't publish to Kafka inside the request. I use the transactional outbox pattern: the request persists the user &lt;strong&gt;and&lt;/strong&gt; an outbox row in one local transaction, and a separate scheduled poller publishes to Kafka afterward. (Why: a direct publish inside the request can commit the DB row and then lose the event if the broker call fails — the dual-write problem. The outbox closes that gap.)&lt;/p&gt;

&lt;p&gt;That decoupling is correct for delivery. It is also exactly where identity dies.&lt;/p&gt;

&lt;p&gt;The outbox publisher runs on a &lt;strong&gt;scheduled thread&lt;/strong&gt;, not the request thread. &lt;code&gt;SecurityContextHolder&lt;/code&gt;, &lt;code&gt;ThreadLocal&lt;/code&gt;, &lt;code&gt;MDC&lt;/code&gt; — every ambient place you might have stashed "who is calling" — are all empty by the time the poller runs. There is no request. There is no token. There is nothing to read.&lt;/p&gt;

&lt;p&gt;So the event goes out anonymous. The consumer logs anonymous. The notification is written anonymous. And when an event exhausts its retries and lands in the dead-letter queue — the one moment you will &lt;em&gt;urgently&lt;/em&gt; want to know who triggered it — the dead-letter row is anonymous too. Provenance vanishes at precisely the point forensics begins.&lt;/p&gt;

&lt;h3&gt;
  
  
  The naive fixes (and why each one fails)
&lt;/h3&gt;

&lt;p&gt;The tempting answers all fail at the same boundary:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Just log the username in the controller."&lt;/strong&gt; You can — but the log line you care about is the &lt;em&gt;publish&lt;/em&gt;, which happens later, on another thread, after the HTTP response has already returned. The controller log tells you a request arrived; it can't attribute the event that failed twenty seconds later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Stash it in MDC / a ThreadLocal and read it in the publisher."&lt;/strong&gt; The publisher isn't on your thread. MDC is thread-scoped; the scheduled poller starts with a clean, empty context. You'll read &lt;code&gt;null&lt;/code&gt; every time. Worse, under Virtual Threads with pooled carriers, a &lt;em&gt;stale&lt;/em&gt; ThreadLocal is a correctness hazard — you can leak one request's identity onto another's event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Re-read the JWT in the publisher."&lt;/strong&gt; There is no request in scope and no token to re-validate. The authentication event is long over.&lt;/p&gt;

&lt;p&gt;Every naive fix assumes identity lives in ambient thread state. Across an async boundary, ambient state is exactly what you don't have.&lt;/p&gt;

&lt;h3&gt;
  
  
  The production implementation: persist identity with the event
&lt;/h3&gt;

&lt;p&gt;If the publish is decoupled from the request in &lt;em&gt;time&lt;/em&gt; and &lt;em&gt;thread&lt;/em&gt;, then identity has to travel the same way the event does — &lt;strong&gt;as data, not as ambient context&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So I capture the actor on the request thread and persist it onto the outbox row, inside the same transaction as the entity write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// user-service — OutboxEventService (runs on the request thread)&lt;/span&gt;
&lt;span class="nc"&gt;IdentityContext&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;IdentityContextHolder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;orElse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;traceId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;MDC&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CorrelationConstants&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;TRACE_ID&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="nc"&gt;OutboxEvent&lt;/span&gt; &lt;span class="n"&gt;outboxEvent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;OutboxEvent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;builder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eventId&lt;/span&gt;&lt;span class="o"&gt;(...).&lt;/span&gt;&lt;span class="na"&gt;aggregateType&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"USER"&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;eventType&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"USER_CREATED"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;objectMapper&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;writeValueAsString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;OutboxEventStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;PENDING&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;actorUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actor&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;      &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;actorEmail&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;   &lt;span class="n"&gt;actor&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;         &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;actorRoles&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;   &lt;span class="n"&gt;actor&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;rolesAsString&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;traceId&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;traceId&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;outboxEventRepository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;save&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outboxEvent&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// same TX as the user write&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now identity is as durable as the event. It survives a crash, a restart, a redeploy — because it's a committed row, not a value on a dying thread.&lt;/p&gt;

&lt;p&gt;The scheduled publisher later rehydrates that context from the row and rides it onto the message as Kafka headers — supplied &lt;strong&gt;explicitly&lt;/strong&gt;, never read from MDC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// user-service — EventPublisher (runs on the scheduled outbox thread)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;publishUserCreatedEvent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;UserCreatedEvent&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;traceId&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;IdentityContext&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;ProducerRecord&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ProducerRecord&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;(&lt;/span&gt;&lt;span class="no"&gt;TOPIC&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getId&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;addHeader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;KAFKA_TRACE_ID_HEADER&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;traceId&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actor&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;addHeader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;KAFKA_USER_NAME&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="n"&gt;addHeader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;KAFKA_USER_EMAIL&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
        &lt;span class="n"&gt;addHeader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="no"&gt;KAFKA_USER_ROLES&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;rolesAsString&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;kafkaTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;send&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The consumer does the mirror operation: read the headers, rebind identity to the consumer thread and MDC so every log line is attributed — and, critically, &lt;strong&gt;clear it in a &lt;code&gt;finally&lt;/code&gt; block&lt;/strong&gt; so nothing bleeds into the next message on a reused thread:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="c1"&gt;// notification-service — KafkaConsumerService&lt;/span&gt;
&lt;span class="nc"&gt;IdentityContext&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;restoreIdentityContext&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userNameHeader&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;userEmailHeader&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;userRolesHeader&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;notificationService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;sendWelcomeNotification&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;partition&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;offset&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attempt&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;clearIdentityContext&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;          &lt;span class="c1"&gt;// MDC.remove(...) + IdentityContextHolder.clear()&lt;/span&gt;
    &lt;span class="no"&gt;MDC&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;remove&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CorrelationConstants&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;TRACE_ID&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A single immutable &lt;code&gt;IdentityContext&lt;/code&gt; record is the canonical "who is acting" shape at every hop — serialized to HTTP headers at the gateway, to a DB row in the outbox, to Kafka headers on publish, back to MDC on consume. It's deliberately transport-agnostic, so a sync→async hop never has to re-derive trust from the token.&lt;/p&gt;

&lt;p&gt;Here's the whole path, including the failure branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[HTTP request thread]                    [scheduled thread]           [consumer thread]
Gateway (validate JWT)                    Outbox Publisher             @KafkaListener
   │ X-User-* headers (overwritten)          │ read actor from row        │ read actor from headers
   ▼                                          ▼                            ▼ bind to MDC
user-service ──save user + outbox row──▶ outbox_events ──Kafka headers──▶ process + log (attributed)
             (one transaction: entity                                     │
              + actor_username/email/roles)                               │ retries exhausted
                                                                          ▼
                                                             @DltHandler → dead_letter_events
                                                             (actor_* columns persisted)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The payoff: the dead-letter queue keeps its memory
&lt;/h3&gt;

&lt;p&gt;The reason all of this is worth it lives in the &lt;code&gt;@DltHandler&lt;/code&gt;. When every retry is exhausted, the failed event is persisted for triage &lt;strong&gt;with the originating actor attached&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;deadLetterEventRepository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;save&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;DeadLetterEvent&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;builder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eventId&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getEventId&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lastError&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;errorMessage&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;actorUsername&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;actorEmail&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;actorRoles&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;roles&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;isEmpty&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;rolesAsString&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A dead letter without an actor is a mystery ticket. A dead letter &lt;em&gt;with&lt;/em&gt; one is an incident you can route, reproduce, and explain. The schema changes that back this are explicit migrations — Liquibase &lt;code&gt;actor_*&lt;/code&gt; + &lt;code&gt;trace_id&lt;/code&gt; on &lt;code&gt;outbox_events&lt;/code&gt; (MySQL), Flyway &lt;code&gt;actor_*&lt;/code&gt; on &lt;code&gt;dead_letter_events&lt;/code&gt; and &lt;code&gt;notification_log&lt;/code&gt; (PostgreSQL) — not &lt;code&gt;ddl-auto&lt;/code&gt; guesses.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verification: prove it survives the failure path
&lt;/h3&gt;

&lt;p&gt;Assertion isn't evidence. I verified the branch that matters — the failure one — by fault injection: force the notification step to fail so an event exhausts its four attempts and dead-letters, then read the audit table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;event_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;actor_username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;actor_email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;last_error&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt;   &lt;span class="n"&gt;dead_letter_events&lt;/span&gt;
&lt;span class="k"&gt;ORDER&lt;/span&gt;  &lt;span class="k"&gt;BY&lt;/span&gt; &lt;span class="n"&gt;failed_at&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;-- actor_username / actor_email populated on the failed row ✅&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The identity is there, on a &lt;em&gt;failed&lt;/em&gt; event, written by a background thread that never saw the original request. That's the whole thesis in one row.&lt;/p&gt;

&lt;p&gt;A subtle bonus: because identity rides Kafka headers as data, it survives even where distributed &lt;em&gt;tracing&lt;/em&gt; currently doesn't. On this platform the OTel agent doesn't yet emit Kafka spans (a gap I wrote about separately), so the async trace edge is blind — yet the actor still crosses it, because header-borne data doesn't depend on span instrumentation. Two independent propagation mechanisms; the durable one keeps working when the automatic one has a hole.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key takeaways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Authentication is not propagation.&lt;/strong&gt; Validating a token proves a request is allowed &lt;em&gt;now&lt;/em&gt;; it says nothing about who's behind the event that fails an hour later on another thread.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Across an async boundary, identity must be data, not ambient context.&lt;/strong&gt; ThreadLocal/MDC/SecurityContext are all empty on the publisher and consumer threads. Persist the actor with the event.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Attach identity in the same transaction as the write.&lt;/strong&gt; That's what makes it as durable and replay-safe as the event — surviving crashes, retries, and redeploys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The dead-letter queue is where provenance matters most and is usually lost.&lt;/strong&gt; Persisting &lt;code&gt;actor_*&lt;/code&gt; on the DLT row turns an anonymous mystery into a routable incident.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust in propagated headers requires an unspoofable perimeter.&lt;/strong&gt; Unconditionally overwrite &lt;code&gt;X-User-*&lt;/code&gt; at the gateway, or you've built impersonation-as-a-service.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clear context in &lt;code&gt;finally&lt;/code&gt;.&lt;/strong&gt; Under Virtual Threads and pooled consumers, a stale ThreadLocal is a cross-request correctness bug, not just untidy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The platform is open source — gateway, both services, the outbox, and this identity path end to end: &lt;a href="https://github.com/Rummy43/ai-microservices-platform" rel="noopener noreferrer"&gt;https://github.com/Rummy43/ai-microservices-platform&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When one of your events lands in the dead-letter queue tonight, can you tell who triggered it?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@yara.ramesh/who-did-this-identity-across-async-boundaries-823c712b073f" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>distributedsystems</category>
      <category>springboot</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Your Service Map Is Lying</title>
      <dc:creator>Ramesh Yara</dc:creator>
      <pubDate>Sun, 09 Aug 2026 18:10:22 +0000</pubDate>
      <link>https://dev.to/ramesh-yara/your-service-map-is-lying-4g47</link>
      <guid>https://dev.to/ramesh-yara/your-service-map-is-lying-4g47</guid>
      <description>&lt;p&gt;You attach the OpenTelemetry Java agent, point it at a collector, and within minutes Grafana is drawing a service map you never drew. A box for each service, arrows between them, latency on every edge. It feels like magic, and — more dangerously — it feels &lt;em&gt;complete&lt;/em&gt;. "The agent traces everything" is the sentence repeated in every onboarding doc.&lt;/p&gt;

&lt;p&gt;This is the story of the moment that sentence stopped being true on my platform, why I'm glad it did, and the difference between a system that is &lt;em&gt;working&lt;/em&gt; and a system you can actually &lt;em&gt;see&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The flow everyone trusts
&lt;/h3&gt;

&lt;p&gt;The platform is an event-driven set of Spring Boot services: an API gateway in front, a &lt;code&gt;user-service&lt;/code&gt; backed by MySQL, a &lt;code&gt;notification-service&lt;/code&gt; backed by PostgreSQL, and Kafka carrying events between them. A user is created, an event is published, a notification is sent.&lt;/p&gt;

&lt;p&gt;I didn't want to &lt;em&gt;draw&lt;/em&gt; that topology. A hand-drawn architecture diagram is documentation that drifts — true the day you commit it, slightly wrong a month later, actively misleading after a quarter. I wanted the dependency graph &lt;strong&gt;generated from live traffic&lt;/strong&gt;, so it would always reflect what the system actually does.&lt;/p&gt;

&lt;p&gt;Grafana Tempo does exactly this. Its &lt;code&gt;service-graphs&lt;/code&gt; processor reads matched client/server span pairs out of trace data and emits a metric — &lt;code&gt;traces_service_graph_request_total&lt;/code&gt; — that Grafana renders as a node graph. No edge is ever wired by hand. The topology is derived, continuously, from real spans.&lt;/p&gt;

&lt;h3&gt;
  
  
  The edge that wasn't there
&lt;/h3&gt;

&lt;p&gt;I generated the graph and the synchronous edges lit up immediately:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;api-gateway → user-service&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;user-service → MySQL&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;notification-service → PostgreSQL&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then I looked for the one edge I actually cared about — &lt;code&gt;user-service → notification-service&lt;/code&gt;, the asynchronous hop over Kafka.&lt;/p&gt;

&lt;p&gt;It wasn't there.&lt;/p&gt;

&lt;h3&gt;
  
  
  The naive conclusion (and why it's wrong)
&lt;/h3&gt;

&lt;p&gt;The tempting read is immediate and obvious: &lt;em&gt;the async hop is broken. The event isn't getting across. Go debug the consumer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So I checked. And the consumer was completely fine. &lt;code&gt;notification-service&lt;/code&gt; had consumed every event and written every corresponding row to PostgreSQL. Its database edge was lit. Liveness was perfect; the feature worked end to end.&lt;/p&gt;

&lt;p&gt;That is the trap. &lt;strong&gt;A missing edge looks exactly like a broken feature&lt;/strong&gt;, and the instinct is to go "fix" something that was never broken. The defect wasn't in the message path at all — it was in the &lt;em&gt;observability&lt;/em&gt; of the message path. Those are two different failure domains that happen to render identically on a dashboard.&lt;/p&gt;

&lt;p&gt;So I stopped trusting the picture and went to the source of truth: the trace store.&lt;/p&gt;

&lt;h3&gt;
  
  
  Evidence over assertion
&lt;/h3&gt;

&lt;p&gt;Two TraceQL queries settled it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ span.messaging.system = "kafka" }
→ 0 results
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{ resource.service.name = "user-service" } &amp;amp;&amp;amp; { resource.service.name = "notification-service" }
→ 0 traces
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zero Kafka messaging spans anywhere in the system. Zero traces spanning both services. The agent — this build, under this Spring Boot version — simply was not instrumenting the Kafka client. Nothing errored. No warning was logged. The map wasn't wrong about the data; &lt;strong&gt;the data was never produced&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is the part worth sitting with: a green dashboard would have let me believe the chain was fully traced. The absence of red is not the presence of coverage.&lt;/p&gt;

&lt;h3&gt;
  
  
  How the graph is actually built
&lt;/h3&gt;

&lt;p&gt;The pipeline that produces the map is worth seeing, because one of its links is &lt;em&gt;also&lt;/em&gt; a silent path you have to consciously turn on:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OTel Java Agent (spans)
        │
        ▼
Tempo  (service-graphs processor)
        │  remote_write
        ▼
Prometheus  (--web.enable-remote-write-receiver)
        │  query
        ▼
Grafana  (Tempo data source → serviceMap → nodeGraph)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three deliberate decisions shaped it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generated edges, not declared ones.&lt;/strong&gt; Tempo reads client/server span pairs and emits the edge metric. The graph is a test, not a drawing — it &lt;em&gt;fails&lt;/em&gt; when reality diverges from expectation, which is exactly what makes it valuable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One processor, scoped on purpose.&lt;/strong&gt; I enabled &lt;code&gt;service-graphs&lt;/code&gt; only — deliberately not &lt;code&gt;span-metrics&lt;/code&gt;. The latter generates RED/latency series and would have inflated cardinality for a deliverable that was strictly about topology. Minimal blast radius, single responsibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A push boundary you must open explicitly.&lt;/strong&gt; Tempo &lt;em&gt;remote-writes&lt;/em&gt; its generated metrics into Prometheus — the inverse of every other component, which Prometheus scrapes. That requires flipping Prometheus into a receiver with &lt;code&gt;--web.enable-remote-write-receiver&lt;/code&gt;. Forget it, and the metrics silently never land. Same lesson as the Kafka gap, one layer down: the data paths that fail quietly are the ones nobody turned on.&lt;/p&gt;

&lt;h3&gt;
  
  
  One missing edge, two real causes
&lt;/h3&gt;

&lt;p&gt;There's a subtlety the graph forced me to articulate. Even once the agent emits Kafka spans, the &lt;code&gt;user-service → notification-service&lt;/code&gt; edge would &lt;em&gt;still&lt;/em&gt; not look like a normal synchronous call — because my publish doesn't happen on the request thread.&lt;/p&gt;

&lt;p&gt;I use the transactional outbox pattern: the request persists the user and an outbox row in one local transaction, and a scheduled poller publishes to Kafka afterward. So the Kafka branch roots its &lt;em&gt;own&lt;/em&gt; trace, off the poll cycle, structurally separate from the originating HTTP request. That's the outbox decoupling working as designed — not a propagation bug.&lt;/p&gt;

&lt;p&gt;So a single missing edge had two distinct, both-legitimate explanations: a real &lt;strong&gt;instrumentation gap&lt;/strong&gt; (no Kafka spans) and a real &lt;strong&gt;design boundary&lt;/strong&gt; (async decoupling). Conflating them would have been the naive read. The generated graph didn't just find a bug — it made an architecture decision legible.&lt;/p&gt;

&lt;h3&gt;
  
  
  Making the map legible, not just generated
&lt;/h3&gt;

&lt;p&gt;There was one more way the graph was technically correct but practically dishonest: both databases first rendered as a single node named &lt;code&gt;localhost&lt;/code&gt;. The agent labels an uninstrumented peer by its host, and both databases live on the loopback interface — so MySQL and PostgreSQL collapsed into one vertex. A heterogeneous-persistence design rendered as if it shared one database.&lt;/p&gt;

&lt;p&gt;The fix is a peer-service mapping on the agent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="py"&gt;-Dotel.instrumentation.common.peer-service-mapping&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="s"&gt;localhost:3306=MySQL,localhost:5432=PostgreSQL,&lt;/span&gt;&lt;span class="se"&gt;\
&lt;/span&gt;  &lt;span class="s"&gt;localhost:8085=SchemaRegistry,localhost:8180=Keycloak&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now each dependency resolves to a real, named vertex, and the Schema Registry shows up as its own node. I confirmed it the same way I confirmed everything else — in the backend, not the UI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight prometheus"&gt;&lt;code&gt;&lt;span class="n"&gt;traces_service_graph_request_total&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"MySQL"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;        &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;present&lt;/span&gt;
&lt;span class="n"&gt;traces_service_graph_request_total&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"PostgreSQL"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;present&lt;/span&gt;
&lt;span class="n"&gt;traces_service_graph_request_total&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;server&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"localhost"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;    &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A graph that says &lt;code&gt;localhost&lt;/code&gt; is &lt;em&gt;generated&lt;/em&gt;; a graph that says &lt;code&gt;MySQL&lt;/code&gt; and &lt;code&gt;PostgreSQL&lt;/code&gt; is &lt;em&gt;legible&lt;/em&gt;. The labels are what turn telemetry into topology.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key takeaways
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Auto-instrumentation is a claim, not a guarantee.&lt;/strong&gt; "The agent traces everything" holds until a version boundary quietly says otherwise. Verify spans exist in the backend; never infer coverage from the absence of errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A missing edge is not a missing feature.&lt;/strong&gt; Liveness and observability are independent failure domains. A system can be correct and unobservable at the same time — the most dangerous state, because it looks fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A generated graph is a test, not a decoration.&lt;/strong&gt; Its entire value is that it can fail when reality diverges. A hand-drawn diagram cannot fail; that's precisely why it's worthless as a safety net.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Silent data paths must be consciously enabled.&lt;/strong&gt; Remote-write receivers, peer mappings, opt-in instrumentation — the telemetry that "just never lands" is the telemetry nobody turned on. Make the gaps loud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name your peers.&lt;/strong&gt; Topology you can't read is only half-built; labels are the difference between a generated graph and a useful one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verify with queries, not screenshots.&lt;/strong&gt; Green is the absence of evidence, not evidence of absence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The platform is open source — gateway, two services, Kafka, the full observability stack, and this service-graph setup: &lt;a href="https://github.com/Rummy43/ai-microservices-platform" rel="noopener noreferrer"&gt;https://github.com/Rummy43/ai-microservices-platform&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What's the most expensive silent gap you've found by verifying instead of trusting the dashboard?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://medium.com/@yara.ramesh/your-service-map-is-lying-cfc84fb38990" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>observability</category>
      <category>kafka</category>
      <category>distributedsystems</category>
      <category>springboot</category>
    </item>
  </channel>
</rss>
