<?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:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[DevOps IN SPACE: Kubernetes]]></title><description><![CDATA[This Section will help to understand the Kubernetes Concept.]]></description><link>https://devopsguyankit.substack.com/s/kubernetes</link><image><url>https://substackcdn.com/image/fetch/$s_!K2kC!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9aa9f505-ddb8-42b5-aaf3-f25fb8290953_271x271.png</url><title>DevOps IN SPACE: Kubernetes</title><link>https://devopsguyankit.substack.com/s/kubernetes</link></image><generator>Substack</generator><lastBuildDate>Thu, 18 Jun 2026 11:41:13 GMT</lastBuildDate><atom:link href="https://devopsguyankit.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Ankit Ranjan]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[devopsguyankit@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[devopsguyankit@substack.com]]></itunes:email><itunes:name><![CDATA[Ankit Ranjan]]></itunes:name></itunes:owner><itunes:author><![CDATA[Ankit Ranjan]]></itunes:author><googleplay:owner><![CDATA[devopsguyankit@substack.com]]></googleplay:owner><googleplay:email><![CDATA[devopsguyankit@substack.com]]></googleplay:email><googleplay:author><![CDATA[Ankit Ranjan]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[From Scripts to Scalable Systems: Building a Production-Ready DevOps Platform with Kubernetes, CI/CD & Observability]]></title><description><![CDATA[Modern software isn&#8217;t just about writing code &#8212; it&#8217;s about building systems that run reliably, scale effortlessly, and recover automatically.]]></description><link>https://devopsguyankit.substack.com/p/from-scripts-to-scalable-systems</link><guid isPermaLink="false">https://devopsguyankit.substack.com/p/from-scripts-to-scalable-systems</guid><dc:creator><![CDATA[Ankit Ranjan]]></dc:creator><pubDate>Mon, 06 Apr 2026 04:32:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!PO25!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Modern software isn&#8217;t just about writing code &#8212; it&#8217;s about building systems that <strong>run reliably, scale effortlessly, and recover automatically</strong>.</p><p>But here&#8217;s the reality most tutorials don&#8217;t tell you:</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://devopsguyankit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading DevOps IN SPACE! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><blockquote><p><em>You can write a working application&#8230; and it can still fail in production.</em></p></blockquote><p>Why?<br>Because real-world systems demand more than just functionality:</p><ul><li><p>They need <strong>automation (CI/CD)</strong></p></li><li><p>They need <strong>orchestration (Kubernetes)</strong></p></li><li><p>They need <strong>observability (metrics, logs, alerts)</strong></p></li><li><p>And most importantly &#8212; they need <strong>resilience</strong></p></li></ul><p>So instead of stopping at &#8220;Hello World,&#8221; this project takes a different path.</p><ul><li><p>A <strong>microservices architecture</strong> (API + worker + Redis)</p></li><li><p>Managed first with system-level services, then evolved into <strong>Docker + Kubernetes</strong></p></li><li><p>Automated using <strong>CI/CD pipelines</strong></p></li><li><p>Made observable with <strong>Prometheus, Grafana, and ELK</strong></p></li><li><p>And finally, made reliable with <strong>SRE-grade alerting strategies</strong></p></li></ul><p>This isn&#8217;t just a project.<br>It&#8217;s a <strong>blueprint of how modern backend systems actually run in production</strong>.</p><p>By the end, you won&#8217;t just understand tools &#8212; you&#8217;ll understand <strong>how everything connects</strong>.</p><p><strong>What We&#8217;re Building</strong></p><blockquote><p><em><strong>We&#8217;ll create:</strong></em></p></blockquote><ul><li><p>A Python script (your custom daemon)</p></li><li><p>A systemd service file</p></li><li><p>Enable it to run at boot</p></li><li><p>Manage it like a real production service</p></li></ul><p>&#65039;<strong> Step 1: Create Your Daemon Script</strong></p><p>Create a simple script:</p><pre><code>sudo nano /usr/local/bin/mydaemon.py</code></pre><p>Paste this:</p><pre><code>import time

