<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kyawzawaung on Medium]]></title>
        <description><![CDATA[Stories by Kyawzawaung on Medium]]></description>
        <link>https://medium.com/@kyawzawaung321?source=rss-1ab368eee62------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ekwcJejIG9YqTcU-</url>
            <title>Stories by Kyawzawaung on Medium</title>
            <link>https://medium.com/@kyawzawaung321?source=rss-1ab368eee62------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:05:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kyawzawaung321/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your Kubernetes Pods Are Running — So Why Are Users Still Getting 503s?]]></title>
            <link>https://medium.com/@kyawzawaung321/your-kubernetes-pods-are-running-so-why-are-users-still-getting-503s-eba32cc5a7c3?source=rss-1ab368eee62------2</link>
            <guid isPermaLink="false">https://medium.com/p/eba32cc5a7c3</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[readinessprobe]]></category>
            <category><![CDATA[production]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Kyawzawaung]]></dc:creator>
            <pubDate>Tue, 22 Sep 2026 01:14:34 GMT</pubDate>
            <atom:updated>2026-09-22T01:50:04.584Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Kubernetes rolling updates are designed to deploy new versions without downtime. Yet many teams still encounter HTTP 503 Service Unavailable errors during deployments, even when every pod shows a Running status. The root cause is often a combination of readiness probe issues, premature traffic routing, and improper pod termination handling.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CBuu588ncMBKiNk_lTW4BA.png" /></figure><p>Imagine this production incident: an API runs with six replicas. A new release is deployed using a rolling update. Every replacement pod eventually reaches the Running state, but users intermittently receive HTTP 503 responses during the deployment.</p><p>At first, this can look like a contradiction: if Kubernetes successfully starts the new pods, why does the service briefly become unavailable?</p><p>The answer is that Running only describes the pod’s lifecycle phase. It does not prove that the application is ready to serve traffic, nor does it guarantee that an old pod has completed its active requests before shutting down. A reliable rollout must control both sides of the transition:</p><p>New pods must not receive traffic too early.</p><p>Old pods must not disappear too quickly.</p><p>Enough healthy capacity must remain throughout the update.</p><p>This is a common Kubernetes failure mode. Let’s investigate why it happens and build a safer rollout.</p><p><strong>Why Running Does Not Mean Ready</strong></p><p>A pod becomes Running after Kubernetes starts its containers. The application inside may still be:</p><p>loading configuration;</p><p>warming caches;</p><p>establishing database or broker connections;</p><p>running internal initialization;</p><p>waiting for a sidecar proxy to become usable; or</p><p>temporarily unable to handle production traffic.</p><p>Without an effective readiness probe, Kubernetes may add the pod to the Service endpoints as soon as the container starts. Requests then reach an application that is alive but not operational, producing connection failures or 503 responses from the ingress, service mesh, or upstream proxy.</p><p>The first principle of a safe rollout is therefore:</p><p><em>Traffic eligibility must be based on application readiness, not merely process existence.</em></p><p><strong>Step 1: Investigate the Deployment</strong></p><p>Start by inspecting the Deployment and observing the rollout in real time:s</p><pre>kubectl -n production get deployment api -o yaml<br>kubectl -n production rollout status deployment/api<br>kubectl -n production get pods -l app=api -w</pre><p>Check whether a readiness probe exists and whether it represents real serving readiness. A probe that always returns 200, or only proves that the process is alive, does not protect the Service.</p><p>Next, watch the Service endpoints during the rollout:</p><pre>kubectl -n production get endpontslice \<br> -l kubernetes.io/service-name=api -w</pre><p>This reveals when new pods enter the backend pool and when terminating pods leave it. Compare those changes with application, ingress, or Istio gateway logs to determine whether 503 responses occur while new pods are joining or old pods are leaving.</p><p>Also inspect rollout events and replica counts:</p><pre>kubectl -n production describe deployment api<br>kubectl -n production get events \<br> - sort-by=.metadata.creationTimestamp</pre><p>Important questions include:</p><p>1. Does the new pod receive traffic before initialization finishes?</p><p>2. Does the old application exit immediately after receiving SIGTERM?</p><p>3. Are active requests interrupted during termination?</p><p>4. Does the rollout temporarily reduce available capacity?</p><p>5. Can the cluster schedule the additional surge pods?</p><p>These checks separate readiness failures from termination failures and insufficient rollout capacity.</p><p><strong>Step 2: Design a Safer Rolling Update</strong></p><p>The following configuration provides a strong starting point for a six-replica production API:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: api<br>  namespace: production<br>spec:<br>  replicas: 6<br><br>  minReadySeconds: 15<br>  progressDeadlineSeconds: 600<br><br>  strategy:<br>    type: RollingUpdate<br>    rollingUpdate:<br>      maxUnavailable: 0<br>      maxSurge: 2<br><br>  selector:<br>    matchLabels:<br>      app: api<br><br>  template:<br>    metadata:<br>      labels:<br>        app: api<br>    spec:<br>      terminationGracePeriodSeconds: 60<br><br>      containers:<br>        - name: api<br>          image: example/api:v2<br>          ports:<br>            - name: http<br>              containerPort: 8080<br><br>          startupProbe:<br>            httpGet:<br>              path: /health/startup<br>              port: http<br>            periodSeconds: 5<br>            failureThreshold: 30<br><br>          readinessProbe:<br>            httpGet:<br>              path: /health/ready<br>              port: http<br>            periodSeconds: 5<br>            timeoutSeconds: 2<br>            failureThreshold: 2<br>            successThreshold: 1<br><br>          livenessProbe:<br>            httpGet:<br>              path: /health/live<br>              port: http<br>            periodSeconds: 10<br>            timeoutSeconds: 2<br>            failureThreshold: 3<br><br>          lifecycle:<br>            preStop:<br>              exec:<br>                command:<br>                  - /bin/sh<br>                  - -c<br>                  - sleep 10<br><br>          resources:<br>            requests:<br>              cpu: 200m<br>              memory: 256Mi<br>            limits:<br>              memory: 512MiEach part addresses a different stage of the rollout.</pre><p><strong>Step 3: Protect Traffic With Readiness Checks</strong></p><p>The readiness probe decides whether a pod should be included in Service endpoints. The /health/ready endpoint should succeed only when that particular instance can handle requests.</p><p>For example, readiness may verify that initialization is complete and required local components are usable. It should not blindly return success just because the HTTP server has started.</p><p>At the same time, avoid tying readiness to every optional external dependency. If all six pods mark themselves unready because one shared, nonessential dependency fails, Kubernetes can remove every backend from the Service and turn a partial dependency failure into a total outage.</p><p>The startup probe gives slow-starting applications extra time to initialize. Until it succeeds, Kubernetes does not run the regular liveness and readiness checks. This prevents the kubelet from repeatedly restarting a legitimate but slow startup.</p><p>The liveness probe has a different job: it detects an application that is stuck and needs to be restarted. Readiness controls traffic; liveness controls restarts. They should not be treated as interchangeable.</p><p>Finally, minReadySeconds: 15 requires a new pod to remain Ready for at least 15 seconds before Kubernetes considers it available. This protects the rollout from pods that briefly pass readiness and then fail immediately.</p><p><strong>Step 4: Drain Requests During Termination</strong></p><p>Readiness protects the beginning of a pod’s life. Graceful termination protects the end.</p><p>When Kubernetes terminates a pod, endpoint removal and process shutdown do not behave like one perfectly synchronized action across the entire network. Ingress controllers, sidecars, kube-proxy rules, and external load balancers may require time to observe the endpoint change. A small preStop delay provides time for that update to propagate before the application receives SIGTERM.</p><p>The application must also handle SIGTERM correctly. A production API should:</p><p>1. mark itself unready;</p><p>2. stop accepting new work;</p><p>3. allow active requests to finish;</p><p>4. close database and messaging connections cleanly; and</p><p>5. exit before the termination grace period expires.</p><p>In the example, preStop waits for 10 seconds and terminationGracePeriodSeconds allows up to 60 seconds for the complete termination sequence. These values are not universal. They should be based on endpoint-propagation time and the duration of legitimate long-running requests.</p><p>One subtle detail is that time spent in preStop counts against the termination grace period. A 10-second hook with a 60-second grace period leaves roughly 50 seconds for application shutdown. If the process does not exit before the deadline, Kubernetes sends SIGKILL, which prevents further cleanup.</p><p><strong>Step 5: Maintain Capacity Throughout the Rollout</strong></p><p>This rollout uses:</p><blockquote>maxUnavailable: 0<br>maxSurge: 2</blockquote><p>maxUnavailable: 0 tells Kubernetes not to intentionally reduce the number of available replicas below six during the update. maxSurge: 2 allows it to create up to two extra pods, producing a temporary maximum of eight pods.</p><p>The sequence becomes:</p><p>1. Start one or two new pods.</p><p>2. Wait for them to pass readiness and minReadySeconds.</p><p>3. Terminate the corresponding old pods gracefully.</p><p>4. Continue until all six replicas run the new version.</p><p>This favors availability over minimal resource consumption. Before adopting it, confirm that the cluster, ResourceQuota, and node capacity can accommodate two additional pods. If surge pods remain Pending, the rollout may stall because Kubernetes is not allowed to remove an old available pod first.</p><p><strong>Step 6: Validate the Fix Under Traffic</strong></p><p>A safer manifest is only a hypothesis until it is tested under traffic. Generate continuous requests while performing the rollout:</p><pre>while true; do<br> code=$(curl -sS -o /dev/null -w &#39;%{http_code}&#39; \<br> https://api.example.com/health)<br> printf &#39;%s %s\n&#39; &quot;$(date -Is)&quot; &quot;$code&quot;<br> sleep 0.2<br>done</pre><p>In another terminal, deploy the new image and watch its progress:</p><pre>kubectl -n production set image deployment/api \<br> api=example/api:v2<br>kubectl -n production rollout status deployment/api</pre><p>During the test, watch pods, EndpointSlices, application logs, ingress metrics, and 5xx response rates. A successful result should show:</p><p>no 503 responses during the rollout;</p><p>new pods receiving traffic only after becoming Ready;</p><p>at least six available replicas throughout the update;</p><p>terminating pods completing active requests; and</p><p>a broken new version stopping the rollout without removing all healthy old replicas.</p><p>Repeat the experiment with controlled failures. Make the new version fail readiness, delay its startup, and process a long-running request while its pod terminates. These tests expose lifecycle problems that a normal successful deployment can hide.</p><p><strong>Final Takeaway</strong></p><p>Kubernetes can orchestrate a rolling update, but it cannot automatically understand when an application is truly ready or how it should shut down. Those behaviors form a contract between the platform and the application.</p><p>A reliable rollout combines three controls:</p><p><strong>Readiness behavior</strong> prevents premature traffic to new pods.</p><p><strong>Graceful termination</strong> drains traffic and protects in-flight requests on old pods.</p><p><strong>Conservative rollout settings</strong> maintain enough healthy capacity during the transition.</p><p>When these controls work together, the important outcome is no longer that every pod eventually becomes Running. It is that users continue receiving successful responses throughout the entire deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eba32cc5a7c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>