<?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 Nimesha Premaraja on Medium]]></title>
        <description><![CDATA[Stories by Nimesha Premaraja on Medium]]></description>
        <link>https://medium.com/@pmndilshan?source=rss-d7d5ef8229c1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LSoyIktC6u6O-p2c</url>
            <title>Stories by Nimesha Premaraja on Medium</title>
            <link>https://medium.com/@pmndilshan?source=rss-d7d5ef8229c1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:22:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pmndilshan/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[The process of kubectl Communicates with a Kubernetes Cluster]]></title>
            <link>https://medium.com/@pmndilshan/the-process-of-kubectl-communicates-with-a-kubernetes-cluster-64e18d6aee0d?source=rss-d7d5ef8229c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/64e18d6aee0d</guid>
            <category><![CDATA[kubectl-request-flow]]></category>
            <category><![CDATA[kubectl-request-lifecycle]]></category>
            <dc:creator><![CDATA[Nimesha Premaraja]]></dc:creator>
            <pubDate>Sat, 01 Aug 2026 12:05:21 GMT</pubDate>
            <atom:updated>2026-08-01T12:05:21.128Z</atom:updated>
            <content:encoded><![CDATA[<p>Kubernetes users run kubectl commands every day to interact with Kubernetes resources. Even though these commands appear simple, a series of interactions happens behind the scenes before the requested information appears in the terminal. Understanding how kubectl communicates with a Kubernetes cluster is essential for managing, troubleshooting, and operating a Kubernetes cluster. In this article, we will go through the complete process of a kubectl request from your local machine to the Kubernetes API Server and back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y5_ZakwbmrMo4e0oHTBTyQ.png" /></figure><h3>Step 1: The User Runs a kubectl Command</h3><p>Everything starts when a user executes a command in the terminal.</p><p><em>kubectl get pods</em></p><p>At this step, kubectl doesn’t directly communicate with Pods (acts as a client application), Nodes or any other Kubernetes resources. Instead, it sends requests to the <a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/">Kubernetes API Server</a>.</p><h3>Step 2: kubectl Reads the kubeconfig File</h3><p>Before reaching out to the cluster, kubectl checks the <a href="https://kubernetes.io/docs/reference/config-api/kubeconfig.v1/">kubeconfig</a> file, typically located at:</p><p><strong>~/.kube/config</strong> or set with <a href="https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#the-kubeconfig-environment-variable"><strong>KUBECONFIG</strong></a> environment variable.</p><p>This file contains:</p><ul><li>The target Kubernetes clusters, identified by name, API server URL, and Certificate Authority (CA) data</li><li>Credentials used to interact with the cluster</li><li>Context information that identifies which user and cluster should be used to connect and interact</li></ul><h3>Step 3: kubectl Builds an API Request</h3><p>After gathering the required configuration details, kubectl converts the command into a Kubernetes API request.</p><p><strong>For example:</strong> <em>kubectl get pods</em></p><p><strong>Something like</strong> <em>GET https://&lt;api-server&gt;:6443/api/v1/namespaces/default/pods</em></p><h3>Step 4: Secure Communication Over HTTPS</h3><p>kubectl sends the request to the Kubernetes API Server using HTTPS.</p><p>This communication is encrypted using TLS, ensuring the credentials and cluster data remain secure while transmission across the network.</p><p>The communication path is bidirectional:</p><ul><li>Requests transmit from kubectl to the API Server.</li><li>Responses transmit back from the API Server to kubectl.</li></ul><h3>Step 5: The API Server Processes the Request</h3><p>The API Server is the entry point for the Kubernetes cluster.</p><p>When it receives a request, it performs the following checking phases:</p><ol><li><strong>Authentication</strong> — Verifies the identity of the user.</li><li><strong>Authorization</strong> — Checks whether the user has permission to perform the requested action using <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/">RBAC</a>.</li><li><strong>Validation</strong> — Checks syntax and resource structure correctness. Confirms that the request is valid.</li><li><strong>Admission Control</strong> — Any command that creates, modifies, or deletes a resource (like kubectl apply) must pass through Mutating and Validating Admission Controllers.</li></ol><p>After passing these checks, Kubernetes processes the request.</p><h3>Step 6: The API Server Retrieves Cluster Data</h3><p><strong>etcd</strong> — Kubernetes’ distributed database that stores cluster state.</p><p>The API server reads (or writes) the relevant object data from <strong>etcd</strong>, the cluster’s key-value store, which is the single source of truth for cluster state.</p><p>For a <em>kubectl get pods</em> command, the API Server typically retrieves Pod information from the cluster state and prepares a response.</p><h3>Step 7: The API Server Returns the Response</h3><p>Once the requested information is collected, the API Server serializes the result and sends the response back to kubectl over the same secure HTTPS connection. While the API Server can serialize this data as JSON, kubectl generally defaults to requesting Protocol Buffers <em>(application/vnd.kubernetes.protobuf)</em> for this communication, as it is faster and more compact for network transmission.</p><h3>Step 8: kubectl Displays the Result</h3><p>Finally, kubectl receives the response, deserializes it <em>(Protobuf response)</em> formats it as the human-readable context which you see in your terminal.</p><ul><li>Standard human-readable table (default)</li><li>Full YAML object (if using -o yaml)</li><li>Full JSON object (if using -o json)</li></ul><h3>Key Takeaways</h3><ul><li>kubectl is only a client tool; it does not manage the cluster directly.</li><li>All interactions with Kubernetes go through the API Server.</li><li>The <em>kubeconfig</em> file provides connection and authentication details for each cluster.</li><li>Communication between kubectl and the cluster is secured using HTTPS/TLS.</li><li>The API Server authenticates, authorizes, and processes every request.</li><li>Cluster information is retrieved from etcd.</li><li>The response is returned to kubectl, which formats and displays the result to the user.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64e18d6aee0d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding VLSM: Efficient IP Management for Growing Networks]]></title>
            <link>https://medium.com/@pmndilshan/understanding-vlsm-efficient-ip-management-for-growing-networks-0f107c5b8281?source=rss-d7d5ef8229c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f107c5b8281</guid>
            <dc:creator><![CDATA[Nimesha Premaraja]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 12:42:32 GMT</pubDate>
            <atom:updated>2026-07-23T03:45:00.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qpNcSZ2odSyUgrnVW2v9Wg.png" /><figcaption>FLSM vs. VLSM</figcaption></figure><p>Variable Length Subnet Masking (VLSM) is a technique that allows network administrators to divide an IP address space into subnets of different sizes based on actual host requirements. Unlike traditional fixed-length subnetting (FLSM), that wastes IP addresses by assigning the same subnet size to every network segment, VLSM enables efficient IP address allocation by tailoring subnet masks to actual host requirements.</p><h4><strong>Importance &amp; Relevance of VLSM</strong></h4><ul><li><strong>Efficient IP Utilization </strong>— VLSM allows network administrators to design addresses for each subnet based on actual requirements, avoiding wastage inherent in fixed-size subnetting.</li><li><strong>Scalability</strong> — When Networks grow organically, with subnets of varying sizes added without redesigning the whole addressing scheme.</li><li><strong>Optimized Routing</strong> — By creating hierarchical subnetting, VLSM reduces the size of routing tables, which enhance network performance.</li><li><strong>Flexibility</strong> — Different segments of a network, such as servers, workstations, or IoT devices, can have custom-sized subnets, making network design more adaptable.</li><li><strong>Cost-Effectiveness</strong> — Efficient IP usage can delay the need for new IP address blocks, saving time and resources, especially in IPv4 networks where addresses are limited.</li></ul><h4><strong>VLSM Subnetting Example</strong></h4><p><strong>Scenario</strong>:</p><p>The Network Administrator has a IP <strong><em>192.168.2.0/24</em></strong>.</p><pre>These are the IP addresses requirements for each department.<br>➤ IT: 50,  Sales: 24, Management: 8</pre><p><strong>Solution</strong></p><pre>• Determine the class of the Network: 192.168.2.0/24 belongs to Class C<br>• Order the host requirements in descending order: IT &gt; Sales &gt; Management<br><br>• Start assigning subnets<br>For ease of understand convert ip block to binary format<br>11000000.10101000.00000010.00000000<br>|         Network         | Host  |<br><br>Network bits (24): 11000000.10101000.00000010<br>Host bits (8):     00000000<br><br><br><strong>👉 Start Subnet Calculation<br><br>IT Department </strong><br><br>To make 50 hosts we need 6 bits from Host ID<br>➤ Using the formula: 2^n − 2 ≥ required hosts<br><br>Where:<br>• n = number of host bits<br>• −2 = subtract network + broadcast<br><br>Calculation<br>n=6: 2^6−2 =62<br><br>Therefore allocate 6 Host bits and 26 Network Bits<br><br>Network Address<br>➤ Binary: 11000000.10101000.00000010.00 <strong>000000</strong><br>➤ Decimal: 192.168.2.0/26<br>➤ Subnet Mask: 255.255.255.192<br>➤ Usable range: 192.168.2.1 - 192.168.2.62<br><br><strong>Sales Department</strong><br>2^n − 2 ≥ 24<br>n=5: 2^5 - 2 = 30<br><br>Network Address<br>➤ Binary: 11000000.10101000.00000010.010 <strong>00000</strong><br>➤ Decimal: 192.168.2.64/27<br>➤ Subnet Mask: 255.255.255.224<br>➤ Usable range: 192.168.2.65 - 192.168.2.94<br><br><strong>Management Department</strong><br>2n − 2 ≥ 8<br>n=4: 2^4 - 2 = 14<br><br>Network Address<br>Binary: 11000000.10101000.00000010.0110 <strong>0000</strong><br>Decimal: 192.168.2.96/28<br>Subnet Mask: 255.255.255.240<br>Usable range: 192.168.2.97 - 192.168.2.110</pre><p><strong>In summery</strong></p><p>Variable Length Subnet Masking (VLSM) allows networks to use IP addresses efficiently by creating subnets of different sizes based on actual host needs. It enhances flexibility, manageability and ensures scalable network design by minimizing IP address wastage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f107c5b8281" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrate Terraform state from Terraform cloud to GCP Storage Bucket]]></title>
            <link>https://medium.com/@pmndilshan/migrate-terraform-state-from-terraform-cloud-to-gcp-storage-bucket-88be41a8c4aa?source=rss-d7d5ef8229c1------2</link>
            <guid isPermaLink="false">https://medium.com/p/88be41a8c4aa</guid>
            <dc:creator><![CDATA[Nimesha Premaraja]]></dc:creator>
            <pubDate>Sun, 28 Jan 2024 15:04:40 GMT</pubDate>
            <atom:updated>2024-02-22T16:39:39.910Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migrate Terraform state from Terraform Cloud to GCP Storage Bucket</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x0nTOJy1XJcfSPaGiwPqdg.png" /></figure><p>Terraform state is a crucial component that enables the Terraform to manage infrastructure effectively. The state file, usually stored remotely, maintains mappings between resource declarations in configuration files and the corresponding resources in the actual infrastructure. A <strong>backend</strong> defines where Terraform stores its state data files.</p><p>In this article we are going to discuss how to migrate Terraform state stored in Terraform cloud to <a href="https://developer.hashicorp.com/terraform/language/settings/backends/gcs">Google Cloud Storage (GCS) backend</a>.</p><p>Here I have created an IAM Service account using below code and I have stored state file on Terraform Cloud.</p><pre>terraform {<br>  cloud {<br>    organization = &quot;my-org&quot;<br><br>    workspaces {<br>      name = &quot;iam-sa&quot;<br>    }<br>  }<br>}<br><br>module &quot;dev-user-accounts&quot; {<br>  source            = &quot;terraform-google-modules/service-accounts/google&quot;<br>  version           = &quot;4.2.0&quot;<br>  project_id        = &quot;dev-project&quot;<br><br>  grant_xpn_roles   = false<br>  names             = [&quot;dev-user&quot;]<br>  project_roles     = []<br>}</pre><h3>Prepare for migration to GCS Backend</h3><p>Now we are going to migrate our infrastructure’s current Terraform state to existing Storage Bucket in Google Cloud.</p><ol><li>Navigate to your project directory and type <strong><em>terraform init</em></strong><em>. </em>This will create <em>.terraform</em> subdirectory.</li><li>Now we can obtain the latest Terraform state file using <strong><em>terraform state pull &gt; terraform.tfstate </em></strong>command<strong><em>.</em></strong></li><li>Remove the .terraform subdirectory and remove Terraform cloud backend.</li><li>Add new Backend configurations for GCS bucket in your code.</li><li>Update correct GCS backend prefix name. This prefix will be the directory path inside GCS bucket where Terraform state file will be stored.</li></ol><p>Final code will be look like this.</p><pre>terraform {<br>  backend &quot;gcs&quot; {<br>    bucket = &quot;dev-tf-state&quot;<br>    prefix = &quot;dev-user&quot;<br>  }<br>}<br><br>module &quot;dev-user-accounts&quot; {<br>  source            = &quot;terraform-google-modules/service-accounts/google&quot;<br>  version           = &quot;4.2.0&quot;<br>  project_id        = &quot;dev-project&quot;<br><br>  grant_xpn_roles   = false<br>  names             = [&quot;dev-user&quot;]<br>  project_roles     = []<br>}</pre><h3>Start Migration</h3><ol><li>Navigate to your project directory and type <strong><em>terraform init</em></strong><em>.</em></li><li>It will asks to copy existing backend to new gcs backend asn shown below. You have to type <strong>yes.</strong></li></ol><pre>Do you want to copy existing state to the new backend?<br>  Pre-existing state was found while migrating the previous &quot;local&quot; backend to the<br>  newly configured &quot;gcs&quot; backend. No existing state was found in the newly<br>  configured &quot;gcs&quot; backend. Do you want to copy this state to the new &quot;gcs&quot;<br>  backend? Enter &quot;yes&quot; to copy and &quot;no&quot; to start with an empty state.<br><br>  Enter a value:</pre><p>3. It will continue the initializing process. once that you can delete the <strong><em>terraform.tfstate </em></strong>in your local.</p><p>This will copy you local state file obtained from Terraform cloud to new GCS backend. However you have to carefully clean your Terraform cloud workspace after the migration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88be41a8c4aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>