while True:
    with open(&#8221;/tmp/mydaemon.log&#8221;, &#8220;a&#8221;) as f:
        f.write(&#8221;Daemon running...\n&#8221;)
    time.sleep(5)</code></pre><p>Make it executable:</p><pre><code>sudo chmod +x /usr/local/bin/mydaemon.py</code></pre><p><strong>How This Service Will Work</strong></p><pre><code>systemd
   &#8595;
Service Unit File
   &#8595;
ExecStart &#8594; Python Script
   &#8595;
Runs in Background (Daemon)
   &#8595;
Writes logs continuously</code></pre><p><strong>Step 2: Create systemd Service File</strong></p><p>Now create the service definition:</p><pre><code>sudo nano /etc/systemd/system/mydaemon.service</code></pre><p>Paste this:</p><pre><code>[Unit]
Description=My Custom Python Daemon
After=network.target

[Service]
ExecStart=/usr/bin/python3 /usr/local/bin/mydaemon.py
Restart=always
User=root

[Install]
WantedBy=multi-user.target</code></pre><p><strong>Understanding the Service File</strong></p><p><code>Unit</code></p><ul><li><p>Metadata and dependencies</p></li><li><p><code>After=network.target</code> &#8594; starts after network is ready</p></li></ul><p><code>Service</code></p><ul><li><p><code>ExecStart</code> &#8594; command to run</p></li><li><p><code>Restart=always</code> &#8594; auto-restart if it crashes</p></li><li><p><code>User=root</code> &#8594; runs as root (&#9888;&#65039; not always recommended)</p></li></ul><p><code>Install</code></p><ul><li><p>Defines when service should start</p></li><li><p><code>multi-user.target</code> &#8594; normal system boot</p></li></ul><p><strong>Step 3: Reload systemd</strong></p><p>After creating a new service:</p><pre><code>sudo systemctl daemon-reexec
sudo systemctl daemon-reload</code></pre><p><strong>Step 4: Start the Service</strong></p><pre><code>sudo systemctl start mydaemon</code></pre><p>Check status:</p><pre><code>sudo systemctl status mydaemon</code></pre><p><strong>Step 5: Verify It&#8217;s Working</strong></p><p>Check logs:</p><pre><code>cat /tmp/mydaemon.log</code></pre><p>You should see:</p><pre><code>Daemon running...
Daemon running...</code></pre><p><strong>Step 6: Enable at Boot</strong></p><pre><code>sudo systemctl enable mydaemon</code></pre><p>Now your daemon:</p><ul><li><p>Starts automatically on reboot</p></li><li><p>Runs continuously</p></li></ul><p><strong>Step 7: Debugging &amp; Logs</strong></p><p>Use:</p><pre><code>journalctl -u mydaemon</code></pre><p>This shows:</p><ul><li><p>Errors</p></li><li><p>Restart attempts</p></li><li><p>Runtime logs</p></li></ul><p><strong>Production Best Practices</strong></p><p><strong>Avoid:</strong></p><ul><li><p>Running everything as root</p></li></ul><p><strong>Instead:</strong></p><pre><code>User=ubuntu
Group=ubuntu</code></pre><p><strong>Add Resource Limits</strong></p><pre><code>LimitNOFILE=4096</code></pre><p>Add Restart Control</p><pre><code>Restart=on-failure
RestartSec=5</code></pre><p><strong>Advanced: Full Production-Ready Service</strong></p><pre><code>[Unit]
Description=My Production Daemon
After=network.target

[Service]
ExecStart=/usr/bin/python3 /usr/local/bin/mydaemon.py
Restart=on-failure
RestartSec=5
User=ubuntu
WorkingDirectory=/usr/local/bin
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PO25!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PO25!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 424w, https://substackcdn.com/image/fetch/$s_!PO25!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 848w, https://substackcdn.com/image/fetch/$s_!PO25!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!PO25!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PO25!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg" width="1050" height="543" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:543,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!PO25!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 424w, https://substackcdn.com/image/fetch/$s_!PO25!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 848w, https://substackcdn.com/image/fetch/$s_!PO25!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!PO25!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb822c70c-7fd3-4e88-b2ac-5f441615cb56_1050x543.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Flow:</strong></p><ol><li><p>API receives request</p></li><li><p>Pushes job to Redis</p></li><li><p>Worker consumes job</p></li><li><p>Processes and logs result</p></li></ol><p>This is how <strong>real async systems</strong> work.</p><p><strong>Step 1: Install Dependencies</strong></p><pre><code>sudo apt update
sudo apt install python3-pip redis -y
pip3 install flask redis</code></pre><p><strong>Step 2: Build Services</strong></p><p><strong>1. API Service (Flask)</strong></p><pre><code>sudo nano /usr/local/bin/api_service.py</code></pre><pre><code>from flask import Flask, request
import redis

app = Flask(__name__)
r = redis.Redis(host=&#8217;localhost&#8217;, port=6379)

@app.route(&#8217;/task&#8217;, methods=[&#8217;POST&#8217;])
def task():
    data = request.json.get(&#8217;data&#8217;)
    r.lpush(&#8217;queue&#8217;, data)
    return {&#8221;status&#8221;: &#8220;queued&#8221;}

app.run(host=&#8217;0.0.0.0&#8217;, port=5000)</code></pre><p><strong>2. Worker Service</strong></p><pre><code>sudo nano /usr/local/bin/worker_service.py</code></pre><pre><code>import redis
import time

r = redis.Redis(host=&#8217;localhost&#8217;, port=6379)

while True:
    _, task = r.brpop(&#8217;queue&#8217;)
    print(f&#8221;Processing: {task.decode()}&#8221;)
    time.sleep(2)</code></pre><p><strong>3. Redis Service</strong></p><p>Redis is already a daemon. You just enable it:</p><pre><code>sudo systemctl enable redis
sudo systemctl start redis</code></pre><p><strong>Step 3: Create systemd Services</strong></p><p><strong>API Service Unit</strong></p><pre><code>sudo nano /etc/systemd/system/api.service</code></pre><pre><code>[Unit]
Description=Flask API Service
After=network.target redis.service

[Service]
ExecStart=/usr/bin/python3 /usr/local/bin/api_service.py
Restart=always
User=ubuntu

[Install]
WantedBy=multi-user.target</code></pre><p><strong>Worker Service Unit</strong></p><pre><code>sudo nano /etc/systemd/system/worker.service</code></pre><pre><code>[Unit]
Description=Worker Service
After=network.target redis.service

[Service]
ExecStart=/usr/bin/python3 /usr/local/bin/worker_service.py
Restart=always
User=ubuntu

[Install]
WantedBy=multi-user.target</code></pre><p><strong>Step 4: Reload &amp; Start Everything</strong></p><pre><code>sudo systemctl daemon-reload

sudo systemctl start api
sudo systemctl start worker

sudo systemctl enable api
sudo systemctl enable worker</code></pre><p><strong>Step 5: Test the System</strong></p><p>Send request:</p><pre><code>curl -X POST http://localhost:5000/task \
-H &#8220;Content-Type: application/json&#8221; \
-d &#8216;{&#8221;data&#8221;:&#8221;hello world&#8221;}&#8217;</code></pre><p><strong>Verify Worker Output</strong></p><pre><code>journalctl -u worker -f</code></pre><p>Expected:</p><pre><code>Processing: hello world</code></pre><p><strong>Visual: Service Interaction</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!x-w3!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!x-w3!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 424w, https://substackcdn.com/image/fetch/$s_!x-w3!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 848w, https://substackcdn.com/image/fetch/$s_!x-w3!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!x-w3!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!x-w3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg" width="800" height="447" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:447,&quot;width&quot;:800,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!x-w3!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 424w, https://substackcdn.com/image/fetch/$s_!x-w3!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 848w, https://substackcdn.com/image/fetch/$s_!x-w3!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!x-w3!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F30810d96-38e7-4838-97df-5c1455e9e04b_800x447.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Y9Eb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 424w, https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 848w, https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 1272w, https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png" width="471" height="242" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:242,&quot;width&quot;:471,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 424w, https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 848w, https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 1272w, https://substackcdn.com/image/fetch/$s_!Y9Eb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83fc2660-cdd2-4dbd-937f-34f76a4f3b60_471x242.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Production Enhancements (DevOps Level)</strong></p><p><strong>Add Environment File</strong></p><pre><code>Environment=REDIS_HOST=localhost</code></pre><p><strong>Add Restart Limits</strong></p><pre><code>Restart=on-failure
RestartSec=3</code></pre><p><strong>Logging</strong></p><pre><code>journalctl -u api
journalctl -u worker</code></pre><p><strong>Real-World Mapping</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!CTCs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!CTCs!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 424w, https://substackcdn.com/image/fetch/$s_!CTCs!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 848w, https://substackcdn.com/image/fetch/$s_!CTCs!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 1272w, https://substackcdn.com/image/fetch/$s_!CTCs!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!CTCs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png" width="482" height="250" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:250,&quot;width&quot;:482,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!CTCs!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 424w, https://substackcdn.com/image/fetch/$s_!CTCs!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 848w, https://substackcdn.com/image/fetch/$s_!CTCs!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 1272w, https://substackcdn.com/image/fetch/$s_!CTCs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3cce5e02-e58c-4226-acd9-eddd32e3e9d9_482x250.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Why This Matters</strong></p><p>You just built:</p><ul><li><p>A <strong>microservices architecture</strong></p></li><li><p>With <strong>async processing</strong></p></li><li><p>Managed by <strong>system-level orchestration</strong></p></li></ul><p><strong>This is exactly how:</strong></p><ul><li><p>Payment systems</p></li><li><p>Notification services</p></li><li><p>Data pipelines</p></li></ul><p>&#8230;are built in production.</p><p>Let&#8217;s take your microservices setup to <strong>production-grade DevOps</strong> by adding a <strong>CI/CD pipeline using GitHub Actions</strong>.</p><p><strong>CI/CD Flow</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oLtT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oLtT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 424w, https://substackcdn.com/image/fetch/$s_!oLtT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 848w, https://substackcdn.com/image/fetch/$s_!oLtT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 1272w, https://substackcdn.com/image/fetch/$s_!oLtT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oLtT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png" width="1015" height="594" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:594,&quot;width&quot;:1015,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!oLtT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 424w, https://substackcdn.com/image/fetch/$s_!oLtT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 848w, https://substackcdn.com/image/fetch/$s_!oLtT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 1272w, https://substackcdn.com/image/fetch/$s_!oLtT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffcb054fa-60a6-4fd9-8022-f41bc7c7ad9e_1015x594.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Flow:</strong></p><ol><li><p>Push code to GitHub</p></li><li><p>GitHub Actions runs pipeline</p></li><li><p>Connects to server via SSH</p></li><li><p>Pulls latest code</p></li><li><p>Restarts systemd services</p></li></ol><p><strong>Step 1: Prepare Your Repo</strong></p><p>Your repo structure should look like:</p><pre><code>project/
 &#9500;&#9472;&#9472; api_service.py
 &#9500;&#9472;&#9472; worker_service.py
 &#9500;&#9472;&#9472; requirements.txt
 &#9492;&#9472;&#9472; .github/workflows/deploy.yml</code></pre><p><strong>Step 2: Add Secrets in GitHub</strong></p><p>Go to your repo &#8594; <strong>Settings &#8594; Secrets &#8594; Actions</strong></p><p>Add:</p><ul><li><p><code>SERVER_IP</code></p></li><li><p><code>SERVER_USER</code></p></li><li><p><code>SSH_PRIVATE_KEY</code></p></li></ul><p>These are used for secure deployment.</p><p><strong>Step 3: Create GitHub Actions Workflow</strong></p><pre><code>mkdir -p .github/workflows
nano .github/workflows/deploy.yml</code></pre><p><strong>deploy.yml</strong></p><pre><code>name: Deploy Microservices

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v3

      - name: Setup SSH
        run: |
          mkdir -p ~/.ssh
          echo &#8220;${{ secrets.SSH_PRIVATE_KEY }}&#8221; &gt; ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan -H ${{ secrets.SERVER_IP }} &gt;&gt; ~/.ssh/known_hosts

      - name: Deploy to Server
        run: |
          ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} &lt;&lt; &#8216;EOF&#8217;
            cd /usr/local/bin
            git pull origin main

            pip3 install -r requirements.txt

            sudo systemctl restart api
            sudo systemctl restart worker
          EOF</code></pre><p><strong>What This Pipeline Does</strong></p><p><code>on: pus</code>h &#8212; Triggers deployment automatically on every push to <code>main</code></p><p>Checkout &#8212; Pulls your code into the runner</p><p><strong>SSH Setup</strong></p><ul><li><p>Injects private key</p></li><li><p>Establishes trust with server</p></li></ul><p><strong>Deployment Step</strong></p><ul><li><p>SSH into server</p></li><li><p>Pull latest code</p></li><li><p>Install dependencies</p></li><li><p>Restart services</p></li></ul><p><strong>Step 4: Test the Pipeline</strong></p><ol><li><p>Push a change:</p></li></ol><pre><code>git add .
git commit -m &#8220;Test CI/CD&#8221;
git push origin main</code></pre><ol><li><p>Go to GitHub &#8594; <strong>Actions tab</strong></p></li></ol><p>You&#8217;ll see your pipeline running</p><p><strong>Verify Deployment</strong></p><p>On your server:</p><pre><code>systemctl status api
systemctl status worker</code></pre><p>Check logs:</p><pre><code>journalctl -u api -f
journalctl -u worker -f</code></pre><p><strong>Production Best Practices</strong></p><p><strong>Use Non-Root User</strong></p><p>Avoid:</p><pre><code>User=root</code></pre><p>Use:</p><pre><code>User=ubuntu</code></pre><p><strong>Add Zero-Downtime Restart</strong></p><pre><code>systemctl reload api</code></pre><p><strong>Use Virtual Environment</strong></p><pre><code>python3 -m venv venv
source venv/bin/activate</code></pre><p>Update service:</p><pre><code>ExecStart=/usr/local/bin/venv/bin/python api_service.py</code></pre><p><strong>Add Health Check Step</strong></p><p>You can extend pipeline:</p><pre><code>- name: Health Check
  run: |
    curl -f http://${{ secrets.SERVER_IP }}:5000 || exit 1</code></pre><p><strong>Advanced Version (Production Ready)</strong></p><p>Add rollback logic:</p><pre><code>- name: Restart Services Safely
  run: |
    ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} &lt;&lt; &#8216;EOF&#8217;
      sudo systemctl restart api || sudo systemctl rollback api
    EOF</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6VCZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6VCZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 424w, https://substackcdn.com/image/fetch/$s_!6VCZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 848w, https://substackcdn.com/image/fetch/$s_!6VCZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 1272w, https://substackcdn.com/image/fetch/$s_!6VCZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6VCZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png" width="885" height="477" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:477,&quot;width&quot;:885,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!6VCZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 424w, https://substackcdn.com/image/fetch/$s_!6VCZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 848w, https://substackcdn.com/image/fetch/$s_!6VCZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 1272w, https://substackcdn.com/image/fetch/$s_!6VCZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8528416b-aa58-4e99-9c85-c847075b73e4_885x477.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Flow:</strong></p><ul><li><p>API (Flask) &#8594; receives request</p></li><li><p>Sends job &#8594; Redis</p></li><li><p>Worker &#8594; consumes job</p></li><li><p>Kubernetes &#8594; orchestrates everything</p></li></ul><p>You&#8217;re moving from <strong>system-level services &#8594; cloud-native architecture</strong></p><p><strong>Step 1: Dockerize Your Services</strong></p><p><strong>API Dockerfile</strong></p><pre><code># api/Dockerfile
FROM python:3.9-slim

WORKDIR /app

COPY api_service.py.
COPY requirements.txt.

RUN pip install -r requirements.txt

CMD [&#8221;python&#8221;, &#8220;api_service.py&#8221;]</code></pre><p><strong>Worker Docker file</strong></p><pre><code># worker/Dockerfile
FROM python:3.9-slim

WORKDIR /app

COPY worker_service.py.
COPY requirements.txt.

RUN pip install -r requirements.txt

CMD [&#8221;python&#8221;, &#8220;worker_service.py&#8221;]</code></pre><p><strong>requirements.txt</strong></p><pre><code>flask
redis</code></pre><p><strong>Build &amp; Run Locally</strong></p><pre><code>docker build -t api-service./api
docker build -t worker-service./worker

docker run -d -p 5000:5000 api-service
docker run -d worker-service</code></pre><p><strong>Step 2: Kubernetes Manifests</strong></p><p><strong>Redis Deployment</strong></p><pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis:7
        ports:
        - containerPort: 6379</code></pre><p><strong>API Deployment</strong></p><pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 2
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - name: api
        image: api-service:latest
        ports:
        - containerPort: 5000</code></pre><p><strong>Worker Deployment</strong></p><pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: worker
spec:
  replicas: 2
  selector:
    matchLabels:
      app: worker
  template:
    metadata:
      labels:
        app: worker
    spec:
      containers:
      - name: worker
        image: worker-service:latest</code></pre><p><strong>Step 3: Expose API Service</strong></p><pre><code>apiVersion: v1
kind: Service
metadata:
  name: api-service
spec:
  type: NodePort
  selector:
    app: api
  ports:
    - port: 80
      targetPort: 5000
      nodePort: 30007</code></pre><p><strong>Step 4: Deploy to Kubernetes</strong></p><pre><code>kubectl apply -f redis.yaml
kubectl apply -f api.yaml
kubectl apply -f worker.yaml
kubectl apply -f api-service.yaml</code></pre><p><strong>Step 5: Test</strong></p><pre><code>curl http://&lt;node-ip&gt;:30007/task</code></pre><p><strong>Visual: Kubernetes Internals</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Yh0X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yh0X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 424w, https://substackcdn.com/image/fetch/$s_!Yh0X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 848w, https://substackcdn.com/image/fetch/$s_!Yh0X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 1272w, https://substackcdn.com/image/fetch/$s_!Yh0X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yh0X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png" width="1050" height="462" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:462,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!Yh0X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 424w, https://substackcdn.com/image/fetch/$s_!Yh0X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 848w, https://substackcdn.com/image/fetch/$s_!Yh0X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 1272w, https://substackcdn.com/image/fetch/$s_!Yh0X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F827e0d59-8a09-4cb3-a07e-cfda4bd9c006_1050x462.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vama!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vama!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 424w, https://substackcdn.com/image/fetch/$s_!vama!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 848w, https://substackcdn.com/image/fetch/$s_!vama!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!vama!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vama!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg" width="1050" height="852" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:852,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!vama!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 424w, https://substackcdn.com/image/fetch/$s_!vama!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 848w, https://substackcdn.com/image/fetch/$s_!vama!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!vama!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbdc04759-3401-4d6c-88a1-b58a43d13d4b_1050x852.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Production Enhancements</strong></p><p><strong>Use Config Map</strong></p><pre><code>env:
- name: REDIS_HOST
  value: redis</code></pre><p><strong>Add Readiness &amp; Liveness Probes</strong></p><pre><code>livenessProbe:
  httpGet:
    path: /
    port: 5000</code></pre><p>Use Ingress (instead of NodePort)</p><p>Use Persistent Storage (for Redis)</p><p><strong>CI/CD Upgrade</strong></p><p>Update your <strong>GitHub Actions</strong> pipeline:</p><pre><code>- name: Build Docker Images
  run: |
    docker build -t api-service./api
    docker build -t worker-service./worker- name: Push to Docker Hub

- name: Push to Docker Hub
  run: |
    docker tag api-service your-dockerhub/api-service
    docker push your-dockerhub/api-service

- name: Deploy to Kubernetes
  run: |
    kubectl apply -f k8s/

</code></pre><p><strong>Real Industry Mapping</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6WYe!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6WYe!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 424w, https://substackcdn.com/image/fetch/$s_!6WYe!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 848w, https://substackcdn.com/image/fetch/$s_!6WYe!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 1272w, https://substackcdn.com/image/fetch/$s_!6WYe!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6WYe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png" width="499" height="254" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:254,&quot;width&quot;:499,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!6WYe!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 424w, https://substackcdn.com/image/fetch/$s_!6WYe!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 848w, https://substackcdn.com/image/fetch/$s_!6WYe!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 1272w, https://substackcdn.com/image/fetch/$s_!6WYe!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9d35f38e-008d-4f49-b1f6-34ccd8647f4b_499x254.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!GgIC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!GgIC!,w_424,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 424w, https://substackcdn.com/image/fetch/$s_!GgIC!,w_848,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 848w, https://substackcdn.com/image/fetch/$s_!GgIC!,w_1272,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 1272w, https://substackcdn.com/image/fetch/$s_!GgIC!,w_1456,c_limit,f_webp,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!GgIC!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:null,&quot;width&quot;:null,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!GgIC!,w_424,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 424w, https://substackcdn.com/image/fetch/$s_!GgIC!,w_848,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 848w, https://substackcdn.com/image/fetch/$s_!GgIC!,w_1272,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 1272w, https://substackcdn.com/image/fetch/$s_!GgIC!,w_1456,c_limit,f_auto,q_auto:good,fl_lossy/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b2df59f-ea58-4e7f-8a3c-859f09d446f9_1920x1080.gif 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Flow:</strong></p><ul><li><p>Kubernetes Pods &#8594; expose metrics</p></li><li><p>Prometheus &#8594; scrapes metrics</p></li><li><p>Grafana &#8594; visualizes</p></li><li><p>Alertmanager &#8594; sends alerts</p></li></ul><p>This is called <strong>Observability Stack</strong></p><p><strong>Step 1: Install Prometheus (Kubernetes)</strong></p><p><strong>Use Helm (recommended)</strong></p><pre><code>helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

helm install prometheus prometheus-community/kube-prometheus-stack</code></pre><p>This installs:</p><ul><li><p>Prometheus</p></li><li><p>Grafana</p></li><li><p>Alertmanager</p></li><li><p>Node Exporter</p></li></ul><p><strong>Step 2: Access Grafana Dashboard</strong></p><pre><code>kubectl port-forward svc/prometheus-grafana 3000:80</code></pre><p>Open: http://localhost:3000</p><p>Default login:</p><ul><li><p>user: <code>admin</code></p></li><li><p>password:</p></li></ul><pre><code>kubectl get secret prometheus-grafana \
-o jsonpath=&#8221;{.data.admin-password}&#8221; | base64 --decode</code></pre><p><strong>Step 3: Add Application Metrics</strong></p><p>Right now, Prometheus monitors cluster &#8212; but not your app.</p><p>Let&#8217;s fix that</p><p><strong>Update API Service (Flask Metrics)</strong></p><p>Install:</p><pre><code>pip install prometheus_client</code></pre><p>Update API:</p><pre><code>from prometheus_client import Counter, generate_latest
from flask import Response

REQUEST_COUNT = Counter(&#8217;api_requests_total&#8217;, &#8216;Total API Requests&#8217;)

@app.route(&#8217;/metrics&#8217;)
def metrics():
    return Response(generate_latest(), mimetype=&#8217;text/plain&#8217;)

@app.route(&#8217;/task&#8217;, methods=[&#8217;POST&#8217;])
def task():
    REQUEST_COUNT.inc()
    ...</code></pre><p><strong>Step 4: Expose Metrics in Kubernetes</strong></p><p>Update API deployment:</p><pre><code>ports:
- containerPort: 5000</code></pre><p><strong>Add Service Monitor (CRD)</strong></p><pre><code>apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: api-monitor
spec:
  selector:
    matchLabels:
      app: api
  endpoints:
  - port: http
    path: /metrics
    interval: 15s</code></pre><p><strong>Step 5: Create Grafana Dashboard</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!m14y!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!m14y!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 424w, https://substackcdn.com/image/fetch/$s_!m14y!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 848w, https://substackcdn.com/image/fetch/$s_!m14y!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 1272w, https://substackcdn.com/image/fetch/$s_!m14y!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!m14y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png" width="1050" height="582" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:582,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!m14y!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 424w, https://substackcdn.com/image/fetch/$s_!m14y!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 848w, https://substackcdn.com/image/fetch/$s_!m14y!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 1272w, https://substackcdn.com/image/fetch/$s_!m14y!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb0b41e4-dff0-43a3-908c-24374d7dbb91_1050x582.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D9FN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D9FN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 424w, https://substackcdn.com/image/fetch/$s_!D9FN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 848w, https://substackcdn.com/image/fetch/$s_!D9FN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 1272w, https://substackcdn.com/image/fetch/$s_!D9FN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D9FN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png" width="1050" height="733" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:733,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!D9FN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 424w, https://substackcdn.com/image/fetch/$s_!D9FN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 848w, https://substackcdn.com/image/fetch/$s_!D9FN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 1272w, https://substackcdn.com/image/fetch/$s_!D9FN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa328b1a9-12a0-4a90-a6ee-7e454bf7ed3c_1050x733.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Add Panel Query:</strong></p><pre><code>api_requests_total</code></pre><p>Now you can see:</p><ul><li><p>Request rate</p></li><li><p>Traffic patterns</p></li><li><p>Load spikes</p></li></ul><p><strong>Step 6: Add Alerts</strong></p><p><strong>Example Alert Rule</strong></p><pre><code>groups:
- name: api-alerts
  rules:
  - alert: HighRequestRate
    expr: api_requests_total &gt; 100
    for: 1m
    labels:
      severity: warning
    annotations:
      description: &#8220;High API traffic detected&#8221;</code></pre><p><strong>Step 7: Configure Alert manager</strong></p><p>Example:</p><pre><code>receivers:
- name: email-alert
  email_configs:
  - to: your-email@example.com</code></pre><p><strong>What You Just Achieved</strong></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-Y5X!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-Y5X!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 424w, https://substackcdn.com/image/fetch/$s_!-Y5X!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 848w, https://substackcdn.com/image/fetch/$s_!-Y5X!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 1272w, https://substackcdn.com/image/fetch/$s_!-Y5X!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-Y5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png" width="436" height="144" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:144,&quot;width&quot;:436,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!-Y5X!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 424w, https://substackcdn.com/image/fetch/$s_!-Y5X!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 848w, https://substackcdn.com/image/fetch/$s_!-Y5X!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 1272w, https://substackcdn.com/image/fetch/$s_!-Y5X!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fddad3809-1a1c-4834-8d44-d3e2d1162c68_436x144.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p><strong>Real DevOps Insight</strong></p><p>This stack is used in:</p><ul><li><p>Netflix</p></li><li><p>Uber</p></li><li><p>Swiggy / Zomato</p></li><li><p>Cloud-native startups</p></li></ul><p>You just built <strong>industry-standard observability</strong></p><p><strong>Pro-Level Enhancements</strong></p><p><strong>Add RED Metrics</strong></p><ul><li><p>Rate</p></li><li><p>Errors</p></li><li><p>Duration</p></li></ul><p><strong>Add Latency Metrics</strong></p><pre><code>from prometheus_client import Histogram

REQUEST_LATENCY = Histogram(&#8217;request_latency_seconds&#8217;, &#8216;Request latency&#8217;)</code></pre><p><strong>Add Kubernetes Metrics</strong></p><ul><li><p>Pod CPU</p></li><li><p>Memory</p></li><li><p>Restarts</p></li></ul><p>Let&#8217;s add <strong>centralized logging using the ELK stack</strong>:</p><ul><li><p>Elasticsearch &#8594; stores logs</p></li><li><p>Logstash &#8594; processes logs</p></li><li><p>Kibana &#8594; visualizes logs</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!kC3U!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!kC3U!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 424w, https://substackcdn.com/image/fetch/$s_!kC3U!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 848w, https://substackcdn.com/image/fetch/$s_!kC3U!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!kC3U!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!kC3U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg" width="1050" height="689" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:689,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!kC3U!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 424w, https://substackcdn.com/image/fetch/$s_!kC3U!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 848w, https://substackcdn.com/image/fetch/$s_!kC3U!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!kC3U!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa134f35a-38b5-48c3-a471-5cf7da69a267_1050x689.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4rEA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4rEA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 424w, https://substackcdn.com/image/fetch/$s_!4rEA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 848w, https://substackcdn.com/image/fetch/$s_!4rEA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 1272w, https://substackcdn.com/image/fetch/$s_!4rEA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4rEA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png" width="1050" height="385" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:385,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!4rEA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 424w, https://substackcdn.com/image/fetch/$s_!4rEA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 848w, https://substackcdn.com/image/fetch/$s_!4rEA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 1272w, https://substackcdn.com/image/fetch/$s_!4rEA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faad56969-45af-4d36-9013-b1e3db9d5456_1050x385.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>Flow:</strong></p><ul><li><p>Kubernetes Pods &#8594; generate logs</p></li><li><p>Fluent Bit / Logstash &#8594; collect &amp; process</p></li><li><p>Elasticsearch &#8594; store</p></li><li><p>Kibana &#8594; visualize</p></li></ul><p>This gives you <strong>full log visibility across microservices</strong></p><p><strong>Step 1: Deploy ELK Stack (Kubernetes)</strong></p><p><strong>Use Helm (Recommended)</strong></p><pre><code>helm repo add elastic https://helm.elastic.co
helm repo update

helm install elasticsearch elastic/elasticsearch
helm install kibana elastic/kibana
helm install logstash elastic/logstash</code></pre><p><strong>Step 2: Access Kibana</strong></p><pre><code>kubectl port-forward svc/kibana-kibana 5601:5601</code></pre><p>Open: http://localhost:5601</p><p><strong>Step 3: Collect Logs from Pods</strong></p><p>Kubernetes writes logs to:</p><pre><code>/var/log/containers/*.log</code></pre><p>We use <strong>Fluent Bit</strong> (lightweight log collector).</p><p><strong>Deploy Fluent Bit</strong></p><pre><code>helm repo add fluent https://fluent.github.io/helm-charts
helm install fluent-bit fluent/fluent-bit</code></pre><p><strong>Fluent Bit Flow</strong></p><pre><code>Pods &#8594; stdout logs &#8594; Fluent Bit &#8594; Elasticsearch &#8594; Kibana</code></pre><p><strong>Step 4: Configure Log Parsing</strong></p><p>Example Fluent Bit config:</p><pre><code>[INPUT]
    Name tail
    Path /var/log/containers/*.log
    Tag kube.*

[OUTPUT]
    Name es
    Match *
    Host elasticsearch-master
    Port 9200</code></pre><p><strong>Step 5: Visualize Logs in Kibana</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!YsC8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!YsC8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 424w, https://substackcdn.com/image/fetch/$s_!YsC8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 848w, https://substackcdn.com/image/fetch/$s_!YsC8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 1272w, https://substackcdn.com/image/fetch/$s_!YsC8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!YsC8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png" width="1050" height="615" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/713d20cc-7334-425c-8fda-0900d9829824_1050x615.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:615,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!YsC8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 424w, https://substackcdn.com/image/fetch/$s_!YsC8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 848w, https://substackcdn.com/image/fetch/$s_!YsC8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 1272w, https://substackcdn.com/image/fetch/$s_!YsC8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F713d20cc-7334-425c-8fda-0900d9829824_1050x615.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!A-Lp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!A-Lp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 424w, https://substackcdn.com/image/fetch/$s_!A-Lp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 848w, https://substackcdn.com/image/fetch/$s_!A-Lp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 1272w, https://substackcdn.com/image/fetch/$s_!A-Lp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!A-Lp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png" width="1050" height="636" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:636,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!A-Lp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 424w, https://substackcdn.com/image/fetch/$s_!A-Lp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 848w, https://substackcdn.com/image/fetch/$s_!A-Lp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 1272w, https://substackcdn.com/image/fetch/$s_!A-Lp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fed2f69c3-eadf-4593-a2c0-81bf616814e5_1050x636.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!snMA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!snMA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 424w, https://substackcdn.com/image/fetch/$s_!snMA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 848w, https://substackcdn.com/image/fetch/$s_!snMA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 1272w, https://substackcdn.com/image/fetch/$s_!snMA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!snMA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png" width="1050" height="615" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:615,&quot;width&quot;:1050,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!snMA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 424w, https://substackcdn.com/image/fetch/$s_!snMA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 848w, https://substackcdn.com/image/fetch/$s_!snMA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 1272w, https://substackcdn.com/image/fetch/$s_!snMA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F588e6d7e-3dfd-4301-975f-371f8e5c5e6a_1050x615.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><strong>In Kibana:</strong></p><ol><li><p>Go to <strong>Discover</strong></p></li><li><p>Create index pattern: <code>logstash-*</code></p></li><li><p>Search logs like:</p></li></ol><pre><code>error OR exception</code></pre><p><strong>Step 6: Add Structured Logging</strong></p><p>Update your Python services:</p><pre><code>import logging

logging.basicConfig(level=logging.INFO)

logging.info(&#8221;Task received&#8221;)
logging.error(&#8221;Something failed&#8221;)</code></pre><p>Structured logs = better searchability in Kibana</p><p><strong>Step 7: Log-Based Alerts</strong></p><p>You can trigger alerts on logs:</p><p>Example:</p><ul><li><p>If <code>"error"</code> appears &gt; 10 times/min &#8594; alert</p></li></ul><p><strong>Observability = Logs + Metrics + Alerts</strong></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1WL0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1WL0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 424w, https://substackcdn.com/image/fetch/$s_!1WL0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 848w, https://substackcdn.com/image/fetch/$s_!1WL0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 1272w, https://substackcdn.com/image/fetch/$s_!1WL0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1WL0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png" width="440" height="148" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:148,&quot;width&quot;:440,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!1WL0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 424w, https://substackcdn.com/image/fetch/$s_!1WL0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 848w, https://substackcdn.com/image/fetch/$s_!1WL0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 1272w, https://substackcdn.com/image/fetch/$s_!1WL0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef93e8ff-801e-406b-b713-944ea24fc1fb_440x148.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><blockquote><p><em><strong>Metrics tell you what is wrong<br>Logs tell you why it&#8217;s wrong</strong></em></p></blockquote><p>Now &#8212; you have both.</p><p>What started as a simple service has now evolved into a <strong>fully observable, automated, production-ready system</strong>.</p><p>Let&#8217;s step back and look at what you&#8217;ve built:</p><ul><li><p>Microservices architecture</p></li><li><p>Containerized applications using Docker</p></li><li><p>Kubernetes orchestration</p></li><li><p>CI/CD pipeline with GitHub Actions</p></li><li><p>Monitoring with Prometheus &amp; Grafana</p></li><li><p>Centralized logging with ELK</p></li><li><p>Intelligent alerting strategies</p></li></ul><p>This is not a beginner setup.<br>This is the <strong>foundation of real-world DevOps and SRE systems</strong>.</p><p>More importantly, you&#8217;ve made a critical mindset shift:</p><blockquote><p><em>From running applications &#8594; to <strong>engineering systems</strong></em></p></blockquote><p>And that&#8217;s what separates:</p><ul><li><p>A developer from a <strong>DevOps engineer</strong></p></li><li><p>A learner from a <strong>builder</strong></p></li><li><p>Knowledge from <strong>real capability</strong></p></li></ul><p>In production, systems don&#8217;t fail because of one bug.<br>They fail because of <strong>missing visibility, weak automation, and poor alerting</strong>.</p><blockquote><p><em>Now &#8212; you&#8217;ve solved all three.</em></p></blockquote><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://devopsguyankit.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading DevOps IN SPACE! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item></channel></rss>