<?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 Buddhima Udaranga on Medium]]></title>
        <description><![CDATA[Stories by Buddhima Udaranga on Medium]]></description>
        <link>https://medium.com/@buddhimau?source=rss-2e9e9001e4fe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*rqJp3Phh_ri-W7qo.jpg</url>
            <title>Stories by Buddhima Udaranga on Medium</title>
            <link>https://medium.com/@buddhimau?source=rss-2e9e9001e4fe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 03:51:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@buddhimau/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[I Tried BMad Method with Codex in VS Code. Here is the Windows Setup Guide]]></title>
            <link>https://buddhimau.medium.com/i-tried-bmad-method-with-codex-in-vs-code-here-is-the-windows-setup-guide-04bd8e32ffe6?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/04bd8e32ffe6</guid>
            <category><![CDATA[openai-codex]]></category>
            <category><![CDATA[bmad]]></category>
            <category><![CDATA[ai-assisted-development]]></category>
            <category><![CDATA[bmad-method]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sat, 02 May 2026 17:05:53 GMT</pubDate>
            <atom:updated>2026-05-02T17:05:53.017Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lNkY_AaYhnkzrJ2fbWFkPg.png" /></figure><p>AI coding tools move fast. You prompt. You get code. You fix issues. Then things drift. Structure fades. Decisions get messy.</p><p>I hit this problem.</p><p>I tested the BMad Method with Codex inside VS Code. This guide shows what I did on Windows. You can follow the same steps.</p><h3>Why BMad plus Codex</h3><p>Most AI coding follows this loop.</p><ul><li>Prompt</li><li>Output</li><li>Fix</li><li>Repeat</li></ul><p>This loop works for small tasks. It fails for larger builds.</p><p>BMad adds structure. You follow a fixed flow.</p><ul><li>Idea to Product Brief</li><li>Product Brief to PRD</li><li>PRD to Architecture</li><li>Architecture to Tasks</li><li>Tasks to Code</li></ul><p><em>Codex handles execution. BMad handles planning.</em></p><h4>Step 1. Create a project</h4><p>Start with a clean Next.js project.</p><p>Run:</p><blockquote>mkdir sl-practical-guide<br>cd sl-practical-guide</blockquote><blockquote>git init<br>npx create-next-app@latest .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TjHwzxV6_uzVbWaD-rr5pQ.png" /></figure><p>Pick default options.</p><ul><li>Next.js 16</li><li>TypeScript</li><li>Tailwind CSS</li></ul><p>Start the app.</p><blockquote>npm run dev</blockquote><p>Open <a href="http://localhost:3000/">http://localhost:3000</a></p><p>You now have a clean frontend app.</p><h4>Step 2. Install BMad</h4><p>Run inside the project folder.</p><blockquote>npx bmad-method install</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cwqqYi3M9F578qV9TOTU6A.png" /></figure><p>Select these modules.</p><ul><li>BMad Method</li><li>BMad Core</li><li>BMad Builder</li><li>Codex integration</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*oyy7VFonUn7lsg4CFuw3xg.png" /></figure><p>The setup takes a few minutes.</p><h4>Step 3. Check the new structure</h4><p>After install, you will see new folders.</p><p><em>_bmad-output/<br> docs/<br> .agents/skills/</em></p><p>Each folder has a purpose.</p><ul><li>_bmad-output holds generated documents</li><li>docs holds project knowledge</li><li>.agents/skills defines AI actions</li></ul><p>Your project now supports structured AI workflows.</p><h4>Step 4. Open VS Code</h4><p>Run:</p><blockquote>code .</blockquote><p>Open the Codex extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*r920nTfc0Od7T71oU27uIw.png" /></figure><p>Make sure the chat connects to your project.</p><p>You will work inside the chat from this point.</p><h4>Step 5. Start the first workflow</h4><p>Begin with the product brief.</p><p>Type this in Codex chat.</p><blockquote>bmad-product-brief</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*NO8iSOhtM33rXqAwp3VGug.png" /></figure><p>You will answer questions.</p><ul><li>What are you building</li><li>Who uses it</li><li>What problem do you solve</li></ul><p>Example I used.</p><p>A practical guide for tourists and expats in Sri Lanka. Focus on SIM cards, taxi pricing, scams, visa steps, coworking spaces.</p><p>Keep answers clear. Avoid marketing language. Focus on real use cases.</p><h4>Step 6. Continue the flow</h4><p>Run the next steps in order.</p><blockquote>bmad-create-prd<br>bmad-architecture<br>bmad-task-breakdown</blockquote><p>Each step builds on the previous output.</p><p>You move from idea to execution without guessing.</p><h4>Step 7. Check generated output</h4><p>Open the _bmad-output folder.</p><p>You will find:</p><ul><li>Product Brief</li><li>PRD</li><li>Architecture docs</li><li>Task breakdown</li></ul><p>These files form a complete plan.</p><p>You write less. You review more.</p><h3>Mistakes to avoid</h3><p>Skipping planning</p><ul><li>You lose structure</li><li>You return to prompt guessing</li></ul><p>Expecting instant output</p><ul><li>BMad follows steps</li><li>You must complete each step</li></ul><p>What changed in my workflow</p><p>Before:</p><ul><li>Prompt</li><li>Patch code</li><li>Repeat</li></ul><p>Now:</p><ul><li>Define problem</li><li>Write brief</li><li>Generate PRD</li><li>Design system</li><li>Break into tasks</li><li>Implement</li></ul><p>You spend more time thinking early. You save time during coding.</p><p>This setup fits well for:</p><ul><li>SaaS ideas</li><li>Side projects</li><li>Structured builds</li></ul><p>You get a clear path from idea to code.</p><p>References</p><p>1.<a href="https://github.com/bmad-code-org/BMAD-METHOD">https://github.com/bmad-code-org/BMAD-METHOD</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04bd8e32ffe6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Doesn’t Flow — We Just Feel Like It Does]]></title>
            <link>https://buddhimau.medium.com/time-doesnt-flow-we-just-feel-like-it-does-39527519ec8f?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/39527519ec8f</guid>
            <category><![CDATA[einstein]]></category>
            <category><![CDATA[spacetime]]></category>
            <category><![CDATA[time]]></category>
            <category><![CDATA[life-universe-everything]]></category>
            <category><![CDATA[general-relativity]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sun, 22 Feb 2026 19:25:06 GMT</pubDate>
            <atom:updated>2026-02-22T19:25:06.345Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxsBULD13kUBKya-SrvCAA.png" /></figure><h3>When Two Clocks Argue, Both Are Right</h3><p>We feel time as if each moment is being replaced by a new one. The past feels behind us, and the future feels like something that hasn’t happened yet. But according to the theory of relativity, time and space aren’t separate they’re connected as one thing called spacetime. So when you move through space, you’re also moving through time. That would mean time can actually pass differently for different people, depending on how they’re moving relative to each other.</p><p>Imagine a <strong>very simple clock</strong>:</p><ul><li>Two mirrors facing each other</li><li>A beam of light bouncing up and down between them</li><li>Each bounce = <strong>one tick</strong></li></ul><p>This is called a <em>light clock</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kN4nGjJFbrYq-Mfnb71Wlw.png" /></figure><h3>Case 1: Clock at rest (Friend A)</h3><p>Friend A is standing still relative to you.</p><p>From your point of view:</p><ul><li>Light goes <strong>straight up and down</strong></li><li>Short path</li><li>Each tick takes a certain time</li></ul><p>So far, no surprises.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4h0rBkF1ucPKgbDefp-WIQ.png" /></figure><h3>Case 2: Clock moving fast (Friend B)</h3><p>Now Friend B is moving sideways very fast in a spaceship <strong>while the light clock is ticking</strong>.</p><p>Here’s the crucial part:</p><p>From <em>your</em> point of view:</p><ul><li>The light does <strong>not</strong> go straight up and down</li><li>It follows a <strong>diagonal path</strong></li><li>That path is <strong>longer</strong></li></ul><p>Now here is the magic statement, <strong>The speed of light is the same for everyone. </strong>If light travels a longer distance and cannot go faster, <strong>the tick must take more time</strong>.</p><h3>What is NOW?</h3><p>From your friend’s point of view inside the spaceship, nothing strange is happening. The light in the clock moves straight left and right between the two mirrors, just like it’s supposed to. At any moment, your friend can say where the light is right now it’s exactly halfway between the mirrors. But when you watch that same clock at the same time, From your point of view the light is following a diagonal path, and because simultaneity depends on motion, <strong><em>the moment your friend calls “now” is not the same moment you call “now.”</em></strong></p><h3><em>If Everyone Has a Different “Now”, Which One Is Real?</em></h3><p>There isn’t a single, universal “now” that the entire universe agrees on. Each observer carries their own present with them, defined by how they’re moving through spacetime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z90xjPx5iiLKNLhYDv-zVg.png" /></figure><p>Each observer slices spacetime differently, depending on how they’re moving, and each slice defines their own present moment. <strong>The block universe is simply the idea that all these different slices are cutting through the same fixed structure.</strong></p><p>In the block universe:</p><ul><li>The <strong>past</strong> still exists</li><li>The <strong>present</strong> exists</li><li>The <strong>future</strong> also exists</li></ul><h3>Does the Block Universe Mean Free Will Is an Illusion?</h3><p><strong>This is the part that hurts my head the most.</strong><br> If my future already exists, does that mean I don’t have free will?<br> No matter what I do, is my future already decided? Imagine a huge mountain range with many trails. From far above, the entire landscape already exists:</p><ul><li>Every peak</li><li>Every valley</li><li>Every trail from start to finish</li></ul><p>Nothing appears as you walk. The mountain isn’t being built under your feet.Now imagine you’re hiking.</p><p>You experience:</p><ul><li>One step at a time</li><li>One bend in the trail at a time</li><li>One decision at a time</li></ul><p>From where you stand, the next turn feels open and uncertain.But the trail itself already exists. At a fork in the path, you choose left or right. That choice matters. It determines where you’ll end up. But both paths are real.<br> They were part of the mountain long before you arrived. Choosing one path doesn’t erase the other. It just determines <strong>which route becomes your journey</strong>. That’s how the block universe treats choice. <strong>The mountain doesn’t force your steps. It just holds all the paths.</strong></p><h3>You Exist Across Time, Not In a Single Moment</h3><p>If your childhood exists in one part of spacetime and your old age exists in another, which one is the real you?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBTeibqPTrMPLTu5LRNADQ.png" /></figure><h3>What physics actually says</h3><ul><li>Spacetime contains events</li><li>Your decisions are events</li><li>There is no external force “taking” you somewhere</li></ul><p>You are not being carried along a track. You are <strong>part of how the track is formed</strong>. The decisions you make during the track are a result of physical process that happens in your brain, and that process is part of spacetime. Instead of asking: “Am I controlled by spacetime?” Think: “I am one of the ways spacetime behaves.”</p><h3>References &amp; Further Reading</h3><ol><li>Einstein, A. (1905). <em>On the Electrodynamics of Moving Bodies.</em></li><li>Minkowski, H. (1908). <em>Space and Time.</em></li><li>Greene, B. <em>The Fabric of the Cosmos.</em></li><li>Stanford Encyclopedia of Philosophy — Eternalism.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39527519ec8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive CI/CD Guide: Deploying a Spring Boot Application on Choreo — Deploying your docker…]]></title>
            <link>https://buddhimau.medium.com/a-comprehensive-ci-cd-guide-deploying-a-spring-boot-application-on-choreo-deploying-your-docker-aebd7b8f1c72?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/aebd7b8f1c72</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[choreo]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[wso2is]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Wed, 13 Dec 2023 16:43:49 GMT</pubDate>
            <atom:updated>2023-12-15T18:25:11.257Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Comprehensive CI/CD Guide: Deploying a Spring Boot Application on Choreo — Deploying your docker image in Choreo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/0*6GcHR2Lzatws8wGi.png" /></figure><p>Welcome back, fellow developers! In our previous <a href="https://medium.com/@buddhimau/a-comprehensive-ci-cd-guide-deploying-a-spring-boot-application-on-choreo-crafting-a-dockerfile-ce0fd039b666">blogs</a>, we embarked on a journey of crafting a sleek Spring Boot application and encapsulating it within a Docker embrace. Today, our adventure takes a thrilling turn as we explore the realm of container orchestration with WSO2 Choreo. Buckle up as we unravel the magic behind deploying our Dockerized creation onto the orchestration stage, where WSO2 Choreo orchestrates the symphony of containers with finesse. Get ready to witness the seamless dance of microservices orchestrated in perfect harmony. Let the show begin! 🚀 #WSO2Choreo #ContainerOrchestration #DevOpsMagic</p><h3>What is choreo</h3><p>Choreo represents an internal developer platform that transforms the way you craft digital experiences. With Choreo, you have the capability to effortlessly design, develop, deploy, and govern your cloud-native applications. This platform not only fosters innovation but also significantly minimizes time-to-market.</p><h3>Configuring Endpoints.yaml</h3><p>First you need to create your open api definition for your spring boot application. For this you will need the following dependency</p><pre>&lt;dependency&gt;</pre><pre>&lt;groupId&gt;org.springdoc&lt;/groupId&gt;</pre><pre>&lt;artifactId&gt;springdoc-openapi-starter-webmvc-ui&lt;/artifactId&gt;</pre><pre>&lt;version&gt;2.2.0&lt;/version&gt;</pre><pre>&lt;/dependency&gt;</pre><p>This will generate a yaml file that has the specifications of the APIs defined in your spring boot application.</p><p>Then create a .choreo folder in your github repo and have a yaml file named endpoints.yaml</p><pre>version: 0.1</pre><pre>endpoints:</pre><pre>- name: Employee API</pre><pre>port: 8080</pre><pre>type: REST</pre><pre>networkVisibility: Public</pre><pre>context: /</pre><pre>schemaFilePath: openapi.yaml</pre><p><a href="https://github.com/Buddhimah/demo-vehicle-service/blob/main/.choreo/endpoints.yaml">demo-vehicle-service/.choreo/endpoints.yaml at main · Buddhimah/demo-vehicle-service</a></p><p>The openapi.yaml file can be obtained from the earlier step and should be committed just outside the .choreo folder.</p><h3>Trying Out</h3><p>Go to <a href="https://console.choreo.dev/signup">https://console.choreo.dev/signup</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/0*Tqo4vZzw1-iFbrig" /></figure><p>You can sign in simply using Google or using the email address. Then it will prompt you to create a organization</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xi36_uKNm0l2fmlY" /></figure><p>You will have a default project created and you can click on the default project. That will direct you to a page as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ApSXINaDJoDqLPfp" /></figure><p>Click on create and then service</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-zgeQrFicYnOUoIN" /></figure><p>Enter a component name and then click on Authorize with github.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9hU5CRzm0Rpwv-s-" /></figure><p>This should show a repositories of the github account you have connected. Then you can click on Docker and select docker context and docker file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V4YgoPjesLXWY2Jq" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wULWVyPEBZqT5q4N" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1qMgLgZjo5E_ImB8" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e6DB0TkAOrvE4hfE" /></figure><p>In the left plane there is a deploy button when you clicked on that you will be directed to the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lNuS8xk2sJx2a8Ba" /></figure><p>Then click on build.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/0*O-p9qOUqfp18c8Ue" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fj2hTjMMxgeXXpoo" /></figure><p>In build now you should see the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*CZeJjuGYlqyuPDQm" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/0*RU5O_sr2wKHiW_XF" /></figure><p>Click on Test in the left plane and then click the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MwAHuPIt9RBqG_B9" /></figure><p>You can try your APIs from here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aebd7b8f1c72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive CI/CD Guide: Deploying a Spring Boot Application on Choreo — Crafting a Dockerfile…]]></title>
            <link>https://buddhimau.medium.com/a-comprehensive-ci-cd-guide-deploying-a-spring-boot-application-on-choreo-crafting-a-dockerfile-ce0fd039b666?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce0fd039b666</guid>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[choreo]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Wed, 13 Dec 2023 16:23:50 GMT</pubDate>
            <atom:updated>2023-12-13T16:23:50.741Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Comprehensive CI/CD Guide: Deploying a Spring Boot Application on Choreo — Crafting a Dockerfile for Seamless Deployment</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*DPoeXfDgMk9Rj-jb" /></figure><p>Welcome back to our Spring Boot and Choreo deployment series! In our <a href="https://medium.com/@buddhimau/a-comprehensive-ci-cd-guide-deploying-a-spring-boot-application-on-choreo-63d249b8a83f">last blog</a>, we covered the ins and outs of building and versioning your Spring Boot app. Now, in Part 2, we’re diving into Dockerfile creation — the key to seamless deployment with Choreo.</p><p>In this blog, we’ll guide you through the essentials of crafting a Dockerfile, from defining the base image to optimizing performance. By the end, you’ll be ready to transform your Spring Boot app into a deployable container, perfectly suited for Choreo’s deployment orchestration.</p><p>Let’s get started on this containerization journey — your ticket to streamlined and efficient deployment!</p><h3>Base Image</h3><blockquote>FROM openjdk:17-alpine</blockquote><p>Starting your Dockerfile with the FROM instruction is a crucial step, as it defines the base image for your container. In your case, you’ve chosen the Alpine variant of OpenJDK 17, a lightweight Linux distribution. But why does it have to be lightweight,</p><p>Choosing a lightweight base image, such as Alpine Linux, for your Docker containers offers several advantages in the context of microservices, cloud-native applications, and containerized environments. Here are a few reasons why a lightweight base image is often preferred:</p><h4>Security</h4><p>Minimalistic images often have a reduced attack surface because they include only essential components. This can contribute to a more secure environment by minimizing potential vulnerabilities.</p><h4>Reduced Image Size</h4><p>Lightweight base images typically have a smaller footprint compared to their full-fledged counterparts. This is crucial for faster image downloads, quicker container startup times, and more efficient use of storage</p><blockquote>WORKDIR /app</blockquote><p>The WORKDIR command in Docker is used to set the working directory for any subsequent RUN, CMD, ENTRYPOINT, COPY, and ADD instructions in the Dockerfile.</p><p>In this case, the /app directory is being set as the working directory. This means that any subsequent commands or file operations will be relative to this directory unless an absolute path is specified.</p><blockquote>ARG USER=buddhima</blockquote><blockquote>ARG USER_GROUP=buddhima</blockquote><blockquote>ARG USER_ID=10001</blockquote><blockquote>ARG USER_GROUP_ID=10001</blockquote><p>Running processes as a non-root user in a container enhances security. If a container runs as the root user and gets compromised, it might have more privileges on the host system, potentially leading to security vulnerabilities. By running the container as a non-root user, you limit the potential impact of security breaches.</p><blockquote>RUN addgroup -g ${USER_GROUP_ID} -S ory; \</blockquote><blockquote>adduser -u ${USER_ID} -S ory -G ory -D -h /app -s /bin/nologin; \</blockquote><blockquote>chown -R ${USER_ID}:${USER_GROUP_ID} /app</blockquote><p>addgroup -g ${USER_GROUP_ID} -S ory;: This command creates a group named “ory” with the specified group ID (USER_GROUP_ID). The -S flag indicates that this is a system group.</p><p>adduser -u ${USER_ID} -S ory -G ory -D -h /app -s /bin/nologin;: This command creates a user named “ory” with the specified user ID (USER_ID). The user is added to the “ory” group (-G ory). The -S flag indicates that this is a system user. The -D flag instructs adduser to create a home directory (-h /app). The shell for this user is set to /bin/nologin to restrict login access.</p><p>chown -R ${USER_ID}:${USER_GROUP_ID} /app: This command changes the ownership of the “/app” directory and its contents recursively to the user and group created earlier.</p><p>By setting the shell to /bin/nologin, you ensure that the user cannot log in interactively. This is beneficial for security because if an attacker gains access to the container or system, they won’t be able to log in using the compromised user account.</p><blockquote>ADD — chown=10001:10001 <a href="https://github.com/Buddhimah/demo-vehicle-service/releases/download/v0.0.34/employee-0.0.34.jar">https://github.com/Buddhimah/demo-vehicle-service/releases/download/v0.0.34/employee-0.0.34.jar</a> /app/</blockquote><p>— chown=10001:10001: This option sets the ownership of the copied file or directory to the specified user and group IDs. In this case, it’s setting the ownership to the user ID 10001 and the group ID 10001.</p><p><a href="https://github.com/Buddhimah/demo-vehicle-service/releases/download/v0.0.34/employee-0.0.34.jar:">https://github.com/Buddhimah/demo-vehicle-service/releases/download/v0.0.34/employee-0.0.34.jar:</a> This is the source URL from which the file is downloaded. In this case, it’s a JAR file hosted on GitHub.</p><p>/app/: This is the destination directory inside the Docker image where the file will be copied.</p><p>So, this ADD instruction fetches the JAR file from the specified URL and copies it into the /app/ directory in the Docker image, setting the ownership to the user with ID 10001 and group with ID 10001. This is a common practice to ensure that the file is owned by a specific non-root user within the container, adhering to the principle of least privilege for security reasons.</p><p>The finalised docker file can be found <a href="https://github.com/Buddhimah/demo-vehicle-service/blob/main/Dockerfile">https://github.com/Buddhimah/demo-vehicle-service/blob/main/Dockerfile</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce0fd039b666" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive CI/CD Guide: Deploying a Spring Boot Application on Choreo]]></title>
            <link>https://buddhimau.medium.com/a-comprehensive-ci-cd-guide-deploying-a-spring-boot-application-on-choreo-63d249b8a83f?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/63d249b8a83f</guid>
            <category><![CDATA[choreo]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[pipeline]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sun, 10 Dec 2023 17:41:44 GMT</pubDate>
            <atom:updated>2023-12-10T17:41:44.415Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Kd81H1Ex6T569dpC" /></figure><p>Embarking on the journey of deploying a Spring Boot application as a Docker container in Choreo? Look no further. This concise guide walks you through setting up a robust CI/CD pipeline, ensuring seamless integration from version control to Choreo deployment.</p><p>Whether you’re a seasoned developer or new to CI/CD, this tutorial simplifies the process, covering automated testing, containerization, and deployment. By the end, you’ll have a Spring Boot app ready for Choreo, streamlining your development and ensuring reliable application delivery. Ready to dive in? Let’s get started!</p><h3>Spring Boot Application Development</h3><p>I used a sample spring boot application that we can simply create using <a href="https://start.spring.io/">https://start.spring.io/</a>. Since this blog is more focused on the CI CD process I will not go in to Spring Boot Java code level.</p><p><a href="https://github.com/Buddhimah/demo-vehicle-service">https://github.com/Buddhimah/demo-vehicle-service</a></p><p>You can refer to the code from here. This has some APIs related to employee’s. These APIs will return and has the possibility to update some mock data provided using a sql file in resources.</p><h3>CI Build Automation</h3><p>For this I have used github actions. This github action is responsible for building the java project and releasing a versioned artifact.</p><h4>Triggers</h4><p>We have configured this Github action to trigger on a push to the branch main on this repo, Also this can be triggered by a pull request as well.</p><h4>Jobs</h4><p>Here I have used Jobs in Github actions. Job is a set of steps that get executed in a same VM to collectively perform a specific task. Since the task is to build then identify whether build is successful. And if the build is successful trigger a release with release artifacts with latest changes. The version numbers should auto increment.</p><p>Since the build and release should happen in the same environment although those two are two steps I used Jobs.</p><p>Here I have configured java using a built in Github action actions/setup-java@v3. I have specified java version as Java 17 as the distribution I have used temurin since it is community driven and opensource.</p><p>To improve build timing I have added cache: maven, This enables caching in maven dependencies.</p><h4>Steps</h4><p>The job consists of two steps the first one is responsible for building the repo with the latest version and creating a release artifact.</p><ol><li>Building with the latest version</li></ol><p>To fetch the latest version the github action should have access to the latest tag. This requires a token. You can add a token to your github actions via your repo settings.</p><p>To retrieve the latest tag of a repository using a GitHub token, you need to ensure that the token has at least read access to the repository. Specifically, the token should have the repo scope, which includes the necessary permissions for reading repository-related data.</p><p>Here are the steps to create a GitHub token with the required scope:</p><p>Here are the steps to create a GitHub token with the required scope:</p><ul><li>Go to your GitHub account settings.</li><li>Navigate to “Developer settings” and then “Personal access tokens.”</li><li>Click on “Generate token.”</li><li>Provide a token description and select the appropriate scopes.</li></ul><p>At a minimum, you need to select the repo scope. If you only need read access, you can unselect other unnecessary scopes.</p><p>Click on “Generate token” to create the token.</p><p>You can go to <a href="https://github.com/Buddhimah/demo-vehicle-service/settings/secrets/actions">https://github.com/&lt;GITHUB USERNAME&gt;/&lt;REPO NAME&gt;/settings/secrets/actions</a> to configure the created token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nD0Bw8B9x6Q5Aa-p" /></figure><p>To use this token in github action you can use the following code snippet.</p><blockquote><strong>echo ${{ secrets.TOEKN }} | gh auth login — with-token</strong></blockquote><p>To fetch the latest tag you can use the following gh command</p><blockquote><strong>current_tag=$(gh api repos/Buddhimah/demo-vehicle-service/releases/latest | jq -r ‘.tag_name’)</strong></blockquote><p>I have used the following logic to increment the tag version to create the next version.</p><blockquote><strong>regex=”v([0–9]+).([0–9]+).([0–9]+)”</strong></blockquote><p>Usually we have three number versioning system to identify major minor and patch version changes. So I have defined a regular expression to match with semantic versioning.</p><blockquote><strong>if [[ $current_tag =~ $regex ]]; then</strong></blockquote><blockquote><strong>major=”${BASH_REMATCH[1]}”</strong></blockquote><blockquote><strong>minor=”${BASH_REMATCH[2]}”</strong></blockquote><blockquote><strong>patch=”${BASH_REMATCH[3]}”</strong></blockquote><blockquote><strong>else</strong></blockquote><blockquote><strong>echo “Invalid tag format”</strong></blockquote><blockquote><strong>exit 1</strong></blockquote><blockquote><strong>fi</strong></blockquote><p>Above logic is responsible for matching the latest version with the regular expression and then extracting each of the version numbers.</p><blockquote><strong># Increment the patch version</strong></blockquote><blockquote><strong>patch=$((patch + 1))</strong></blockquote><p>Assuming all the releases are patch releases this workflow will increment the patch number one by one using the above logic</p><blockquote><strong># Form the new tag</strong></blockquote><blockquote><strong>new_tag=”v${major}.${minor}.${patch}”</strong></blockquote><p>Finally the new patch number will be appended to the major and minor versions and create the new version.</p><blockquote><strong>mvn clean install</strong></blockquote><blockquote><strong>mvn -Dmaven.repo.local=./target/ install:install-file -Dfile=./target/employee-0.0.1-SNAPSHOT.jar -DgroupId=com.example -DartifactId=employee -Dversion=$new_version -Dpackaging=jar</strong></blockquote><p>The maven clean install command will build the code with tests. During this build if there are any failures that will fail the build.</p><p>If the build passes then the next command will have a <strong>employee-0.0.1-SNAPSHOT.jar </strong>in the target directory. If the build failed the next command will also fail.</p><p>Mvn install command manually installing a JAR file into the local Maven repository with specific coordinates (group ID, artifact ID, version). Here I will be installing the employee-0.0.1-SNAPSHOT.jar file as the latest version</p><blockquote><strong>echo “new_tag=$new_tag” &gt;&gt; $GITHUB_ENV</strong></blockquote><blockquote><strong>echo “new_version=$new_version” &gt;&gt; $GITHUB_ENV</strong></blockquote><p>Since the new version and the new tag should be passed to the next step they are being write in to the GITHUB environment variable.</p><h3>Releasing the artifact</h3><blockquote><strong>gh release create — title “Release” — notes “Release $new_tag” $new_tag ./target/com/example/employee/$new_version/employee-$new_version.jar</strong></blockquote><p>Im using the above gh command to create a release with the new artifact built.</p><p>This is the first of a blog series. The next blog will explain on how to create a docker image for this application and then lets discuss on how to deploy this on choreo.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63d249b8a83f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Affinity In Nginx Ingress Controller-2]]></title>
            <link>https://buddhimau.medium.com/affinity-in-nginx-ingress-controller-2-1c8b28c83604?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c8b28c83604</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[nginx-ingress]]></category>
            <category><![CDATA[affinity]]></category>
            <category><![CDATA[nginx-ingress-controller]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 18:28:13 GMT</pubDate>
            <atom:updated>2022-12-10T18:28:13.618Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kQg_wSf5OURsVg3rjdrGFA.jpeg" /></figure><p>In an earlier <a href="https://buddhimau.medium.com/affinity-in-nginx-ingress-controller-1-247e733229c5">blog</a> we have discussed the basics of session affinity, How to configure it. In this blog we will focus on the internals of nginx ingress controller.</p><p>Going through this blog you will learn what will happen to a request that comes to a ingress controller. Which methods will execute internally how it maintain session affinity kind of stuff.</p><h3>How Nginx Controller generate nginx.conf</h3><p>If you have worked with nginx you should be familiar with the nginx configuration file nginx.conf. Have you ever thought what is the configuration file in nginx controller.</p><p>In Nginx ingress controller we provide configuration through ingress yaml files. For example you will have to create something like below.</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: hello-world-ingress<br>spec:<br>  ingressClassName: nginx<br>  rules:<br>  - host: demo.com<br>  - http:<br>      paths:<br>      - path: /<br>        pathType: Prefix<br>        backend:<br>          service:<br>            name: hello<br>            port:<br>              number: 80</pre><p>When we apply this kind of configuration through the K8s API they are been picked up from the nginx ingress controller and it results to reload the configuration resulting a configuration file.</p><p>In that configuration file (nginx.conf) with respect to the ingress configuration we have provided above a block of configuration will be created as below.</p><pre>## start server demo.com<br> server {<br>  server_name demo.com;<br>  <br>  listen 80  ;<br>  listen [::]:80  ;<br>  listen 443  ssl http2 ;<br>  listen [::]:443  ssl http2 ;<br>  <br>  set $proxy_upstream_name &quot;-&quot;;<br>  <br>  ssl_certificate_by_lua_block {<br>   certificate.call()<br>  }<br>  <br> location ~* &quot;/&quot; {<br>  <br>  set $namespace      &quot;default&quot;;<br>  set $ingress_name   &quot;hello-world-ingress&quot;;<br>  set $service_name   &quot;hello&quot;;<br>  set $service_port   &quot;80&quot;;<br> set $location_path  &quot;/&quot;;<br>  <br>  rewrite_by_lua_block {<br>   lua_ingress.rewrite({<br>    force_ssl_redirect = false,<br>    ssl_redirect = true,<br>    force_no_ssl_redirect = false,<br>    use_port_in_redirects = false,<br>   })<br>   balancer.rewrite()<br>   plugins.run()<br>  }<br>  <br>  # be careful with `access_by_lua_block` and `satisfy any` directives as satisfy any<br>  # will always succeed when there&#39;s `access_by_lua_block` that does not have any lua code doing `ngx.exit(ngx.DECLINED)`<br>  # other authentication method such as basic auth or external auth useless - all requests will be allowed.<br>  #access_by_lua_block {<br>  #}<br>  <br>  header_filter_by_lua_block {<br>   lua_ingress.header()<br>   plugins.run()<br>  }<br>  <br>  body_filter_by_lua_block {<br>  }<br>  <br>  log_by_lua_block {<br>   balancer.log()<br>   <br>   monitor.call()<br>   <br>   plugins.run()<br>  }<br>  <br>  port_in_redirect off;<br>  <br>  set $balancer_ewma_score -1;<br>  set $proxy_upstream_name &quot;hello&quot;;<br>  set $proxy_host          $proxy_upstream_name;<br>  set $pass_access_scheme  $scheme;<br>  <br>  set $pass_server_port    $server_port;<br>  <br>  set $best_http_host      $http_host;<br>  set $pass_port           $pass_server_port;<br>  <br>  set $proxy_alternative_upstream_name &quot;&quot;;<br>  <br>  client_max_body_size                    1m;<br>  <br>  proxy_set_header Host                   $best_http_host;<br>  <br>  # Pass the extracted client certificate to the backend<br>  <br>  # Allow websocket connections<br>  proxy_set_header                        Upgrade           $http_upgrade;<br>  <br>  proxy_set_header                        Connection        $connection_upgrade;<br>  <br>  proxy_set_header X-Request-ID           $req_id;<br>  proxy_set_header X-Real-IP              $remote_addr;<br>  <br>  proxy_set_header X-Forwarded-For        $remote_addr;<br>  <br>  proxy_set_header X-Forwarded-Host       $best_http_host;<br>  proxy_set_header X-Forwarded-Port       $pass_port;<br>  proxy_set_header X-Forwarded-Proto      $pass_access_scheme;<br>  <br>  proxy_set_header X-Scheme               $pass_access_scheme;<br>  <br>  # Pass the original X-Forwarded-For<br>  proxy_set_header X-Original-Forwarded-For $http_x_forwarded_for;<br>  <br>  # mitigate HTTPoxy Vulnerability<br>  # https://www.nginx.com/blog/mitigating-the-httpoxy-vulnerability-with-nginx/<br>  proxy_set_header Proxy                  &quot;&quot;;<br>  <br>  # Custom headers to proxied server<br>  <br>  proxy_connect_timeout                   5s;<br>  proxy_send_timeout                      300s;<br>  proxy_read_timeout                      300s;<br>  <br>  proxy_buffering                         off;<br>  proxy_buffer_size                       4k;<br>  proxy_buffers                           4 4k;<br>  <br>  proxy_max_temp_file_size                1024m;<br>  <br>  proxy_request_buffering                 on;<br>  proxy_http_version                      1.1;<br>  <br>  proxy_cookie_domain                     off;<br>  proxy_cookie_path                       off;<br>  <br>  # In case of errors try the next upstream server before returning an error<br>  proxy_next_upstream                     error timeout;<br>  proxy_next_upstream_timeout             0;<br>  proxy_next_upstream_tries               3;<br>  <br>  proxy_set_header X-Forwarded-Server $host;<br>  <br>  proxy_pass https://upstream_balancer;<br>  <br>  proxy_redirect                          off;<br>  <br> }</pre><p>Here you can see that the host in the ingress yaml has turned in to a server in nginx.conf. Path has converted into a location and namespace port and service name is defined under the location in the nginx conf file.</p><h3>Request processing inside the Nginx controller</h3><p>Lets assume now our hello application is hosted fronting the nginx controller with above configuration. And some one made a request as below</p><pre>curl -k -v https://demo.com/</pre><p>Here the nginx controller seeks assistance from nginx conf file to process this request. Since the host is demo.com controller directs the request to the server defined as demo.com. Then since the path is / , then the location / is mapped for the request.</p><p>So all the configuration related to the mapped server and location will be applied to the request. Then the request will be passed to proxy_pass block. The proxy pass block calls the <strong>upstream_balancer</strong>.</p><pre> upstream upstream_balancer {<br>  <br>  server 0.0.0.1; # placeholder<br>  <br>  balancer_by_lua_block {<br>   balancer.balance()<br>  }<br>  <br>  keepalive 320;<br>  <br>  keepalive_timeout  60s;<br>  keepalive_requests 10000;<br>  <br> }</pre><p>Upstream balancer method is as above. It will call the <strong>balancer.balance(). </strong>This will invoke the <strong>function get_balancer() </strong>in the balancer.lua file [1] This will return a balancer object.</p><pre>local function get_balancer()<br>  if ngx.ctx.balancer then<br>    return ngx.ctx.balancer<br>  end<br><br>  local backend_name = ngx.var.proxy_upstream_name<br>  ngx.log(ngx.STDERR, &quot;####################### backend name &quot; .. backend_name)<br><br>  local balancer = balancers[backend_name]<br>  ngx.log(ngx.STDERR, &quot;####################### balancer &quot; .. balancer.name)<br>  if not balancer then<br>    return nil<br>  end<br><br>  if route_to_alternative_balancer(balancer) then<br>    local alternative_backend_name = balancer.alternative_backends[1]<br>    ngx.var.proxy_alternative_upstream_name = alternative_backend_name<br><br>    balancer = balancers[alternative_backend_name]<br>  end<br><br>  ngx.ctx.balancer = balancer<br>  ngx.log(ngx.STDERR, &quot;####################### balancer2 &quot; .. balancer.name)<br>  return balancer<br>end</pre><p>Here the balancer object get assigned based on the upstream name defined in the nginx.conf. This lua balancer calls the nginx balancer which is responsible for the rest of the routing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*IBnV7lC9ja_Ya__YvySkWQ.jpeg" /><figcaption>Class Diagram for Balancer</figcaption></figure><p>It would be easier to explain the balancer implementation in a object oriented manner. Each balancer method has a constructor and a balance method.</p><p>There are separate implementations for balance method in Sticky balancer and Round robin balancer. Those implementations extends the Balancer. In this blog we will be focusing on the sticky implantation since the round robin is discussed in the earlier <a href="https://medium.com/r?url=https%3A%2F%2Fbuddhimau.medium.com%2Faffinity-in-nginx-ingress-controller-1-247e733229c5">blog</a> which is obvious.</p><p>The sticky balancer object has the implementation for the balancer method. Let’s see what balancer method does.</p><p><strong>From here onwards its a very interesting part hope you will enjoy !</strong></p><pre>function _M.balance(self)<br>  local upstream_from_cookie<br><br>  local key = self:get_cookie()<br>  if key then<br>    upstream_from_cookie = self.instance:find(key)<br>  end<br><br>  local last_failure = self.get_last_failure()<br>  local should_pick_new_upstream = last_failure ~= nil and<br>    self.cookie_session_affinity.change_on_failure or upstream_from_cookie == nil<br><br>  if not should_pick_new_upstream then<br>    return upstream_from_cookie<br>  end<br><br>  local new_upstream<br>  new_upstream, key = self:pick_new_upstream(get_failed_upstreams())<br>  if not new_upstream then<br>    ngx.log(ngx.WARN, string.format(&quot;failed to get new upstream; using upstream %s&quot;, new_upstream))<br>  elseif should_set_cookie(self) then<br>    self:set_cookie(key)<br>  end<br><br>  return new_upstream<br>end</pre><p>Basically what it does it picking and returning a new upstream. Now if you have read the earlier <a href="https://buddhimau.medium.com/affinity-in-nginx-ingress-controller-1-247e733229c5">blog</a>, I have explained that the Nginx controller keeps the pod ip addresses as upstreams. So basically what this balancer does is picking that ip address based on the stickiness.</p><p>If there is a failure in an upstream the balancer will pick a new upstream. As described in previous blog we have defined the stickiness based on the cookie. This cookie has a key. Example is there in the previous <a href="https://buddhimau.medium.com/affinity-in-nginx-ingress-controller-1-247e733229c5">blog</a>.</p><p>Nginx Controller maintains a map between upstream ip and this cookie key.</p><p>Lets go step by step now</p><ol><li>First balancer check whether a key (cookie) is available.</li><li>If available it will check against the map and will get the upstream ip.</li><li>If that upstream has a failure recorded earlier, which means if the pod is killed for some reason then it decides to pick the new upstream.</li><li>When picking the new upstream it generates a new key and cookie.</li><li>Then the new upstream will be added against the key replacing the earlier value.</li></ol><p>So this is basically how the Nginx controller maintain the session affinity in a Kubernetes platform based on a affinity cookie.</p><p>For me I had to go through all this code to identify because I tried to customize this code for a partitioning requirement. I don’t think there are any other resources that describes this flow in this detailed level. Hope you guys enjoyed it as well !</p><p>[1]. <a href="https://github.com/kubernetes/ingress-nginx/blob/main/rootfs/etc/nginx/lua/balancer.lua#L273">https://github.com/kubernetes/ingress-nginx/blob/main/rootfs/etc/nginx/lua/balancer.lua#L273</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c8b28c83604" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Affinity In Nginx Ingress Controller-1]]></title>
            <link>https://buddhimau.medium.com/affinity-in-nginx-ingress-controller-1-247e733229c5?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/247e733229c5</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[session-affinity]]></category>
            <category><![CDATA[nginx-ingress]]></category>
            <category><![CDATA[nginx-ingress-controller]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sun, 13 Nov 2022 18:11:48 GMT</pubDate>
            <atom:updated>2022-11-13T18:21:51.302Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*8dhuJsPJ4YT0frfQ" /></figure><h3>What is session affinity</h3><p>Let’s assume you have a stateful application that you have deployed in some container orchestration environment, let’s say Kubernetes. These kinds of applications direct traffic from a client to the same pod. This is usually important when a client makes the first request to the server, a session object is created. This object may be stored in server RAM, a file on the server, passed back to the client in an HTTP cookie, stored in a database, or stored in the client. All subsequent requests use the same session object. When you store the session object in a single server’s RAM or file system, then the only way for the client to continue a session in the next request is for the browser to return to the same server instance.</p><h3>How K8s Handle Routing Traffic Without Session Affinity</h3><p>As explained in their official documentation[1] Kubernetes uses iptables to distribute traffic across a set of pods. To explain this simply I will use an example. Let’s say there is an application pod named demo-app. And there are two replicas of this demo-app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/0*1LtSg2kvGW6ocyrG" /></figure><p>For these two replicas Kubernetes assigns two real ip addresses as 10.100.1.164, 10.100.1.165. For these two pods we create a service pointing to both of these pods. When creating this service Kubernetes creates a virtual Cluster IP address for this service. Which is 172.20.86.5.</p><blockquote><strong>$ kubectl get service foo</strong></blockquote><blockquote><strong>NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE</strong></blockquote><blockquote><strong>foo ClusterIP 172.20.86.5 &lt;none&gt; 443:30937/TCP 12m</strong></blockquote><p>This IP address will be used in the map in Nginx Ingress Controller. When a request is made to a host and a path Ingress controller maps the request to a service. Controllers maintain a map for cluster ip and service name.</p><p>When the request is routed to the service level the Kubernetes documentation says the load balancing method by default is round robin, but this is not entirely accurate. If you look at iptables on any of the worker nodes, you can see that for the service demo app with ClusterIP of 172.20.86.5 and 2 pods.</p><p>The service uses statistical mode random probability to randomly send traffic to one of the two pods defined here; <strong>each pod has a 50% chance of being chosen to receive traffic.</strong></p><h3>How do we configure session affinity in Kubernetes</h3><p>We can use an ingress template as below to configure session affinity. Here we define a cookie that is used from nginx controller for handling session affinity.</p><pre>apiVersion: networking.k8s.io/v1</pre><pre>kind: Ingress</pre><pre>metadata:</pre><pre>  name: demo-ing</pre><pre>  annotations:</pre><pre>   kubernetes.io/ingress.class: nginx</pre><pre>   nginx.ingress.kubernetes.io/affinity: &quot;cookie&quot;</pre><pre>   nginx.ingress.kubernetes.io/session-cookie-name: &quot;afc&quot;</pre><pre>spec:</pre><pre> rules:</pre><pre>  - host: demo.com</pre><pre>    http:</pre><pre>      paths:</pre><pre>      - path: /</pre><pre>        backend:</pre><pre>          serviceName: demo-app</pre><pre>          servicePort: 80</pre><p>How this cookie is handling the session affinity. After this is configured the deployment changes as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*Kcm3SwVOHIjeF_o3M9ZqQA.jpeg" /></figure><p>Here as you can see ingress controller maintain a continuous session with one application pod.</p><h3>Life Cycle of a Session Cookie</h3><p>The session cookie gets created in the nginx ingress controller. The process get triggered when a requests hits the controller. The expiration time of this cookie can be configured from the ingress annotations. [1]</p><blockquote><strong>nginx.ingress.kubernetes.io/session-cookie-max-age</strong></blockquote><p>The browser may store the cookie and send it back to the same server with later requests.</p><p>Session cookies are deleted when the current session ends. The browser defines when the “current session” ends, and some browsers use session restoring when restarting. This can cause session cookies to last indefinitely. [3]</p><h3>Format of the Session Cookie</h3><p>Format of the session cookie is defined in [2],</p><blockquote><strong>ngx.now() + i, ngx.worker.pid(), math_random(999999)</strong></blockquote><ul><li><strong>ngx.now()</strong> — Time stamp</li><li><strong><em>i- </em></strong>Iterative value from 1 to 20</li><li><strong>ngx.worker.pid() — </strong>Process ID of the nginx worker</li></ul><p>Example for this is as follows <strong>1668359498.145.369</strong></p><p>So this blog basically explained what is session affinity, why we need session affinity, how to configure session affinity ,and the basic details about the approach that used by nginx ingress controller.</p><p>There is a more interesting story on how this cookie is used internally in nginx ingress controller to identify the upstream. This involves going through the lua scripts in the nginx controller. That will be discussed in the part two of this blog.</p><p>[1]. <a href="https://kubernetes.github.io/ingress-nginx/examples/affinity/cookie/">https://kubernetes.github.io/ingress-nginx/examples/affinity/cookie/</a></p><p>[2]. <a href="https://github.com/kubernetes/ingress-nginx/blob/main/rootfs/etc/nginx/lua/balancer/sticky_balanced.lua#L42">https://github.com/kubernetes/ingress-nginx/blob/main/rootfs/etc/nginx/lua/balancer/sticky_balanced.lua#L42</a></p><p>[3] <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#:~:text=The%20lifetime%20of%20a%20cookie,session%20cookies%20to%20last%20indefinitely">https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#:~:text=The%20lifetime%20of%20a%20cookie,session%20cookies%20to%20last%20indefinitely</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=247e733229c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GDPR Checklist for a IDAAS Solution — Part 2]]></title>
            <link>https://buddhimau.medium.com/gdpr-checklist-for-a-idaas-solution-part-2-aeeba418b7d2?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/aeeba418b7d2</guid>
            <category><![CDATA[idaas]]></category>
            <category><![CDATA[gdpr-compliance]]></category>
            <category><![CDATA[gdpr]]></category>
            <category><![CDATA[identity-management]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sat, 22 Oct 2022 15:59:17 GMT</pubDate>
            <atom:updated>2022-10-22T15:59:17.389Z</atom:updated>
            <content:encoded><![CDATA[<h3>GDPR Checklist for a IDAAS Solution — Part 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*m3fsHS6oMUlFky12.jpg" /></figure><p>In the earlier <a href="https://buddhimau.medium.com/gdpr-checklist-for-a-idaas-solution-part-1-1c10688937c6">blog</a> we got a good understanding about GDPR, PIIs and why IDaaS solutions needs to worry about that. Here we will discuss on the checklist that a IDaaS solution needs to complete in order to be GDPR compliant.</p><p>Here I have categorised these requirements in to three parts</p><h3>Organisational Requirements</h3><ol><li>DPO (Data protection officer)</li></ol><p>As per GDPR documentation you need to appoint a DPO for your organisation if your organisation satisfies below 3 concerns.</p><ul><li><strong>You regularly or systematically monitor individuals or process special categories of data</strong></li></ul><p>Usually this kind of monitoring is happening in search engines, kind of applications to send promotional messages suggesting services or products. In IDaaS solutions this doesn’t happen usually. But there can be cases such that these solutions monitor users behavior to identify how much time that the user remains on the platform. What are the features that they use more often, Based on these information IDaaS solutions create promotional emails and improve user experience.</p><ul><li><strong>This processing is a core business activity</strong></li></ul><p>Without processing this data IDaaS solution cannot make a decision on the authenticity of an user. Hence yes it is a part of core business activity</p><ul><li><strong>You process data on a large scale</strong></li></ul><p>The term large scale processing is further described in [2]. To be defined as a large-scale processing there is a threshold that needs to be exceeded. In the IDaaS case this is information of 50000 people. If your IDaaS solution caters more than 50000 users you need a DPO.</p><p>According to the documentation [3] The primary task of a DPO is making sure the IDaaS solution stakeholders and its users know about data protection rights, obligations and responsibilities and raise awareness about them. Also DPO is responsible of handling queries and complaints from users.</p><p>2. Privacy Policy</p><p>Provide a privacy policy that clearly states the following</p><ul><li>How you collect personal data</li><li>Why you collect personal data</li><li>What you are using the personal data for</li><li>How long you will keep the personal data</li><li>Which rights the user has</li></ul><h3>Data Related Requirements</h3><h4>Data Residency</h4><p>When it comes to PII data the European commission clearly states that personal data should reside in a country that has adequate level of protection. They have announced a set of non EU countries with such protection [4]</p><p>The European Commission has so far recognised Andorra, Argentina, Canada (commercial organisations), Faroe Islands, Guernsey, Israel, Isle of Man, Japan, Jersey, New Zealand, Republic of Korea, Switzerland , the United Kingdom under the GDPR and the LED, and Uruguay as providing adequate protection.</p><h4>Data processing agreements with third parties</h4><p>Under the GDPR, a DPA document is mandatory whenever a person or organization gives personal data to a third-party service provider for a collaborative service. Any parties that act as data processors must sign DPAs with the data controllers.</p><p>These data processing entities may include , Email Service Providers, SMS service providers, billing services and support services</p><h4>Maintain Update Download Personal data</h4><p>When it comes to an IDaaS solution there can be several types of personal data.Lets assume there is a company named Ceytan. Ceytan has employees and customers in the EU region. Ceytan needs to manage its customer and employee identity and access management using an IDaaS solution.</p><p>Ceytan technical manager picks a IDaaS solution and creates an account in that and gets access to dashboards.</p><p>Then the personal data of Ceytan can be categorized into 3 parts.</p><ol><li>Personal data of Ceytan technical manager</li><li>Personal data of Ceytan employees</li><li>Personal data of Ceytan customers</li></ol><p>Each of these users has a right to view their personal data, edit your personal data and download them as a digital format.</p><h4>Request to delete personal data</h4><p>In the earlier topic we discussed the types of personal data that needs to be handled from an IDaaS solution. There can be situations where any of these customers want to remove all their digital traces. In such cases the user has the right to request for user deletion. In this case all the PIIs related to this user such as emails, credit card details, IP addresses, addresses, names, everything needs to be deleted from databases and logs, even backups.</p><h3>Cookie Requirements</h3><p>As per the GDPR[5] documentation they have categorized cookies based on purpose, duration and provenance.</p><p>For our use case the most important categorization is the categorization based on purpose. They have identified cookies that need to use the features of your IDaaS service as strictly necessary cookies without which the site would not work. This type of cookie does not collect any personally identifiable information about you and does not track your browsing habits.</p><p>In the IDaaS context affinity cookies, session cookies can be categorized to this category. Apart from these cookies all other cookies needs to be well documented with their purpose, with data they collect. Customer consent should be acquired for all cookies except strictly necessary cookies.</p><p>Even though customers selected not to provide consent for some of the cookies they should still be able to use the service with some limited functionality. This consent needs to be stored in the IDaaS solution for future use.</p><p>There should be a mechanism provided to withdraw the consent as easy as providing the consent.</p><h3>Conclusion</h3><p>Above are basically the requirements that you needs to satisfy if you need your IDaaS solution to cater EU regional customers.</p><h3>References</h3><ol><li><a href="https://www.forbes.com/sites/andrewrossow/2018/05/25/the-birth-of-gdpr-what-is-it-and-what-you-need-to-know/?sh=23e07a8355e5">https://www.forbes.com/sites/andrewrossow/2018/05/25/the-birth-of-gdpr-what-is-it-and-what-you-need-to-know/?sh=23e07a8355e5</a></li><li><a href="https://iapp.org/news/a/on-large-scale-data-processing-and-gdpr-compliance/">https://iapp.org/news/a/on-large-scale-data-processing-and-gdpr-compliance/</a></li><li><a href="https://edps.europa.eu/data-protection/data-protection/reference-library/data-protection-officer-dpo_en">https://edps.europa.eu/data-protection/data-protection/reference-library/data-protection-officer-dpo_en</a></li><li><a href="https://ec.europa.eu/info/law/law-topic/data-protection/international-dimension-data-protection/adequacy-decisions_en">https://ec.europa.eu/info/law/law-topic/data-protection/international-dimension-data-protection/adequacy-decisions_en</a></li><li><a href="https://gdpr.eu/cookies/">https://gdpr.eu/cookies/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aeeba418b7d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GDPR Checklist for a IDaaS Solution — Part 1]]></title>
            <link>https://buddhimau.medium.com/gdpr-checklist-for-a-idaas-solution-part-1-1c10688937c6?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c10688937c6</guid>
            <category><![CDATA[gdpr-compliance]]></category>
            <category><![CDATA[gdpr]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[european-union]]></category>
            <category><![CDATA[idaas]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sat, 22 Oct 2022 15:57:35 GMT</pubDate>
            <atom:updated>2022-10-22T15:59:56.130Z</atom:updated>
            <content:encoded><![CDATA[<h3>GDPR Checklist for a IDaaS Solution — Part 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cJ7H2682iGrtYqFe" /></figure><h3>Introduction</h3><p>Recently I have been researching GDPR and how it matters to IDaaS applications. IDaaS, is an SAAS model that allows users to connect to and use identity management services from the cloud. Using IDaaS for applications has created a win-win situation for businesses and end customers.</p><p>In modern IDaaS solutions there are so many features that are focused on making the life easy for the end customer. On the other hand businesses do not need to worry about security and infrastructure of their Identity data. They can simply hand that burden over to a IDaaS solution</p><h3>What is GDPR compliance</h3><p>The General Data Protection Regulation (“GDPR”) is a legal framework that requires businesses to protect the personal data and privacy of European Union (EU) citizens for transactions that occur within EU member states. It covers all companies that deal with the data of EU citizens, specifically banks, insurance companies, and other financial companies.[1]</p><p>GDPR legislation applies to you even if you are handling European customer data regardless of your business location. Due to this if you are running a business and if you are into the European market then you will definitely come across the term GDPR.</p><h3>Why GDPR matters to a IDaaS Solution</h3><p>IDaaS solutions provide identity and access management as a service. These platforms perform basically three tasks: identify, authenticate, and authorize. To perform this kind of task the system needs some information from the user. Based on that information, IDaaS solutions are capable of making a decision whether this is the right person that has the right access to this resource.</p><p>The information that the service needs to make this decision can be categorised into three parts.</p><ul><li>What you know</li><li>What you has</li><li>What you are</li></ul><p>What you know usually refers to usernames and passwords. What you have might be a ID or a Passport more of a physical evidence unlike usernames and passwords. What you are referring to is biometrics such as fingerprints, face IDs and stuff.</p><p>IDaaS solutions need to process this information to provide an output related to the authenticity of the user. As I described earlier the GDPR is very concerned about personal data that can identify an individual uniquely among others. Which is the very definition of the data used in the IDaaS solution.</p><p>Hence If you are developing an IDaaS solution you will be the most affected by GDPR legislation.</p><h3>What are the PIIs</h3><p>PIIs if not Personally identifiable information is any data that could potentially identify a specific person uniquely. They can be a name, ID number, Telephone number, fingerprint, email address.</p><p>Also there can be situations where non PIIs can also become PIIs when additional information is provided.</p><p>Also there can be sensitive and non sensitive PII data. Although insensitive PIIIs such as Name address can be found through some public records, leaking sensitive PII data such as credit card numbers and biometrics should be treated as a data breach.</p><p>So we are now in a position where we have a basic idea of what GDPR is and why an IDaaS service. In the <a href="https://buddhimau.medium.com/gdpr-checklist-for-a-idaas-solution-part-2-aeeba418b7d2">next section</a> we will be analysing the requirements that need to achieve GDPR compliance for IDaaS service.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c10688937c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to add authentication to a React app using Asgardeo Auth React SDK]]></title>
            <link>https://buddhimau.medium.com/how-to-add-authentication-to-a-react-app-using-asgardeo-auth-react-sdk-5ada164b2be6?source=rss-2e9e9001e4fe------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ada164b2be6</guid>
            <category><![CDATA[oidc]]></category>
            <category><![CDATA[asgardeo]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[idaas]]></category>
            <dc:creator><![CDATA[Buddhima Udaranga]]></dc:creator>
            <pubDate>Sun, 28 Nov 2021 18:38:16 GMT</pubDate>
            <atom:updated>2021-11-28T18:38:16.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*onIZ26CCictPF16jdZdsgg.png" /></figure><p>The focus of this tutorial is to help developers learn how to secure a React application by implementing user authentication using Asgardeo.</p><p>This guide uses the Asgardeo React SDK to secure React applications, which provides React developers with an easier way to add user authentication to React applications. You can now secure your React applications using security best practices while writing less code.</p><p>In this blog, I’ll walk you through the steps to build a React application then we will use Asgardeo SDK to integrate this application with Asgardeo.</p><h3>1. Generate a React application</h3><p>Before you start, you need to have installed Node on your system. Install npm and node in your local environment if you don’t have them already.</p><p>It can be installed by visiting <a href="https://nodejs.org/en/download/">here</a>.</p><p>Check your installation using the following command</p><blockquote><strong>node -v</strong></blockquote><p>If the node is successfully installed then the above command will display the version. Then we need to install yarn using the following commands.</p><blockquote><strong>npm i -g yarn</strong></blockquote><p>If yarn is successfully installed then the below command will display the version.</p><blockquote><strong>yarn -v</strong></blockquote><p>Create a bootstrap typescript react application using the following command.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6390e1547a6ae9d98d6bf81d58b1968c/href">https://medium.com/media/6390e1547a6ae9d98d6bf81d58b1968c/href</a></iframe><p>This command can take some time</p><p>Go inside the created sample directory</p><blockquote><strong>cd asgardeo-react-sample</strong></blockquote><p>Start the app using the following command</p><blockquote><strong>yarn start</strong></blockquote><p>Navigate to <a href="http://localhost:3000/">http://localhost:3000</a> and you should see our app in all its starter glory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*78sta-u65_ngW-jW" /></figure><h3>2. Create a app in Asgardeo</h3><p>Register in Asgardeo using ​​<a href="https://asgardeo.io/signup">https://asgardeo.io/signup</a>.</p><p>After the signup, you will be redirected to <a href="https://console.asgardeo.io/">https://console.asgardeo.io/</a></p><p>Then go to Develop -&gt; Applications</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D573d6PW_dTQPghL" /></figure><p>Click on New Application -&gt; Single Page Application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TpFdbDzkPmGqhvnT" /></figure><p>Click on Register. You can find more details about this by referring to <a href="https://wso2.com/asgardeo/docs/guides/applications/register-single-page-app/#register-the-app">Asgardeo official documentation</a>.</p><h3>3. Edit Code</h3><blockquote>cd asgardeo-react-sample</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29a0db5d3f264913d7bb35f9ff2b5691/href">https://medium.com/media/29a0db5d3f264913d7bb35f9ff2b5691/href</a></iframe><p>Asgardeo even provides code snippets that can be used to integrate your app with Asgardeo.</p><p>Login to <a href="https://console.asgardeo.io/">https://console.asgardeo.io/</a> and then navigate to the applications page. Click on the pencil icon in front of your application.</p><p>Select the Quick Start tab and Select React.</p><p>Select Integrate your application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1hWplPPr-YZfo68e" /></figure><p>Since we have already installed the Asgardeo SDK. Copy the code snippet on Step 2 on Integrate your application page.</p><p>Go to the code of the React Bootstrap application we created in the above step 2 on this blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7gk1YJssWqF9CI8d" /></figure><p>Replace the content in index.tsx file using the copied code snippet from Asgardeo Console.</p><p>Here you can see a part saying</p><blockquote>{ /* Rest of your application. */ }</blockquote><p>This comment should be replaced with your application. To create your application page go to App.tsx</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2254697d8b21ab26ee44d8cac9f87943/href">https://medium.com/media/2254697d8b21ab26ee44d8cac9f87943/href</a></iframe><p>Replace the code of App.tsx from the above code. This simply has a login and logout button that handles login and logout through Asgardeo. If the Authentication is Successful I have used the Asgardeo React SDK to get the user information and id token. Created a separate component authentication-response.tsx to handle that response.</p><p>Create a component folder in the src folder. Create the authentication-response.tsx file in the component folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88501997b6705a40143fc7454074755b/href">https://medium.com/media/88501997b6705a40143fc7454074755b/href</a></iframe><p>Also, create an index.tsx file in the same components directory to export authentication response handling component. Add the following code to that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca2e12698994bfd5bd7e00e1e01bb398/href">https://medium.com/media/ca2e12698994bfd5bd7e00e1e01bb398/href</a></iframe><p>Now your application part is ready. now you can replace the</p><blockquote>{ /* Rest of your application. */ }</blockquote><p>Comment in the index.tsx file using the following</p><blockquote>&lt;App /&gt;</blockquote><h3>4. Try Out</h3><p>Now your application is ready. You need a customer user in your Asgardeo application to try this. You can go to Manage -&gt; Users -&gt; New User</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bMCPQJvb6TRvFS8D" /></figure><p>Start your react application using the following command</p><blockquote>npm start</blockquote><p>Navigate to <a href="http://localhost:3000/"><strong>http://localhost:3000</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*-S2j4IQIypD4c_Xx.gif" /></figure><p>You can find the full code of the react application in <a href="https://github.com/Buddhimah/asgardeo-react-sample"><strong>https://github.com/Buddhimah/asgardeo-react-sample</strong></a></p><p>You need to change the client id and the tenant domain.[3] That&#39;s it then you can start the application and log in as above.</p><ol><li><a href="https://typeofnan.dev/your-first-react-typescript-project-todo-app/"><strong>https://typeofnan.dev/your-first-react-typescript-project-todo-app/</strong></a></li><li><a href="https://wso2.com/asgardeo/docs/get-started/try-your-own-app/react/#configure-authprovider"><strong>https://wso2.com/asgardeo/docs/get-started/try-your-own-app/react/</strong></a></li><li><a href="https://github.com/Buddhimah/asgardeo-react-sample/blob/main/src/index.tsx#L15"><strong>https://github.com/Buddhimah/asgardeo-react-sample/blob/main/src/index.tsx#L15</strong></a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ada164b2be6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>