<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Keerthana on Medium]]></title>
        <description><![CDATA[Stories by Keerthana on Medium]]></description>
        <link>https://medium.com/@keeerthana?source=rss-2747ae2a60b1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ce-cjBaJ-Jn6eopjej-6IQ.jpeg</url>
            <title>Stories by Keerthana on Medium</title>
            <link>https://medium.com/@keeerthana?source=rss-2747ae2a60b1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 20:01:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@keeerthana/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[Not a] Containers 101]]></title>
            <link>https://medium.com/@keeerthana/containers-101-3c95151362cc?source=rss-2747ae2a60b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c95151362cc</guid>
            <category><![CDATA[container-runtime]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Keerthana]]></dc:creator>
            <pubDate>Sat, 11 Apr 2026 18:30:23 GMT</pubDate>
            <atom:updated>2026-04-18T07:26:03.516Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqDu92Ly98X9wVlooLbvDg.png" /></figure><p><strong>Containers do not actually exist.</strong> We often think of a Container as a mini Virtual Machine or a tiny, isolated computer. But here is the truth, Container is a Process, a restricted Linux process running on a host machine, sharing the host’s kernel but isolated via namespaces (what the process can view) and cgroups (how much resource the process can use).</p><p>Lets start with what is Docker image, how runtimes like containerd and CRI-O uses OverlayFS, Lastly fixing layer duplication issue in my Docker image.</p><h4>Dockerfile</h4><p>Before an image exists, it starts as a Dockerfile. Every instruction we write in a Dockerfile (like COPY, ADD, or RUN) creates a physical <strong>layer</strong> of files. I will repeat again, <strong>it creates files</strong>. Once a build step completes, that layer becomes locked and completely immutable.</p><h4>What Actually is a Docker Image?</h4><p>We write a Dockerfile, push an image, and deploy a Pod. But wait, what is Image?? An image is not a running program. It is nothing more than a collection of standard Linux files and directories. These files are packaged into a specific format (<a href="https://github.com/opencontainers/image-spec">OCI standard</a>) before being stored in a registry.</p><p>Image sitting in a registry consists of two primary components:</p><ol><li><strong>The Manifest:</strong> A JSON document containing execution instructions and a list of layer hashes.</li><li><strong>The Layers :</strong> Actual files ( base OS directories), dependencies, and application code, These are bundled and compressed into a series of .tar.gz files (tarballs). These are simply the Linux equivalent of .zip files, used strictly to save space and bandwidth during download.</li></ol><p>When a container runtime (like containerd or CRI-O or docker) pulls an image, its job is to download the JSON manifest, download the compressed layers, and unpack them into separate, physical directories on the host server’s hard drive in path /var/lib/containerd/.</p><p>To avoid duplicating these files every time a new Pod starts, the runtime relies on the Linux kernel’s OverlayFS.</p><h4>OverlayFS: The Union Filesystem</h4><p>OverlayFS is a union filesystem that allows Linux to mount multiple directories on top of each other, presenting them to the application as a single, unified filesystem.</p><p>It relies on three main components:</p><ul><li><strong>LowerDir (Read-Only):</strong> These are the unpacked .tar.gz layers from Docker image. Once unpacked on the host server, these directories are strictly immutable. Multiple running containers can share this exact same set of physical files.</li><li><strong>UpperDir (Writable):</strong> For every container that starts, the runtime creates a dedicated, empty directory. Any file writes, modifications, or deletions performed by the running application happen exclusively in this directory.</li><li><strong>WorkDir (Staging):</strong> A hidden directory used by OverlayFS to ensure atomic file operations. If a container writes a large file, it is written to the WorkDir first, then moved to the UpperDir upon completion to prevent file corruption in the event of a crash.</li></ul><p>When weexec into a container and list the files, the Linux kernel merges the LowerDir and UpperDir. The application is unaware that the files are physically separated on the host server.</p><h4>Uncovering layer duplication issue</h4><p>Here is my Docker Image</p><pre># Step 1: Use Amazon Corretto 17 with Alpine Linux as the base image for building the application<br>FROM amazoncorretto:17-alpine3.17 as build<br>WORKDIR /workspace/app<br>COPY gradlew .<br>COPY gradle gradle<br>COPY build.gradle .<br>COPY settings.gradle .<br>COPY src src<br>RUN chmod +x ./gradlew &amp;&amp; ./gradlew build -x test<br><br># Step 2: Use Amazon Corretto 17 with Alpine Linux as the runtime base image<br>FROM amazoncorretto:17-alpine3.17<br>ARG JAR_FILE=/workspace/app/build/libs/*.jar<br><br># Copy the JAR file from the build stage<br>COPY --from=build ${JAR_FILE} app.jar<br><br># Add Observability Agent<br>ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.23.0/opentelemetry-javaagent.jar /opt/aws-opentelemetry-agent.jar<br><br>RUN chown 1000 ./app.jar &amp;&amp; \<br>    chown 1000 /opt/aws-opentelemetry-agent.jar<br><br>USER 1000<br>ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;]</pre><p>While I was reading on OverlayFS, I was curious to look at the how CRI-O runtime unpacks the layers into separate folders. SSH’d into AWS EKS EC2 worker node to trace Java application Image’s Layers.</p><p>EKS node runs a CRI-O runtime under the hood, it doesn’t have crictl had to install crictl first</p><pre>VERSION=&quot;v1.33.0&quot;<br>wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/crictl-$VERSION-linux-arm64.tar.gz<br>sudo tar zxvf crictl-$VERSION-linux-arm64.tar.gz -C /usr/local/bin<br>rm -f crictl-$VERSION-linux-arm64.tar.gz</pre><p>To list the running:</p><pre>sudo crictl ps</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRrMgLUj57WTkLKrq3IyGg.png" /></figure><p>Got the Image id for my application: 65be9b046ac9a, and container id: 2d01f07402bce</p><p>To look at the image manifest:</p><pre>sudo crictl inspecti &lt;image-id&gt;</pre><p>In the JSON output, under the history section, I noticed something specific. Instructions like ENV and USER were marked as &quot;empty_layer&quot;: true, meaning they only added metadata and did not take up disk space. , ButRUN chown 1000 command at the end of my Dockerfile had generated a SHA256 layer hash in the rootfs.diff_ids list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAQ4rTGv1Ezbe4zyxFfpCQ.png" /></figure><p>To get the Overlay folders</p><pre>sudo crictl inspect 2d01f07402bce | grep pid<br>cat /proc/230471/mountinfo | grep overlay</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lP8CIQh9-ss6Y6MP7BP3lQ.png" /></figure><p>Output revealed the exact paths chained together in the lowerdir. I have manually navigated through these snapshot directories on the host server and found the problem:</p><ul><li>Inside <strong>Snapshot 270</strong>, I found opt/aws-opentelemetry-agent.jar.</li><li>Inside <strong>Snapshot 268</strong>, I found the exact same opt/aws-opentelemetry-agent.jar duplicated.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yV2ZbS4A67GsYSBnKnyl0A.png" /></figure><p>This made me look closely at dockerfile, and then it striked I was applying permissions after the layers are created</p><pre># Step 1: Use Amazon Corretto 17 with Alpine Linux as the base image for building the application<br>...<br><br># Step 2: Use Amazon Corretto 17 with Alpine Linux as the runtime base image<br>FROM amazoncorretto:17-alpine3.17<br>ARG JAR_FILE=/workspace/app/build/libs/*.jar<br><br># Copy the JAR file from the build stage<br>COPY --from=build ${JAR_FILE} app.jar<br><br># Add Observability Agent<br>ADD https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.23.0/opentelemetry-javaagent.jar /opt/aws-opentelemetry-agent.jar<br><br># Here is the issue<br>RUN chown 1000 ./app.jar &amp;&amp; \<br>    chown 1000 /opt/aws-opentelemetry-agent.jar<br><br>USER 1000<br>ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;]</pre><p>When the COPY and ADD commands executed in Step 2, the image builder created new layers containing those files. After those layers became immutable. When RUN chown command executed, it attempted to change the ownership metadata of files inside those locked layers.</p><p>Builder cannot modify the existing read-only layer, So it copied built app.jar and the 40MB+ OpenTelemetry agent into a brand-new layer just to apply the new ownership metadata. This bloated the final image size by duplicating the heaviest files in the application.</p><p>To resolve this, the ownership permissions must be applied at the exact moment the files are added to the image. Here is my updated Docker file</p><pre># Step 1: Use Amazon Corretto 17 with Alpine Linux as the base image for building the application<br>...<br><br># Step 2: Use Amazon Corretto 17 with Alpine Linux as the runtime base image<br>FROM amazoncorretto:17-alpine3.17<br>ARG JAR_FILE=/workspace/app/build/libs/*.jar<br><br># Apply ownership directly during the COPY and ADD instructions<br>COPY --chown=1000:1000 --from=build ${JAR_FILE} app.jar<br>ADD --chown=1000:1000 https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.23.0/opentelemetry-javaagent.jar /opt/aws-opentelemetry-agent.jar<br><br>USER 1000<br>ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;]</pre><ul><li><strong>Before the Fix:</strong> 9 physical layers, 548MB total image size.</li><li><strong>After the Fix:</strong> 8 physical layers, ~508MB total image size.</li></ul><p>Finally I found hidden inefficiency, reduce my image size. Understanding how containers interact with the underlying operating system changes how we write and optimize Docker images. While fixing the layer duplication bug reduced only 40MB and cleaned up our filesystem, this is only the tip of the iceberg when it comes to container optimization and security. There is a whole world of distroless containers and CIS-hardened base images to explore but we’ll save those for a future post.<br>Happy building!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c95151362cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Centralizing CI/CD with Reusable Workflows and Cross-Repository Access]]></title>
            <link>https://medium.com/@keeerthana/centralizing-ci-cd-with-reusable-workflows-and-cross-repository-access-204f709f8fcc?source=rss-2747ae2a60b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/204f709f8fcc</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <dc:creator><![CDATA[Keerthana]]></dc:creator>
            <pubDate>Tue, 24 Mar 2026 01:56:35 GMT</pubDate>
            <atom:updated>2026-03-24T02:15:01.614Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nY7-zHIjmvtjCTZ-ng0dGg.png" /><figcaption><strong><em>Centralization</em></strong></figcaption></figure><p><strong><em>Centralization.</em></strong> GitHub Actions provides awesome but often underutilized capability. we can store all of the code, deployment logic, bash scripts, and GitHub workflow definitions in <strong>one single, centralized repository</strong>.<br><strong>Other repositories </strong>— which now act purely as <strong>configuration sources</strong> providing unique settings, environment variables, and inputs.</p><p>When a configuration repository triggers a run, GitHub dynamically pulls the scripts from <strong>centralized repository</strong> into the runner’s workspace. We get a single source of truth for our infrastructure, while our service teams get a plug-and-play deployment experience where they only manage their specific inputs.</p><h3>The Architecture Overview</h3><p>To demonstrate this, we will set up the following environment:</p><ol><li><strong><em>platform-devops-hub</em> (Deployment Source):</strong> This repository is owned by the platform team. It contains the master deployment scripts and the reusable GitHub Actions workflow. It holds all the &quot;how-to&quot; logic.</li><li><strong><em>client-config-alpha</em> (Input Source 1):</strong> A repository that provides the specific settings needed to deploy to the US region.</li><li><strong><em>client-config-beta</em> (Input Source 2):</strong> A completely separate repository that provides the exact settings needed to deploy to the EU region.</li></ol><p>Both configuration sources will trigger the exact same centralized workflow, but the centralized logic will dynamically adapt based on the specific inputs provided by each client.</p><h4>Step 1: Create PAT</h4><p>Because these repositories are private, they cannot talk to each other by default. We must create github PAT</p><p><strong>Create a Fine-Grained Personal Access Token (PAT):</strong></p><ul><li>Generate a PAT restricted to <em>only</em> the <strong><em>platform-devops-hub</em></strong> repository.</li><li>navigate to <em>user navigation menu -&gt; Settings -&gt; Developer settings -&gt; Personal access tokens -&gt; fined graned tokens -&gt; generate new token</em></li><li>Grant it <strong>Read-only</strong> access to <strong>Contents</strong>.</li><li>Save this token as a Repository Secret named PLATFORM_REPO_TOKEN inside both client-config-alpha and client-config-beta.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sMNnZYcOIUWoMaNauPCexg.png" /></figure><p><strong>Allow reusable workflows from</strong> <strong><em>platform-devops-hub</em></strong></p><ul><li>In the platform-devops-hub repository, go to <strong>Settings &gt; Actions &gt; General</strong>.</li><li>Scroll down to <strong>Access</strong> and select <strong>“Accessible from repositories owned by user/organization…”</strong></li><li>Save. This allows the client workflows to physically “see” our reusable workflow.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*qfMhHCiAfpPJFwmkYkDjMw.png" /></figure><h4>Step 2: Building the Centralized Repo</h4><p>First, create the master script that will handle the deployment for <em>any</em> service. Notice how this script is designed to look for a settings.yaml file that will eventually be provided by the configuration repositories.</p><p><strong>File:</strong> scripts/deploy.sh</p><pre>#!/bin/bash<br><br>echo &quot;Centralized Deployment&quot;<br><br># The script looks for settings.yaml in the root (where the configuration repo will be)<br>if [ ! -f &quot;./settings.yaml&quot; ]; then<br>  echo &quot;ERROR: No settings.yaml provided by the configuration repository.&quot;<br>  exit 1<br>fi<br><br># Extract variables provided by the specific configuration source<br>REPO_NAME=$(grep &quot;repo_name:&quot; ./settings.yaml | awk -F&#39;&quot;&#39; &#39;{print $2}&#39;)<br>TARGET_REGION=$(grep &quot;target_region:&quot; ./settings.yaml | awk -F&#39;&quot;&#39; &#39;{print $2}&#39;)<br><br>echo &quot;Configuration loaded successfully.&quot;<br>echo &quot;Deploying [$REPO_NAME] to region [$TARGET_REGION]...&quot;<br><br>echo &quot;Deployment complete!&quot;<br>echo &quot;========================================&quot;</pre><p>Next, create the <strong>Reusable Workflow</strong>. This workflow performs a powerful “double checkout”: it pulls the client’s settings into the main folder, and pulls central repo’s scripts into a subfolder.</p><p><strong>File:</strong> .github/workflows/central-deploy.yml</p><pre>name: Central Deployment Pipeline<br><br>on:<br>  workflow_call:<br>    secrets:<br>      PLATFORM_REPO_TOKEN:<br>        required: true<br><br>jobs:<br>  execute-deployment:<br>    runs-on: ubuntu-latest<br>    steps:<br>      # Checkout the Configuration Source (puts settings.yaml in the root)<br>      - name: Checkout Client Settings<br>        uses: actions/checkout@v4<br><br>      # Checkout the Central Repo<br>      - name: Checkout Central Repo<br>        uses: actions/checkout@v4<br>        with:<br>          repository: &lt;owner&gt;/platform-devops-hub<br>          path: platform-devops-hub<br>          token: ${{ secrets.PLATFORM_REPO_TOKEN }}<br><br>      # 3. Execute the shared logic<br>      - name: Run Deployment<br>        run: |<br>          chmod +x ./platform-devops-hub/scripts/deploy.sh<br>          ./platform-devops-hub/scripts/deploy.sh</pre><h4>Step 3: Setting up the Configuration Sources</h4><p>Service teams barely have to write any CI/CD code. They simply provide their configuration and call the central repo</p><p>Configuration Source 1: <strong><em>client-config-alpha</em></strong></p><p>This team needs a deployment to the US. They create their settings file in their repository root:</p><p><strong>File:</strong> settings.yaml (in client-config-alpha)</p><pre>repo_name: &quot;Alpha Repo&quot;<br>target_region: &quot;us-east-1&quot;</pre><p>Create a workflow to call the central repo reusable workflow, passing their secret token:</p><p><strong>File:</strong> .github/workflows/deploy.yml (in <strong><em>client-config-alpha</em></strong>)</p><pre>name: Deploy Alpha Service<br>on:<br>  push:<br>    branches: [ &quot;main&quot; ]<br>jobs:<br>  call-hub:<br>    uses: &lt;owner&gt;/platform-devops-hub/.github/workflows/central-deploy.yml@main<br>    secrets: inherit</pre><p>Runner Workspace for <strong><em>client-config-alpha</em></strong></p><pre>/home/runner/work/client-config-alpha/client-config-alpha/ (Workspace Root)<br>│<br>├── .github/<br>│   └── workflows/<br>│       └── deploy.yml             &lt;-- (Alpha&#39;s caller workflow)<br>│<br>├── settings.yaml                  &lt;-- (Alpha&#39;s config: region &quot;us-east-1&quot;)<br>│<br>└── platform-devops-hub/                &lt;-- (The Central Logic Hub)<br>    ├── .github/<br>    │   └── workflows/<br>    │       └── central-deploy.yml &lt;-- (The reusable workflow)<br>    │<br>    └── scripts/<br>        └── deploy.sh              &lt;-- (The universal deployment script)</pre><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Configuration Source 2: <strong><em>client-config-beta</em></strong></p><p>This team manages a service going to Europe. Their setup is identical, just providing different inputs.</p><p><strong>File:</strong> settings.yaml (in client-config-beta)</p><pre>repo_name: &quot;Beta Repo&quot;<br>target_region: &quot;eu-central-1&quot;</pre><p>Their workflow file (.github/workflows/deploy.yml) is an exact copy of Alpha&#39;s, simply pointing to the same central repo.</p><pre>name: Deploy Beta Service<br>on:<br>  push:<br>    branches: [ &quot;main&quot; ]<br>jobs:<br>  call-hub:<br>    uses: &lt;owner&gt;/platform-devops-hub/.github/workflows/central-deploy.yml@main<br>    secrets: inherit</pre><p>Runner Workspace for <strong><em>client-config-beta</em></strong></p><pre>/home/runner/work/client-config-beta/client-config-beta/ (Workspace Root)<br>│<br>├── .github/<br>│   └── workflows/<br>│       └── deploy.yml             &lt;-- (Beta&#39;s caller workflow)<br>│<br>├── settings.yaml                  &lt;-- (Beta&#39;s config: region &quot;eu-central-1&quot;)<br>│<br>└── platform-devops-hub/                &lt;-- (The Central Logic Hub)<br>    ├── .github/<br>    │   └── workflows/<br>    │       └── central-deploy.yml &lt;-- (The reusable workflow)<br>    │<br>    └── scripts/<br>        └── deploy.sh              &lt;-- (The universal deployment script)</pre><h3>Moment of Truth</h3><p>When we push code to client-config-alpha, GitHub provisions a runner.</p><ol><li>The runner assumes the identity of client-config-alpha.</li><li>It downloads client-config-alpha&#39;s files (including its specific settings.yaml) into the root directory.</li><li>It uses the secret token to securely reach into platform-devops-hub and download the universal deploy.sh script into a subfolder.</li><li>The central script executes, reading Alpha’s settings.yaml, and dynamically deploys to us-east-1.</li></ol><p>trigger client-config-beta, the exact same centralized code will execute, but it will read Beta&#39;s settings.yaml and deploy to eu-central-1.</p><h3>Why This is a Game Changer</h3><p>By adopting this centralized pattern, we achieve:</p><ul><li><strong>Single Source of Truth:</strong> If we need to update our deployment script to support a new cloud provider, we change <em>one</em> file in platform-devops-hub. All configuration sources instantly inherit the update.</li><li><strong>Strict Security:</strong> bake security scanners and compliance checks into the central workflow. The configuration repositories cannot bypass them.</li><li>Our teams don’t need to learn complex bash scripting or advanced GitHub Actions syntax. They just write a YAML configuration file and focus on their actual service.</li></ul><p>By centralizing your CI/CD logic, you are doing much more than just cleaning up your codebase. You are giving your platform team the peace of mind that security and compliance are handled universally.</p><p>It takes a little bit of upfront work to set up those access tokens and reusable workflows, but you DRY !!!</p><p>Happy automating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=204f709f8fcc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Your Own Nameserver: CoreDNS + Traefik on a Hetzner VPS]]></title>
            <link>https://medium.com/@keeerthana/running-your-own-nameserver-coredns-traefik-on-a-hetzner-vps-f41cadd87365?source=rss-2747ae2a60b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f41cadd87365</guid>
            <category><![CDATA[namecheap]]></category>
            <category><![CDATA[self-hosted]]></category>
            <category><![CDATA[nameserver]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[Keerthana]]></dc:creator>
            <pubDate>Mon, 16 Mar 2026 02:46:10 GMT</pubDate>
            <atom:updated>2026-04-25T06:12:52.573Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVwKParhEqBYKWKZXj9MSA.png" /></figure><h3>Why self-host your nameserver?</h3><p>When most people buy a domain, they point it to their registrar’s default nameservers or route it through Cloudflare. But if you are building a self-hosted infrastructure from scratch, we should try something new. <br>Lets build our own nameserver.</p><p>I recently purchased a bare-metal VPS from <strong>Hetzner</strong> and a domain (keerthanap.xyz) from <strong>Namecheap</strong>. Instead of relying on external DNS providers, I did run my own nameserver using <strong>CoreDNS</strong>, sitting securely behind a <strong>Traefik</strong> reverse proxy.</p><p>If you want complete control over your traffic routing and DNS resolution, continue reading :)</p><h3>1. The Infrastructure: Hetzner &amp; Namecheap</h3><p>The first step was acquiring the real estate. Spun up a Hetzner VPS, which gave me server’s public IP address.</p><p>Next, bought keerthanap.xyz domain from Namecheap. Now Mention top-level domain (TLD) registry where nameservers physically live which is ns1.keerthanap.xyz and ns2.keerthanap.xyz</p><p>But wait — Namecheap also needs to know what IP those hostnames resolve to. That’s what <em>glue records</em> are for. In the Namecheap advanced DNS dashboard, Registered custom nameservers and pointed them directly to server’s public IP:</p><p>ns1.keerthanap.xyz. -&gt; 204.168.138.156<br>ns2.keerthanap.xyz. -&gt; 204.168.138.156</p><p>This breaks the chicken-and-egg problem: the registry hardcodes these IPs alongside NS delegation so resolvers can bootstrap the chain of trust.</p><blockquote>You might have noticed I pointed both ns1 and ns2 to the exact same IP. In a higher environment, good practice is to have at least two <em>different</em> physical servers for your nameservers to provide a fallback if one goes down. Since I have single Hetzner VPS to start, I am using the same IP for both. Setting up true HA for DNS is a project for another day!</blockquote><p>Once those records propagated, 204.168.138.156 is officially responsible for answering any DNS queries for keerthanap.xyz.</p><h3>2. Crafting the CoreDNS Zone File</h3><p>Now that the internet was sending DNS queries to my server, we needed a service to actually answer them. Enter <strong>CoreDNS</strong>, a fast, flexible DNS server written in Go (used in k8s, just bragging for choosing coredns).</p><p>Created a custom zone file that mapped subdomains to 204.168.138.156 /etc/coredns/db.keerthanap.xyz contains</p><pre>keerthanap.xyz. 3600 IN SOA ns1.keerthanap.xyz. admin.keerthanap.xyz. (<br>    2026031401  ; Serial<br>    7200        ; Refresh<br>    3600        ; Retry<br>    1209600     ; Expire<br>    3600        ; Minimum TTL<br>)<br>keerthanap.xyz. 3600 IN NS ns1.keerthanap.xyz.<br>keerthanap.xyz.           3600 IN A 204.168.138.156<br>ns1.keerthanap.xyz.       3600 IN A 204.168.138.156<br>ns2.keerthanap.xyz.       3600 IN A 204.168.138.156<br>server.keerthanap.xyz.    3600 IN A 204.168.138.156<br>portfolio.keerthanap.xyz. 3600 IN A 204.168.138.156</pre><blockquote>Increment the serial number every time you change the zone file. Secondary resolvers use it to detect changes and refresh their cache.</blockquote><p>Corefile to load this specific zone into CoreDNS:</p><pre>keerthanap.xyz {<br>    file /etc/coredns/db.keerthanap.xyz<br>    log<br>    errors<br>}</pre><h3>3. Routing DNS Traffic with Traefik</h3><p>CoreDNS is not exposed directly to the wild. Used <strong>Traefik</strong> is the reverse proxy sitting in front of everything. It handles inbound HTTPS on port 443 and also forwards UDP port 53 to CoreDNS.</p><pre>services:<br>  traefik:<br>    image: traefik:v3.6.10<br>    container_name: traefik<br>    command:<br>      - &quot;--providers.docker=true&quot;<br>      - &quot;--providers.docker.exposedbydefault=false&quot;<br>      - &quot;--entrypoints.websecure.address=:443&quot;<br>      - &quot;--entrypoints.dns-udp.address=:53/udp&quot;<br>    ports:<br>      - &quot;53:53/udp&quot;   # DNS<br>      - &quot;443:443&quot;     # HTTPS<br>      - &quot;8080:8080&quot;   # Traefik dashboard<br>    volumes:<br>      - &quot;/var/run/docker.sock:/var/run/docker.sock:ro&quot;<br>      - &quot;/mnt/data/traefik/data:/data&quot;<br>    networks:<br>      - traefik-proxy<br>    restart: unless-stopped<br><br>networks:<br>  traefik-proxy:<br>    external: true</pre><h3>Putting it all together</h3><p>The flow when someone visits portfolio.keerthanap.xyz:</p><ol><li>Their recursive resolver queries the .xyz TLD, which returns Namecheap-registered NS glue: ns1.keerthanap.xyz → 204.168.138.156</li><li>Resolver queries CoreDNS on UDP port 53 at that IP</li><li>Traefik receives the UDP packet on its dns-udp entrypoint and passes it to CoreDNS</li><li>CoreDNS reads the zone file and returns the A record</li><li>Browser connects to 204.168.138.156:443, which Traefik handles and routes to the right container</li></ol><h3>What you can do when you own Nameserver</h3><p>Most interesting part is here. Running CoreDNS — directly on the host — means you can go far beyond just serving A records.</p><h4>Geo-based routing: different IPs for different regions</h4><p>With the geoip plugin and a <a href="https://dev.maxmind.com/geoip/geolocate-an-ip/databases/">MaxMind GeoLite2 database</a>, CoreDNS can inspect the source IP of the DNS query and return different A records depending on where the request is coming from. A user in Asia gets your Singapore server IP; a user in Europe gets your Frankfurt IP.</p><pre>keerthanap.xyz {<br>    geoip /etc/coredns/GeoLite2-City.mmdb<br>    template IN A {<br>        match &quot;^keerthanap\\.xyz\\.$&quot;<br>        answer &quot;{{ if eq .Geo.Country.ISOCode \&quot;IN\&quot; }}keerthanap.xyz. 60 IN A 65.21.1.1<br>               {{ else }}keerthanap.xyz. 60 IN A 95.217.1.1{{ end }}&quot;<br>    }<br>}</pre><blockquote>If you run CoreDNS in Docker, make sure you pass --net=host or use a host-mode network for the container — otherwise Docker NAT replaces the client IP with the gateway IP and geo-routing breaks completely.</blockquote><h4>Blocking Cloudflare DNS and other resolvers</h4><p>Since CoreDNS sees the source IP of whoever is querying it, you can drop or redirect queries from specific IPs. cloudflare’s public DNS resolvers 1.1.1.1 . You can refuse them with the acl plugin:</p><pre>keerthanap.xyz {<br>    acl {<br>        # Blocking Cloudflare&#39;s published IPv4 ranges (to force ECS)<br>        block type ANY net 173.245.48.0/20<br>        block type ANY net 103.21.244.0/22<br>        block type ANY net 103.22.200.0/22<br>        ...<br>        <br>        allow<br>    }<br>    file /etc/coredns/db.keerthanap.xyz<br>    log<br>    errors<br>}</pre><p>Instead of refusing, use the rewrite plugin to return a fake IP pointing to a custom &quot;you&#39;ve been blocked&quot; page whenever Google DNS asks about your domain. Pure chaos.</p><p><strong>But actually Why do we need to block any DNS Resolver? here is the reason</strong></p><p>My friend <a href="https://rka.xyz/">Rohit</a> does it for fun, and then he got a real reason to tell.<br>EDNS Client Subnet (ECS) is a DNS feature where the resolver passes along a small chunk of the user’s real IP address to your server so you can see where they are geographically located.</p><p><strong>Google DNS (8.8.8.8) actually passes ECS data.</strong> They share the user’s /24 subnet, so GeoDNS works perfectly fine with Google.</p><p><strong>Cloudflare (1.1.1.1) refuse to pass ECS data</strong> in the name of user privacy. Because they hide the client details, your server only sees Cloudflare’s IP, which completely breaks geographic routing. In fact, websites like archive.today famously blocked <a href="https://community.cloudflare.com/t/archive-today-is-failing-again/534317">Cloudflare’s DNS for this exact reason!</a></p><h4>Rate limiting</h4><p>The ratelimit plugin lets you cap how many queries per second a single source IP can make.</p><pre>keerthanap.xyz {<br>    ratelimit 100          # max 100 queries/sec per IP<br>    file /etc/coredns/db.keerthanap.xyz<br>}</pre><p>Find More interesting plugins here <a href="https://coredns.io/plugins/">coredns.io/plugins</a>, community supported plugins <a href="https://coredns.io/explugins/">coredns.io/explugins</a></p><p>Now its time for you to host your nameserver, and explore</p><p>Reference:</p><p>https://www.namecheap.com/support/knowledgebase/article.aspx/768/10/how-do-i-register-personal-nameservers-for-my-domain/<br>https://doc.traefik.io/traefik/routing/entrypoints/<br>https://coredns.io/<br>https://coredns.io/plugins<br>https://datatracker.ietf.org/doc/html/rfc7871</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f41cadd87365" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Volume Provisioning]]></title>
            <link>https://medium.com/@keeerthana/kubernetes-volume-provisioning-df14fb675ef6?source=rss-2747ae2a60b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/df14fb675ef6</guid>
            <category><![CDATA[pv]]></category>
            <category><![CDATA[aws-ebs]]></category>
            <category><![CDATA[pvc]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Keerthana]]></dc:creator>
            <pubDate>Wed, 21 Feb 2024 17:39:35 GMT</pubDate>
            <atom:updated>2026-03-16T01:29:34.079Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kubernetes Persistent Volume</h3><blockquote>Statie Provisioning vs Dynamic Provisioning</blockquote><h3>Static Provisioning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xPs3dks9GRoBt1pFuxZTig.png" /></figure><h3>Volume LifeCycle</h3><ul><li>Volume is initially created, and a PersistentVolume (PV) binds with a PersistentVolumeClaim (PVC).</li><li>When a Pod is deployed, the node is attached to the volume, allowing the Pod to access it.</li><li>When all Pods on a node are terminated or killed, the node gets detached from the volume.</li><li>Despite node detachment, the volume remains persistent.</li><li>When new Pods are created, either on the same node or another node, the volume is reattached to the node.</li></ul><blockquote>Static provisioning is crucial when you want to retain past data and attach existing volumes to a new PVC. This is common during migrations or disaster recovery.</blockquote><h4>claimRef Trick for Reusing PVs</h4><p>When you attach an existing volume to a new PVC (like in AWS EKS), the PV goes through specific state changes:</p><p><strong>Available:</strong> The initial state of the PV.<br><strong>Bound:</strong> Once the PVC claims it.<br><strong>Released:</strong> When the PVC is deleted.</p><p><strong>The Catch:</strong> Once a PV is in the Released state, you cannot just bind a new PVC to it. You must manually edit the PV and remove the claimRef block. This resets the status back to Available, allowing a new PVC to bind to it seamlessly while preserving all existing data!</p><h3>Dynamic Provisioning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w0J5GTQw3_NUaIIKS1Mxxw.png" /></figure><h3>Volume Lifecyle</h3><ul><li>StorageClass is created.</li><li>Only StorageClass is created, no other resources are created initially.</li><li>PVC is created.</li><li>PVC triggers dynamic provisioning of a PersistentVolume (PV) based on the StorageClass.</li><li>PV and EBS volume, EBS are created without any node attached.</li><li>Node attaches to the volume when pods are created.</li><li>When all pods are killed in the node, the node gets detached from the volume.</li><li>When new pods created node gets reattached using same volume</li></ul><blockquote>Dynamic provisioning is the default for most modern clusters, automatically creating storage resources as developers request them. Here are the rules for managing dynamically provisioned volumes:</blockquote><ul><li><strong>PVC Deletion isn’t Instant:</strong> You cannot delete a PVC directly if it’s currently in use. All associated Pods must be terminated first.</li><li><strong>Reclaim Policies:<br></strong>Retain: When the PVC is deleted, the PV and the underlying cloud volume (e.g., EBS) persist. They must be cleaned up manually.<br>Delete: Deleting the PVC automatically triggers the deletion of both the associated PV and the underlying cloud volume.</li><li><strong>Creating a New PVC:</strong> This automatically triggers the provisioning of a brand new PV and Volume based on your StorageClass parameters.</li><li><strong>The Limitation:</strong> In dynamic provisioning, you <em>cannot</em> simply attach an existing, pre-populated cloud volume to the cluster. For that, you need Static Provisioning.</li></ul><p><a href="https://kodekloud.com/community/t/had-a-question-to-edit-pvc-using-kubectl-edit-or-kubectl-patch-i-tried-doing-ed/21289/3">Resize PVC storage capacity</a>: only dynamically provisioned pvc can be resized and the storageclass that provisions the pvc must support resize. Regarding the resize of PVC which is associated with PV, you will need to delete the PVC then resize It and create It again.</p><ol><li>manually modify the volume storage</li><li>kill all the pods that are consuming PVC</li><li>delete PVC</li><li>update the PV capacity</li><li>create new PVC and bound with the existing PV</li><li>deploy the pods again</li></ol><h3>Increasing PVC Storage via Helm (Without Deleting the PVC)</h3><p>Resizing storage for a StatefulSet deployed via Helm can be tricky. You cannot simply change the size in the Helm values.yaml and run an upgrade, as StatefulSet volume claim templates are immutable.</p><p>Here is the workaround used to expand storage</p><h4>Step 1: Allow Volume Expansion</h4><p>Ensure your StorageClass allows expansion:</p><pre>kubectl edit storageClass &lt;sc-name&gt;</pre><p><em>Make sure </em><em>allowVolumeExpansion: true is present.</em></p><h4>Step 2: Orphan the StatefulSet</h4><p>Delete the StatefulSet, but leave the pods and PVCs running by using the --cascade=orphan flag. This prevents downtime while we make changes:</p><pre>kubectl delete sts --cascade=orphan &lt;sts-name&gt; -n &lt;namespace&gt;</pre><h4>Step 3: Manually Patch the PVCs</h4><p>Edit the storage capacity of each PVC directly in the cluster to your new desired limit (e.g., 50Gi):</p><pre>kubectl edit pvc &lt;pvc-name&gt; -n &lt;namespace&gt;</pre><h4>Step 4: Update Helm and Upgrade</h4><p>Now, change the requested storage size in your Helm chart’s values.yaml to match the exact value you just set in Step 3 (e.g., 50Gi). <em>Be cautious —the values must match exactly.</em></p><p>Finally, run the Helm upgrade:</p><pre>helm upgrade &lt;release-name&gt; &lt;chart-path&gt; -n &lt;namespace&gt; --recreate-pods --reuse-values</pre><p>This forces Helm to adopt the existing resources, recreating the StatefulSet with the new storage template and safely bouncing the pods to recognize the expanded volumes!</p><p>Reference:</p><p><a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/">https://kubernetes.io/docs/concepts/storage/persistent-volumes/</a><br><a href="https://github.com/keerthanap0810/eks-ebs">https://github.com/keerthanap0810/eks-ebs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df14fb675ef6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open AI Stream response missing the first token]]></title>
            <link>https://medium.com/@keeerthana/open-ai-stream-response-missing-the-first-token-cf77af218169?source=rss-2747ae2a60b1------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf77af218169</guid>
            <dc:creator><![CDATA[Keerthana]]></dc:creator>
            <pubDate>Sat, 11 Nov 2023 19:28:20 GMT</pubDate>
            <atom:updated>2026-03-16T01:11:28.685Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Open AI" src="https://cdn-images-1.medium.com/max/453/1*rlqZ32I-rzwGnMA0xZsZ2A.png" /></figure><p>The streaming response from OpenAI has undergone changes, impacting the handling and parsing of the response. A more robust approach is required to effectively manage this.</p><pre>const completion = await openai.createChatCompletion({<br>            model: &#39;gpt-3.5-turbo&#39;,<br>            messages: [{ role: &#39;user&#39;, content: template }],<br>            stream: true,<br>            temperature:0.7<br>        }, { responseType: &#39;stream&#39; });</pre><pre>const stream = completion.data;</pre><pre>stream.on(&#39;data&#39;, (chunk) =&gt; {<br>            const payloads = chunk.toString().split(&quot;\n\n&quot;);<br>            for (const payload of payloads) {<br>                if (payload.includes(&#39;[DONE]&#39;)) return;<br>                  console.log(payload)<br>            }<br>        });</pre><blockquote>so the payloads here is the array returned as a chunk from Open ai in a stream, previously the chunks would be</blockquote><p>chunk -1</p><pre>[<br>  `data: {&quot;id&quot;:&quot;chatcmpl-8Jh3daCazSSQaONS2m3x8ThuZ7NXw&quot;,&quot;object&quot;:&quot;chat.completion.chunk&quot;,&quot;created&quot;:1699704437,&quot;model&quot;:&quot;gpt-3.5-turbo-0613&quot;,&quot;choices&quot;:[{&quot;index&quot;:0,&quot;delta&quot;:{&quot;content&quot;:&quot;Hell&quot;},&quot;finish_reason&quot;:null}]}`,<br>  &#39;&#39;<br>]</pre><p>chunk-2</p><pre><br>[<br>  &#39;data: {&quot;id&quot;:&quot;chatcmpl-8Jh3daCazSSQaONS2m3x8ThuZ7NXw&quot;,&quot;object&quot;:&quot;chat.completion.chunk&quot;,&quot;created&quot;:1699704437,&quot;model&quot;:&quot;gpt-3.5-turbo-0613&quot;,&quot;choices&quot;:[{&quot;index&quot;:0,&quot;delta&quot;:{&quot;content&quot;:&quot;o world&quot;},&quot;finish_reason&quot;:null}]}&#39;,<br>  &#39;&#39;<br>]</pre><p>BUT after openai mode changed the payloads’s elements which are strings are spliced<br>chunk -1</p><pre>[<br>  `data: {&quot;id&quot;:&quot;chatcmpl-8Jh3daCazSSQaONS2m3x8ThuZ7NXw&quot;,&quot;object&quot;:&quot;chat.completion.chunk&quot;,&quot;created&quot;:1699704437,&quot;model&quot;:&quot;gpt-3.5-turbo-0613&quot;,&quot;choices&quot;:[{&quot;index&quot;:0,&quot;delta&quot;:{&quot;content&quot;:&quot;Hell&quot;},&quot;finish_reason&quot;:null}]}`,<br>  &#39;&#39;data: {&quot;id&quot;:&quot;chatcmpl-8Jh3daCazSSQaONS2m3x8ThuZ7NXw&quot;,&quot;o&#39;<br>]</pre><p>chunk-2</p><pre>[<br>  &#39;bject&quot;:&quot;chat.completion.chunk&quot;,&quot;created&quot;:1699704437,&quot;model&quot;:&quot;gpt-3.5-turbo-0613&quot;,&quot;choices&quot;:[{&quot;index&quot;:0,&quot;delta&quot;:{&quot;content&quot;:&quot;o world&quot;},&quot;finish_reason&quot;:null}]}&#39;,<br>  &#39;&#39;<br>]</pre><p>so parsing code that you have used to handle the chunks may not be suitable for processing a spliced JSON string.</p><p>The point is we need just the content, ignore rest other fields</p><pre>const regex = /&quot;choices&quot;:.*?&quot;delta&quot;:\{.*?&quot;content&quot;:&quot;(?&lt;newToken&gt;.*?)&quot;/s;<br>        stream.on(&#39;data&#39;, (chunk) =&gt; {<br>            const payloads = chunk.toString().split(&quot;\n\n&quot;);<br>            for (const payload of payloads) {<br>                if (payload.includes(&#39;[DONE]&#39;)) return;<br>                const matchPattern = regex.exec(payload);<br>                if (matchPattern &amp;&amp; matchPattern.groups.newToken) {<br>                    try {<br>                      let chunk = matchPattern.groups.newToken;<br>                      if (chunk) {<br>                        console.log(chunk);<br>                        res.write(chunk);<br>                      }<br>                    } catch (error) {<br>                        console.log(`Error with JSON.parse and ${payload}.\n${error}`);<br>                    }<br>                }<br>            }<br>        });</pre><pre>const regex = /&quot;choices&quot;:.*?&quot;delta&quot;:\{.*?&quot;content&quot;:&quot;(?&lt;newToken&gt;.*?)&quot;/s;</pre><p>This regular expression is crafted to extract information from a string that follows a specific pattern. It looks for a substring starting with &quot;choices&quot;:, followed by any characters until it encounters &quot;delta&quot;:{, and then continues to capture any characters until it finds the substring &quot;content&quot;:&quot;. The content between &quot;content&quot;:&quot; and the next occurrence of &quot; is placed in a named capturing group called newToken.</p><p>As I said before we need only the content and the regex does that, ignores all other fields.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf77af218169" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>