<?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 Gaveen Buddhika on Medium]]></title>
        <description><![CDATA[Stories by Gaveen Buddhika on Medium]]></description>
        <link>https://medium.com/@buddhikagaveen2021?source=rss-ec1e56dce3f1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JI-6F_hgGfofUPyp4X-Srw.png</url>
            <title>Stories by Gaveen Buddhika on Medium</title>
            <link>https://medium.com/@buddhikagaveen2021?source=rss-ec1e56dce3f1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 17:23:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@buddhikagaveen2021/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[How to Send a Custom Alerting Message to Mobile When Cloudwatch Alarm Triggers]]></title>
            <link>https://medium.com/@buddhikagaveen2021/how-to-send-a-custom-alerting-message-to-mobile-when-cloudwatch-alarm-triggers-86243fd886b1?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/86243fd886b1</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Thu, 23 Apr 2026 08:13:02 GMT</pubDate>
            <atom:updated>2026-04-24T09:53:05.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gBIyTCTKVhgGu_mz5M92zg.png" /></figure><h3>Overview</h3><p>AWS CloudWatch can monitor any infrastructure metric and trigger an alarm when it exceeds a certain threshold. But the default alarm notification is a raw JSON payload that is difficult to read on a phone screen when something goes wrong.</p><p>This guide shows you how to build a fully serverless alerting pipeline using three AWS services: CloudWatch sees the breach, SNS sends the alert, and Lambda changes the raw data into a clean, structured SMS message that goes straight to the on-call engineers.</p><h3>Proposed Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*5fdLCPR0ip54WTNJi6JrwA.png" /></figure><h3>Why use SNS to invoke Lambda instead of a direct CloudWatch trigger?</h3><p>You can set up CloudWatch alarms to directly trigger a Lambda function. Using an SNS topic as the middleman is the best way to do things for several important reasons:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9710fdee38734bdacdb68e0576476d47/href">https://medium.com/media/9710fdee38734bdacdb68e0576476d47/href</a></iframe><p><strong><em>Best Practice<br></em></strong><em>Always use an SNS topic between CloudWatch and Lambda. If you later want to add a Slack channel, an email list, or a ticketing system, you simply add a new SNS subscription without touching the CloudWatch alarm configuration.</em></p><h3>Implementation Steps</h3><h4><strong>Create SNS Topic</strong></h4><ul><li>Go to AWS Console -&gt; SNS -&gt; Topics, and then Create Topic. Choose “Standard” instead of “FIFO” (CloudWatch doesn’t support FIFO). Give it a clear name.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qGNohL4k9ElIMHrMSVv6A.png" /></figure><h4><strong>Create and Deploy Lambda Function</strong></h4><p>Create the function in AWS Console -&gt; Lambda -&gt; Create function.<br>Runtime: Python 3.12.</p><p>When creating a Lambda function, AWS automatically creates a role with an <strong>AWSLambdaBasicExecutionRole policy</strong>. After that, you need to attach <strong>AmazonSNSFullAccess policy</strong> to that role by navigating to the IAM role in Lambda configurations, the permissions section.<br><em>(If not, you can create a role with above policies before the Lambda creation and attach it when creating Lambda.)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ws3MQGuZDIEICBWNTfF9ww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CqsZttQqj2d_bm9yBOaM3Q.png" /></figure><p>Then include our main function in code section</p><pre>import boto3<br>import json<br>import re<br><br>sns = boto3.client(&#39;sns&#39;, region_name=&#39;&lt;your-region&gt;&#39;)<br><br># Add all numbers here<br>PHONE_NUMBERS = [<br>    &#39;+9412345666&#39;,<br>    &#39;+9478111663&#39; <br>]<br><br># Extract numeric metric value from CloudWatch alarm reason<br># Example: &quot;Threshold Crossed: 1 datapoint [92.0 (..)]&quot;<br># Returns: 92<br>def get_metric_value(reason):<br>    match = re.search(r&#39;\[(\d+\.?\d*)\s&#39;, reason)<br>    if match:<br>        return round(float(match.group(1)))<br>    return None<br><br># Clean and extract server name from alarm name<br># Removes generic words like &#39;cpu&#39;, &#39;alarm&#39;, &#39;high&#39;<br># Example: &quot;prod-server-1-cpu-high&quot; → &quot;prod server 1&quot;<br>def get_server_name(alarm_name):<br>    remove_words = [&#39;high&#39;, &#39;alarm&#39;, &#39;alert&#39;, &#39;usage&#39;, &#39;cpu&#39;, &#39;disk&#39;, &#39;memory&#39;, &#39;threshold&#39;, &#39;warning&#39;, &#39;critical&#39;]<br>    parts = alarm_name.replace(&#39;-&#39;, &#39; &#39;).replace(&#39;_&#39;, &#39; &#39;).split()<br>    filtered = [p for p in parts if p.lower() not in remove_words]<br>    return &#39; &#39;.join(filtered)<br><br># Identify alert type based on keywords in alarm name<br># Example: &quot;cpu-high-alarm&quot; → &quot;CPU&quot;<br>def get_alert_type(alarm_name):<br>    keywords = [&#39;cpu&#39;, &#39;disk&#39;]<br>    return next((kw.upper() for kw in keywords if kw in alarm_name.lower()), &#39;Resource&#39;)<br><br># Determine severity level from alarm name<br># Example: &quot;critical-cpu-alarm&quot; → &quot;CRITICAL&quot;<br>def get_severity(alarm_name):<br>    alarm_name_lower = alarm_name.lower()<br>    if &#39;critical&#39; in alarm_name_lower:<br>        return &#39;CRITICAL&#39;<br>    elif &#39;warning&#39; in alarm_name_lower:<br>        return &#39;WARNING&#39;<br>    else:<br>        return &#39;UNKNOWN&#39;<br><br># Send SMS using Amazon SNS<br># Takes phone number and formatted message<br>def send_sms(phone_number, message):<br>    sns.publish(<br>        PhoneNumber=phone_number,<br>        Message=message,<br>        MessageAttributes={<br>            &#39;AWS.SNS.SMS.SMSType&#39;: {<br>                &#39;DataType&#39;: &#39;String&#39;,<br>                &#39;StringValue&#39;: &#39;Transactional&#39;<br>            }<br>        }<br>    )<br><br>def lambda_handler(event, context):<br><br>    # Parse SNS message from CloudWatch Alarm<br>    message = json.loads(event[&#39;Records&#39;][0][&#39;Sns&#39;][&#39;Message&#39;])<br><br>    alarm_name = message[&#39;AlarmName&#39;]<br>    state      = message[&#39;NewStateValue&#39;]<br>    reason     = message[&#39;NewStateReason&#39;]<br><br>    # Use helper functions to extract structured data<br>    alert_type   = get_alert_type(alarm_name)<br>    severity     = get_severity(alarm_name)<br>    metric_value = get_metric_value(reason)<br>    server_name  = get_server_name(alarm_name)<br>    metric_str   = f&quot;{metric_value}%&quot; if metric_value else &quot;N/A&quot;<br><br>    # Build SMS message based on alarm state and severity<br>    if state == &#39;ALARM&#39;:<br>        if severity == &#39;CRITICAL&#39;:<br>            custom_msg = (<br>                  f&quot;CRITICAL! {alert_type} Usage Dangerous\n&quot;<br>                  f&quot;Server: {server_name}\n&quot;<br>                  f&quot;Alarm: {alarm_name}\n&quot;<br>                  f&quot;{alert_type} Usage: {metric_str}\n&quot;<br>            )<br>        elif severity == &#39;WARNING&#39;:<br>            if metric_value and metric_value &gt; 95:<br>                print(f&quot;Suppressed Warning - {alert_type} usage {metric_value}% exceeds Critical threshold&quot;)<br>                return {&#39;statusCode&#39;: 200}<br>            custom_msg = (<br>                f&quot;WARNING! {alert_type} Usage High\n&quot;<br>                f&quot;Server: {server_name}\n&quot;<br>                f&quot;Alarm: {alarm_name}\n&quot;<br>                f&quot;{alert_type} Usage: {metric_str}\n&quot;<br>            )<br>        else:<br>            custom_msg = (<br>                f&quot;ALERT! {alert_type} High\n&quot;<br>                f&quot;Server: {server_name}\n&quot;<br>                f&quot;Alarm: {alarm_name}\n&quot;<br>                f&quot;{alert_type} Usage: {metric_str}&quot;<br>            )<br>    elif state == &#39;OK&#39;:<br>        custom_msg = (<br>            f&quot;RESOLVED! {alert_type} Back to Normal\n&quot;<br>            f&quot;Server: {server_name}\n&quot;<br>            f&quot;Alarm: {alarm_name}\n&quot;<br>            f&quot;{alert_type} Usage: {metric_str}&quot;<br>        )<br>    else:<br>        custom_msg = f&quot;Alarm {alarm_name} ({alert_type}) state: {state}&quot;<br><br>    # Send SMS to all configured phone numbers<br>    for number in PHONE_NUMBERS:<br>        send_sms(number, custom_msg)<br>        print(f&quot;SMS sent to {number}: {custom_msg}&quot;)<br><br>    return {&#39;statusCode&#39;: 200}</pre><p><strong>Function overview</strong></p><p>When the function is called, it does the following:</p><ol><li>Reads the SNS event record and gets the raw CloudWatch alarm JSON from it.</li><li>Gets the alarm name, state (ALARM/OK), reason string, account ID, and StateChangeTime.</li><li>Gets the server name by taking out noise words like “cpu,” “disk,” “alarm,” “warning,” and “critical” from the alarm name.</li><li>Finds out what kind of alert it is (CPU or DISK) and how serious it is (CRITICAL or WARNING) from the name of the alarm.</li><li>Uses regex to get the metric value (like 85%) from the reason string.</li><li>Stops WARNING alerts when the metric goes over 95% because there will already be a CRITICAL alarm.</li><li>Makes the right message template based on the state and severity.</li><li>Sends the SMS to each phone number in PHONE_NUMBERS using SNS Direct Publish and the Transactional type.</li></ol><p><strong><em>You can change alarm names, thresholds, what needs to be included in your message, and the names you need to extract from the SNS record ,can also include instance ID and alarm time from the SNS record and other things because this template was created for CPU disk alarms with my own naming conventions; you can change it.</em></strong></p><p><strong>Message Templates</strong></p><pre># CRITICAL ALARM<br>CRITICAL! {alert_type} Usage Dangerous<br>Server: {server_name}<br>Instance ID: {instance_id}<br>{alert_type} Usage: {metric_value}%<br><br><br># WARNING ALARM<br>WARNING! {alert_type} Usage High<br>Server: {server_name}<br>Instance ID: {instance_id}<br>{alert_type} Usage: {metric_value}%</pre><h4>Subscribe Lambda Function in SNS Topic</h4><p>Go to the AWS console.<br>Choose SNS topic -&gt; Create subscription -&gt; Select AWS Lambda as a protocol, then select a function and create a subscription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avBcJQXtVdfFcj7gJFP_Nw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qYofqUvKbTeC5J8aPPDauA.png" /></figure><h4>Add SNS topic as CloudWatch Alarm Action</h4><p>Go to AWS console.<br>CloudWatch -&gt; Alarms -&gt; create alarm <br>Then select metrics and add necessary conditions after moving to the next page, and under the &quot;Configure Actions&quot; section, add our SNS topic and move to the last page and add alarm details, preview, and create the alarm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bB-YKOMPiTNff8KHX1MY3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5XJPob9cCM8tviyeFCW-AA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aK9GaiWVHi3YmGHp82Puaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbB70WgSuSe58HG5BTb_Bw.png" /></figure><p>You can add this topic to pre-created alarms by moving to the actions section and selecting edit in the alarm dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ibP_te0JVwvgLJjPxTC0DQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N3IQBJfULDXRDR8Fdl8Vww.png" /></figure><h4>Test Lambda Function</h4><p>Go to the test section in the Lambda dashboard and create a test event using the following SNS record.</p><pre>{<br>  &quot;Records&quot;: [{<br>    &quot;Sns&quot;: {<br>      &quot;Message&quot;: &quot;{\&quot;AlarmName\&quot;:\&quot;Test-EC2-CPU-Critical-Alarm\&quot;,<br>        \&quot;NewStateValue\&quot;:\&quot;ALARM\&quot;,<br>        \&quot;NewStateReason\&quot;:\&quot;Threshold Crossed: 1 datapoint [92.0] was greater than threshold [90.0]\&quot;,<br>        \&quot;AWSAccountId\&quot;:\&quot;3335556615\&quot;,<br>        \&quot;Region\&quot;:\&quot;AP-Southeast-1\&quot;,<br>        \&quot;StateChangeTime\&quot;:\&quot;2026-04-06T10:00:00.000+0000\&quot;,<br>        \&quot;Trigger\&quot;:{\&quot;Dimensions\&quot;:[{\&quot;name\&quot;:\&quot;InstanceId\&quot;,\&quot;value\&quot;:\&quot;i-0d22fc44a1a3d484a\&quot;}]}}&quot;<br>    }<br>  }]<br>}</pre><p>After running this test event, you can get an alert message on your mobile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*073J5R45Ws5A4UZprG2X8A.jpeg" /></figure><h4>Monitoring and Logging</h4><p>There need to be two layers of logging: Use SNS Delivery Logs to confirm the carrier received the SMS and Lambda CloudWatch Logs to troubleshoot errors in function execution.</p><p><strong>Turn on SNS SMS Delivery Logs</strong><br>SNS delivery logs show whether the carrier accepted or rejected each SMS, how many segments were sent, the exact cost in USD, the name of the carrier, and the reason for the failure if delivery failed.</p><p><strong>Reading Logs for SNS Delivery</strong><br>The following important fields are in each log entry:</p><pre>{<br>  &quot;notification&quot;: {<br>    &quot;messageId&quot;: &quot;c78b605f-ddcd-58ed-93b4-021289523fa4&quot;,<br>    &quot;timestamp&quot;: &quot;2026-04-06 06:27:43.966&quot;<br>  },<br>  &quot;delivery&quot;: {<br>    &quot;destination&quot;: &quot;+94767552847&quot;,<br>    &quot;phoneCarrier&quot;: &quot;Dialog&quot;,<br>    &quot;numberOfMessageParts&quot;: 2,       // segments billed<br>    &quot;priceInUSD&quot;: 0.78632,           // actual cost<br>    &quot;smsType&quot;: &quot;Transactional&quot;,<br>    &quot;providerResponse&quot;: &quot;Message has been accepted by phone carrier&quot;<br>  },<br>  &quot;status&quot;: &quot;SUCCESS&quot;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1YZe5DgTuf6jiNcee9X7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-EQtaprOlLcFXmGVj0mR1w.png" /></figure><p><strong>CloudWatch Logs for Lambda</strong><br>Lambda automatically writes logs to CloudWatch when you attach the AWSLambdaBasicExecutionRole policy. Each time you call it, a log stream is created with:</p><ul><li>START / END / REPORT lines show how long the invocation lasted, how much memory it used, and how long it was billed for.</li><li>print() output: the function keeps track of each SMS sent, including the</li><li>phone number and message content.<br>Exception tracebacks: a full Python stack trace if the function fails.</li></ul><ol><li>Open the AWS Console, go to Lambda, select a Lambda function, and then click the Monitor tab.</li><li>Click “View CloudWatch Logs” to go straight to the log group.</li><li>To see the most recent invocation, click on the most recent log stream.</li><li>To find failures, look for lines that say “ERROR” or “Exception.”</li></ol><h3>Important Details</h3><h4>Getting access to SNS SMS production</h4><p>By default, new AWS accounts are put in the SNS SMS Sandbox. SMS can only be sent to verified destination phone numbers when in sandbox mode. You will need to request production access to send messages to any number without verification.</p><p><strong>Why do you need production access?</strong></p><ul><li>In sandbox mode, you have to manually verify each destination number with an OTP, which isn’t practical for changes to the on-call rotation.</li><li>New engineers who are added to the on-call list won’t get alerts until their number is confirmed.</li><li>This limit is lifted when you have production access; you can send SMS messages to any E.164 formatted number right away.</li></ul><p><strong>How to Ask for Production Access</strong></p><ol><li>Open the AWS Console, then go to SNS, then Text messaging (SMS), and then Text messaging preferences.</li><li>At the top of the page, click the button that says “Request production access.”</li><li>Use the support case form to provide details about your use case.</li><li>Send in the case. AWS will review it and respond back to you within 1 to 3 business days.</li><li>The sandbox restriction is lifted for your account in that area once it is approved.</li><li>for more details : <a href="https://docs.aws.amazon.com/sms-voice/latest/userguide/sandbox.html">https://docs.aws.amazon.com/sms-voice/latest/userguide/sandbox.html</a></li></ol><h4>Cost Management</h4><p><strong>Monthly Spending Limit</strong><br>There is a monthly limit on how much SMS you can send with AWS SNS. The default amount is $10.00, which is only enough for twenty messages to Sri Lanka. After access to production is granted, this must be raised by hand.</p><ul><li><strong>Click on SNS, then Text messaging (SMS), then Text messaging preferences, and then Edit.</strong></li><li>Choose the value you want for the monthly spending limit.</li><li>return: provider return: provider When the limit is reached, all SMS calls after that return: provider Response: There is no more quota for the account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GUifd_bNfHRwhfPxs8piZA.png" /></figure><h4>SNS SMS Pricing and Cost Optimization</h4><p>To keep costs down, it’s important to know how much SMS costs in Amazon SNS.<br>The cost is affected by two main things:</p><ul><li>Prices in the destination country</li><li>Number of parts in a message</li></ul><p><strong><em>I am going to use Sri Lanka as a destination as an example</em></strong></p><p><strong>SriLanka SMS Pricing<br></strong>In Sri Lanka, both transactional and promotional SMS messages cost $0.39316 per segment on all mobile networks. The cost of sending an SMS segment is the same no matter what kind of message it is.</p><p>This means that Sri Lanka is one of the most expensive places to send SMS through Amazon SNS.</p><p>With a $50 monthly budget, you can send about 127 message segments, for instance. This means that there can only be about 42 alert events before the spending limit is reached if each alert goes to three people.</p><p>Because this is so expensive, it’s very important to make sure that the message length and encoding are as short as possible to cut down on the number of SMS segments used.</p><p><strong>SMS Character Encodings</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fca68d1c60d2ce1bd89c929851c4b6d/href">https://medium.com/media/5fca68d1c60d2ce1bd89c929851c4b6d/href</a></iframe><p><strong>Multipart SMS Overhead<br></strong>When an SMS message exceeds the single-message character limit, it is split into multiple segments. Each segment is billed separately, which directly increases the total cost of delivery in Amazon SNS.</p><p><strong>GSM-7 Encoding</strong><br>For GSM-7 encoded messages:</p><ul><li>160 characters = 1 segment</li><li>161 characters = 2 segments</li><li>306 characters = 2 segments</li><li>307 characters = 3 segments</li></ul><p><strong>UCS-2 Encoding<br></strong>For UCS-2 encoded messages:</p><ul><li>70 characters = 1 segment</li><li>71 characters = 2 segments</li><li>134 characters = 2 segments</li><li>135 characters = 3 segments</li></ul><p>As the number of segments increases, the cost increases linearly because each segment is charged separately. This means a slightly longer message can instantly double or triple the cost.</p><p><strong>Best Practice<br></strong>When using GSM-7, keep messages short, less than 153 characters.</p><p>Why:</p><ul><li>Multipart messages lower the number of characters that can be used in each segment.</li><li>Dynamic values, like server names and metrics, may make things longer.</li><li>Last Suggestions</li><li>Only use characters that work with GSM-7</li><li>Stay away from emojis and text that isn’t in Latin.</li><li>Stay away from special characters that take up extra space.</li><li>Limit messages to 153 characters.</li><li>Keep an eye on usage to keep costs down.</li></ul><p>For more details: <br><a href="https://aws.amazon.com/sns/sms-pricing/">https://aws.amazon.com/sns/sms-pricing/</a><br><a href="https://docs.aws.amazon.com/sms-voice/latest/userguide/sms-limitations.html">https://docs.aws.amazon.com/sms-voice/latest/userguide/sms- limitations.html</a></p><p>I hope this provided a clear understanding of the concept. Thank you!</p><p>Feel free to share any corrections or suggestions in the comments section.<br>I welcome improvements.<br>For more content related to the DevOps world, please follow me.</p><p>Cheers, happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86243fd886b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Use AWS VPC Lattice for Better Service Networking]]></title>
            <link>https://medium.com/@buddhikagaveen2021/how-to-use-aws-vpc-lattice-for-better-service-networking-e0b14e3e9faa?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0b14e3e9faa</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 13:01:05 GMT</pubDate>
            <atom:updated>2026-01-08T03:07:27.576Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PJTzdUkXzRd7YlytN3raJw.png" /></figure><h4>As a beginner, looking at a complex AWS network diagram often feels like trying to read a map in a foreign language. You see VPCs, subnets, route tables, peering connections, and transit gateways. It’s a lot to take in when you just want to connect Service A to Service B.</h4><h4>CONCEPT</h4><p>To understand why VPC Lattice is a game-changer, imagine a corporate office building.</p><ul><li><strong>The Old Way (Peering):</strong> <br>You need to know exactly which floor, room number, and desk (IP Address) your colleague sits at. If they move, you are lost.</li><li><strong>The Lattice Way:</strong> <br>There is a receptionist (Lattice) at the front desk. You simply ask for “The Finance Team” (Service Name). The receptionist connects you, regardless of where they are sitting.</li></ul><h4>HOW LATTICE WORKS</h4><p>There are three main components in AWS Lattice.</p><ol><li><strong>Service Network</strong><br>Consider this as the “Club” or the “Virtual Network.” The services within this network can communicate with any VPC connected to it. Peering is not necessary; all you need is an association.</li><li><strong>Service</strong><br>This stands in for your real application. Even if the backend IPs change, it offers a fixed entry point (DNS name).</li><li><strong>Target Group</strong><br>Your actual workloads (IP addresses, Lambdas, or EC2 instances) reside here. Traffic from the service is routed to these targets via Lattice.</li></ol><h4>KEY FEATURES</h4><ul><li><strong>No IP Overlaps</strong><br>This is a major advantage. Lattice can route traffic between your two VPCs without encountering any conflicts, even if they share the same IP range (e.g. :10.0.0.0/16).</li><li><strong>Zero Trust Security </strong><br>You can manage who has access to your service by using AWS IAM policies. “Who has the permission?” is now more important than “Who has the IP?”</li><li><strong>Centralized Management </strong><br>Using AWS RAM, you can oversee connectivity for several AWS accounts from one location.</li></ul><p><strong><em>To understand how to simplify this, I decided to build a PoC demo. Let’s imagine a hypothetical online shop scenario called “Cake Arcade.”</em></strong></p><p>I chose to use EC2 instances to simulate a microservices architecture in order to illustrate this:</p><ul><li>The ordering interface is a frontend server in VPC A.</li><li>The Payment Service is a backend server located in VPC B.</li></ul><p>Using basic EC2 instances enables us to <strong>concentrate only on the networking logic offered by Lattice</strong>, whereas a real-world setup would use containers (ECS/EKS) or Lambda.</p><p><strong><em>VPC peering, route table updates, and intricate IP-based security groups would be required if I were to construct this the conventional way. It was brittle. “Do I really need to manage network plumbing just to make an API call?” was a question I kept asking myself. I made the decision to investigate AWS VPC Lattice as a solution.</em></strong></p><h4>ARCHITECTURE OVERVIEW</h4><p>The architecture I created for this demonstration is shown here. The intricate VPC peering is being eliminated in favor of a logical “service network.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*kisyWmhaDK5DqrxCxV9zBQ.png" /><figcaption>Here is how I set up this demonstration in my AWS environment without using Peering connection or TGW to establish the connection between two services.</figcaption></figure><h4><strong>STEP-BY-STEP GUIDE</strong></h4><p><strong>STEP 01: Infrastructure Setup<br></strong>The network topology must be created first.</p><p>Create two VPCs:</p><ol><li><strong>Frontend VPC:</strong> Create a VPC <strong>(Cake-Frontend-VPC, 10.1.0.0/16)</strong> with an Internet Gateway (IGW) and a public subnet.</li><li><strong>Backend VPC:</strong> Create a VPC with a private subnet <strong>(Cake-Backend-VPC, 10.2.0.0/16).</strong></li><li><strong>Set Up Outbound Communication :</strong><br><em>The backend VPC cannot directly access the internet to install packages because it is private.</em><br>Update the private route table to point 0.0.0.0/0 to the NAT gateway after creating a NAT gateway in the backend VPC (make sure it’s connected to a public subnet if you have a multi-subnet setup, or use a public NAT setup correctly).</li><li><strong>Launch the instances:</strong></li></ol><ul><li><strong>Frontend Instance: </strong>In the Frontend Public Subnet, launch an Amazon Linux 2023 instance. Make sure it has a public IP so you can use SSH or SSM to access it.</li><li><strong>Backend Instance:</strong> In the Backend Private Subnet, launch an Amazon Linux 2023 instance.</li><li><strong>User Data:</strong> To mimic a microservice, use the following User Data script for the backend instance:</li></ul><pre>#!/bin/bash<br>yum update -y<br>yum install -y httpd<br>systemctl start httpd<br>systemctl enable httpd<br>echo &quot;&lt;h1&gt;Lattice Lab Success!&lt;/h1&gt;&quot; &gt; /var/www/html/index.html</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6vQnGuWR48A9a2pkzJenNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnaxntZE27qqBuSL5rLpKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZKOXjt4ZpjrnF0MGaB9tQ.png" /></figure><p><strong>STEP 02: Creating the Target Group</strong></p><p>The next step is to tell the Lattice where to send the user traffic.</p><ul><li>Go to your VPC Lattice console. In the left corner, you’ll see TargetGroups.</li><li>Click on Create target group.</li><li>Choose Instances as the type of target instance.</li><li>You will then need to select your backend VPC and the backend EC2 instance, port 80.</li><li>Once created, check the “Health Status.” It should turn to Healthy (this confirms your NAT Gateway and User Data script worked correctly).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-cgxOQWId9CD-uj2GkOSMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mb3-PJLnhuYSpzdH-ZJZ_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sLctiibcScwwVZuYh0xuJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7ERAEyu-fKJoJ5awjHgAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQlKFinyROFEMKnfKgkqRw.png" /></figure><p><strong>STEP 03: Defining Service</strong></p><p>Next, specify where users will access your application.</p><ul><li>From the VPC Lattice page, select Services, then Create Service.</li><li>Name the service <strong>payment-service.</strong></li><li>CreateUnder Routing, <br>create a listener on port 80 that forwards traffic to the target group created in step 02.</li><li>Finally, note down the domain name created by Lattice (e.g. payment-service-xxxx.vpc-lattice…).</li></ul><p><strong>Zero Trust Tip: Enabling IAM Authentication During this step, you will see an option called Auth Type.</strong></p><ul><li><strong>NONE: </strong>This allows any VPC associated with the network to connect. It’s great for testing connectivity.</li><li><strong>AWS_IAM:</strong> This is where Zero Trust kicks in. If you select this, the frontend EC2 needs an IAM role with permission (vpc-lattice-svcs:Invoke) to talk to the backend. The request must also be cryptographically signed (SigV4).</li></ul><p><strong><em>Recommendation: For your first lab, keep it as </em></strong><strong><em>NONE to verify the network first. You can switch to </em></strong><strong><em>AWS_IAM later to harden security.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBPgqRGMkZyoJioz1Mqong.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*7Sidcm4HdZqNBBJoXvWTiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cB9v31uYrYXsWByMS9WJWw.png" /></figure><p><strong>STEP 04: Crate the Service Network</strong></p><p>This is the part where connection magic happens.</p><ul><li>You must click Create Service Network to create and label a service network called Cake-Arcade-Network.</li><li>Associate your newly created payment-service with your new service network.</li><li>The Association of VPCs is the single most important item on this list. You must create an association with both vpcs, <br>Cake-Frontend-VPC <br>Cake-Backend-VPC</li><li>This will physically connect/create a logical connection between the two VPCs without the need for VPC peering.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMmeBGmkDn0QGLwk2I_pnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9cPFl7znwX2ogSXHxMFDqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4kqpVDcSS3KgzxgT0mHZmw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HMaip4ZwCuxrliO_f_HnhA.png" /></figure><p><strong>STEP 05: Configure Security Group</strong></p><p>When using Lattice for routing purposes, it is worth noting that your backend EC2 will block all incoming traffic by default via the firewall. To resolve this issue:</p><ol><li>Locate the security group associated with your backend EC2 instance and navigate to it.</li><li>Click on the Inbound Rules tab.</li><li>Create a new rule that will allow for HTTP (Port 80) incoming traffic.</li><li>For your source, do not enter an IP address; instead, enter the AWS Managed Prefix List for Lattice. <br><em>For example, com.amazonaws.region.vpc-lattice in the search bar.</em></li></ol><p>This means that your EC2 instance is saying, “Allow any traffic from the Lattice Service Network.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*psebjY5PANKrYCj0FFLTBw.png" /></figure><p><strong>STEP 06: Verification</strong></p><p>To test the connection:</p><ol><li>Log in to your frontend instance using SSH.</li><li>Run a curl command using the Lattice domain name.</li><li>You should see an HTML response from your private backend server.</li></ol><pre>curl http://payment-service-xxxx.vpc-lattice-svcs.us-east-1.on.aws</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWwBnHeQnJifaxWuYTZqNw.png" /></figure><h4>CONCLUSION</h4><p>VPC Lattice simplifies many of the complexities of AWS Networking for beginners. Through the abstraction of the “plumbing,” beginners can focus on application development rather than trying to figure out how all of the networking components fit together.</p><p>This demo only covered how to build your own application connectivity, but VPC Lattice also allows you to implement Zero Trust security for your application by changing the method of authentication from connection to security. The Auth Type can be set to AWS_IAM and will enforce strong policy, thus limiting your application to only the services you have defined as authorized.</p><p>If microservices networking has been difficult to manage due to the complexity of route tables, take advantage of VPC Lattice!</p><p>I hope this provided a clear understanding of the concept. Thank you!</p><p>Feel free to share any corrections or suggestions in the comments section.<br>I welcome improvements.<br>For more content related to the DevOps world, please follow me.</p><p>Cheers, happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0b14e3e9faa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting VPCs with AWS VPC Peering : A Complete Step-by-Step Guide]]></title>
            <link>https://medium.com/@buddhikagaveen2021/connecting-vpcs-with-aws-vpc-peering-a-complete-step-by-step-guide-0e81150a943d?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e81150a943d</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Thu, 23 Oct 2025 06:58:51 GMT</pubDate>
            <atom:updated>2026-01-08T03:00:37.511Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In the <a href="https://medium.com/@buddhikagaveen2021/how-to-set-up-an-aws-vpc-a-simple-step-by-step-guide-2285818c44c5">last article</a>, we set up a custom AWS Virtual Private Cloud (VPC) with public and private subnets, gateways, and EC2 instances.<br>Now that you’ve made your own VPC, let’s take it a step further and connect several VPCs so that you may talk to each other privately and without any problems.</blockquote><blockquote>VPC Peering is the name of this technique, and it’s one of the most essential ideas in AWS networking.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HKhOYWVdJb2XqdsjTH6_Aw.png" /></figure><h3>What does VPC peering mean?</h3><p>You can connect two VPCs secretly using AWS’s internal network with VPC peering. When connected, instances in these VPCs can communicate without the internet or a VPN.</p><h4>Key Points:</h4><ul><li>There is a direct link between the two VPCs.</li><li>Communication is private because the traffic remains within the AWS backbone.</li><li>YYou can peer VPCs that belong to the same AWS account or to different AWS accounts.</li><li>This feature is applicable to VPCs located in the same region as well as those in different regions or multiregion setups.</li></ul><h4>Common Use Cases</h4><ul><li>Linking development and production settings.</li><li>Sending data between different parts of the business.</li><li>Connecting many VPCs to centralized services like databases, logging, or monitoring.</li><li>This ensures the safe communication between various AWS accounts.</li></ul><h3>Step 1: Things you need to do first</h3><p>Before you set up a VPC peering connection, make sure you have:</p><ul><li>Two VPCs with two public subnets that are already there (like vpc-a and vpc-b)</li><li>CIDR blocks for each VPC must not overlap.</li><li>For example:<br><em>vpc-a: 10.0.0.0/16 , vpc-a-public : </em>10.0.0.0/20<em><br>vpc-b: 10.1.0.0/16 , vpc-b-public : </em>10.1.0.0/20</li><li>Correct IAM permissions to set up and accept peering connections</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yip-JVVp3HRUCpHYVD840A.png" /></figure><h3>Step 2: Set up a VPC peering connection</h3><p>In the console:</p><ul><li>Go to Peering Connections on the VPC Dashboard.</li><li>Make a connection to peer</li><li>Type in a name, like vpc-a-to-b.</li><li>Choose your first VPC (vpc-a) from the list that says “VPC (Requester).</li><li>Choose the second VPC (vpc-b) from the drop-down menu under VPC (Accepter).</li><li>Enter the Account ID and VPC ID by hand if the second VPC is in a different account.</li><li>Click on “Create Peering Connection.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CScge1nsqQStzHOz5XA4WQ.png" /></figure><h3>Step 3: Accept the Connection to Peering</h3><p>The accepter VPC (vpc-b) must approve the request after it is made.</p><p>In the Console:</p><ul><li>Go to VPC and then Peering Connections.</li><li>Choose your new connection → Click Actions → Accept the request</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQSxHDINcJhHUL_SKPEYaA.png" /></figure><p><strong><em>The connection state changes to Active ✅ once you accept it.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKxKzBF8Y-8RyBx1-LMEzg.png" /></figure><h3>Step 4: Update the route tables</h3><p>The two VPCs won’t be able to talk to each other even though the peering connection is active until their route tables are changed.</p><p>You need to add routes in both VPCs that point to each other over the peering connection.</p><h4>For vpc-a:</h4><ul><li>Go to Route Tables and choose the table that is related to your subnets.</li><li>Click “Edit routes” and then “Add route.”</li><li>CIDR block of VPC-B (10.1.0.0/16) is the destination</li><li>Your peering connection ID is the target.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9145WemfGUulU6nKofER8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4oePKhp0TnpdavMNduJA6g.png" /></figure><h4>For vpc-b:</h4><ul><li>Do the same thing, but change the destination.</li><li>The CIDR block of VPC-A (10.0.0.0/16) is the destination.</li><li>Target: The ID of your Peering Connection.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vMSAXXyvqOwduySDDXu8Mg.png" /></figure><h3>Step 5: Set up security groups</h3><p>Even if routes are set up, security groups must nevertheless let traffic from the other VPC through.</p><h4>In the EC2 Security Group for vpc-a:</h4><ul><li>Allow traffic from 10.1.0.0/16 in the inbound rule.</li></ul><h4>In the EC2 Security Group for vpc-b:</h4><ul><li>Allow traffic from 10.0.0.0/16 as an inbound rule</li></ul><p>This makes sure that instances in both VPCs can talk to each other safely.</p><h3>Step 6: Check the connection</h3><ul><li>Start an EC2 instance in each VPC, such one in 10.0.0.0/20 and another in 10.1.0.0/20.</li><li>SSH into one of them, such the public instance in vpc-a.</li><li>Ping the private IP address of the instance in vpc-b.</li><li>ping 10.1.1.10<br><strong><em>If you get answers, your VPC peering connection is working!</em></strong></li></ul><h3>Limitations in VPC Peering</h3><p>VPC peering is quite useful, however it does have certain limits:</p><ol><li>No transitive peering: You can’t link vpc-a to vpc-b to vpc-c indirectly.</li><li>No CIDR blocks that are the same.</li><li>You have to manually update the route table for each new subnet or VPC.</li><li>DNS resolution between VPCs won’t happen automatically unless it’s turned on in both.</li><li>AWS Transit Gateway is a scalable alternative to complicated peering meshes if you need to connect a lot of VPCs.</li></ol><h3>Best Practices</h3><ul><li>Plan CIDR ranges that don’t overlap early on so that networking is easy later.</li><li>For name-based communication, turn on DNS resolution in the peering settings.</li><li>Tags can help you make peering relationships apparent.</li><li>If you have a lot of VPCs, you might want to use Transit Gateway instead of a lot of peerings.</li></ul><h3>Conclusion</h3><p>VPC peering is a safe and powerful approach to let several VPCs talk to each other privately without letting your traffic go out to the internet. You may simply connect environments like development, testing, and production by following these steps. This will keep your network design simple and effective.</p><p>Peering is ideal for small- to medium-sized contexts, but keep in mind its constraints, such as the fact that it doesn’t provide transitive connectivity. AWS Transit Gateway or Site-to-Site VPN might be better for more complicated multi-VPC or hybrid cloud designs.</p><p>You have now linked two VPCs discreetly and safely without utilizing the internet! So far on your journey, you have:</p><ul><li>Learned about a VPC</li><li>Made one from scratch</li><li>Used VPC Peering to link several VPCs together</li></ul><h3>Up Next</h3><p><strong><em>In the next article, we’ll talk about how to link your GCP network to AWS securely via a Site-to-Site VPN, step by step. This is more than just VPC-to-VPC communication. Stay tuned!</em></strong></p><p>I hope this provided a clear understanding of the concept. Thank you!</p><p>Feel free to share any corrections or suggestions in the comments section.<br>I welcome improvements.<br>For more content related to the DevOps world, please follow me.</p><p>Cheers, happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e81150a943d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up an AWS VPC: A Simple Step-by-Step Guide]]></title>
            <link>https://medium.com/@buddhikagaveen2021/how-to-set-up-an-aws-vpc-a-simple-step-by-step-guide-2285818c44c5?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2285818c44c5</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Wed, 22 Oct 2025 11:42:10 GMT</pubDate>
            <atom:updated>2025-10-23T10:08:28.510Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In the <a href="https://medium.com/@buddhikagaveen2021/understand-aws-virtual-private-cloud-a-full-guide-for-cloud-professionals-02585a8cc7b8">last article</a> in our AWS Networking series, we spoke about what an Amazon Virtual Private Cloud (VPC) is, what it’s made of, and why it’s the best way to establish secure, scalable cloud networks.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jVshGFkFPPq9B1s2RjOuQ.png" /></figure><p>In this post, I’ll teach you how to build up your own AWS VPC step by step. Then I’ll show you how to start EC2 instances inside it to test the connection.<br>At the end, you’ll have a network that works with:</p><ul><li>A custom VPC</li><li>Subnets for the public and private</li><li>A NAT Gateway and an Internet Gateway</li><li>Route tables, security groups</li><li>An EC2 instance that is running in your VPC</li></ul><h3>What You’ll Learn</h3><ul><li>How to make your own VPC with your own CIDR block</li><li>How to configure both public and private subnets</li><li>How to set up NAT and Internet Gateways</li><li>How to set up and link route tables</li><li>How to launch EC2 instances in your VPC</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*zNbx_BFKrWA9hzZA-N_AEw.png" /><figcaption>VPC ARCHITECTURE</figcaption></figure><h3>Step 1: Set up a VPC</h3><ol><li>In the AWS Console, go to VPC.</li><li>Click Create VPC and then choose VPC and more.</li><li>Type in a name, like “my-vpc.”</li><li>Set the IPv4 CIDR block to 10.0.0.0/16.</li><li>Click “Create VPC” after leaving the other options as they are.</li></ol><p>CLI Example:</p><pre>aws ec2 create-vpc \<br>  --cidr-block 10.0.0.0/16 \<br>  --tag-specifications &#39;ResourceType=vpc,Tags=[{Key=Name,Value=my-vpc}]&#39;</pre><p><strong><em>Tip: Make sure your CIDR range is broad enough for future growth.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHDQppx-aB4GumLsgnv3Qg.png" /></figure><h3>Step 2: Make Subnets</h3><p>Subnets break up your network into smaller parts.<br>Make:</p><ul><li>Public Subnet 1: 10.0.1.0/24 (ap-southeast-1a)</li><li>Private Subnet 1: 10.0.2.0/24 (ap-southeast-1a)</li></ul><p>In the Console:</p><ol><li>Go to Subnets and then click Create subnet.</li><li>Pick your VPC.</li><li>Choose an AZ, like ap-southeast-1a.</li><li>Add a block of CIDR.</li><li>Do this for every type of subnet.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HysarH9SI3xc_rEl5jpnnA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*npBhXcYRPW1zkSENOHRO7w.png" /></figure><h3>Step 3: Set up and connect an Internet Gateway</h3><p>Steps:</p><ol><li>Go to Internet Gateways and click “Create Internet Gateway.”</li><li>Give it a name, such “my-igw.”</li><li>Click Create.</li><li>Choose it, then attach it to the VPC and choose your VPC.</li></ol><p>CLI Sample:</p><pre>aws ec2 create-internet-gateway \<br>  --tag-specifications &#39;ResourceType=internet-gateway,Tags=[{Key=Name,Value=my-igw}]&#39;<br><br>aws ec2 attach-internet-gateway \<br>  --internet-gateway-id igw-0123abcd \<br>  --vpc-id vpc-0123456789abcdef0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMVuy3oU1RDbgAcdAqzJuw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0T1YrCALldoztWpj0WN7-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NAHXwRPSvykimk5BfVKXRw.png" /></figure><h3>Step 4: Set up the route tables</h3><p>Make two route tables: one for private subnets and one for public subnets.</p><p><em>Table of Public Routes:</em></p><ol><li>To make a route table, go to Route Tables and then click Create.</li><li>Assign it the name public-rt and choose your VPC.</li><li>Make a route:<br><em>Destination: 0.0.0.0/0<br>Your Internet Gateway is the target.<br>Choose your public subnet from the list of subnet affiliations.</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ld3bI4vGHChqqlbOjy0FA.png" /></figure><p><em>Table of Private Routes:</em></p><ol><li>Please create a new route table named private-rt for your private subnet.</li></ol><p><strong><em>For now, leave the routes as they are. We’ll change them after we add the NAT Gateway.</em></strong></p><h3>Step 5: Make a NAT Gateway for Private Subnets</h3><p>A NAT Gateway lets private instances get updates from the internet without letting anyone see them.</p><p>Steps:</p><ol><li>To make a NAT Gateway, go to NAT Gateways and click on “Create NAT Gateway.”</li><li>Pick your public subnet.</li><li>Give out a new Elastic IP.</li><li>Make the NAT Gateway.</li><li>After it is made:<br><strong><em>To add routes, go to Private Route Table and click Edit.<br> To: 0.0.0.0/0<br> Your NAT Gateway is the target.</em></strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wV8b2o2Ug6mi5JV3b6dWPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CLj-w6b55K2x4FXnuJFJnQ.png" /></figure><h3>Step 6: Set up NACLs and Security Groups</h3><h4>SGs (Security Groups):</h4><p>You can control traffic coming in and going out at the instance level.<br>By default, SG lets all outgoing traffic through; incoming traffic must be set up manually.</p><p><em>Rules for incoming:</em></p><ul><li>SSH (22) → My IP</li><li>HTTP (80) -&gt; Anyplace (0.0.0.0/0)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZtf-XV1js50e7Ix1-efDQ.png" /></figure><h4>Network ACLs (NACL):</h4><p>Network ACLs (NACL) are applied at the subnet level and are stateless, meaning you must define both inbound and outbound rules.<br>Default lets everyone in, but you can make it stricter later.</p><h3>Step 7: Start an EC2 Instance in the Public Subnet</h3><p>Let’s test your VPC by launching an EC2 instance now that it’s ready.</p><p>Steps:</p><ol><li>Launch instances by going to EC2 → Instances.</li><li>Give your instance a name, like “public-ec2.”</li><li>Pick an Amazon Machine Image (AMI), like Amazon Linux 2.</li><li>Choose the sort of instance you want (for example, t2.micro).</li><li>In the Network settings:<br><em>VPC: my-vpc<br>Subnet: public-subnet<br>Enable Auto-assign Public IP</em></li><li>Security Group: utilize your web-sg (SSH/HTTP allowed)</li><li>Click Launch Instance, pick a key pair, and then click Launch.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2R-GxMuWZHi8StCiN_026g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7INsl_xYgKQA37DdNW-ug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cdQ103eZ7vJSAq0KnHKt9g.png" /></figure><ol><li>After launching, copy the public IPv4 address and use SSH to connect to it:</li></ol><pre>ssh -i mykey.pem ec2-user@&lt;public_ip&gt;</pre><p>You should be able to connect without any problems. This shows that your public subnet, route table, and Internet Gateway are all up correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjgMpyOfpnUMqqoo_F7KUw.png" /></figure><h3>Step 8: Start an EC2 instance in the private subnet</h3><p>Let’s check to see if your NAT Gateway is working.</p><p>Steps:</p><ol><li>Go to EC2 and start instances again.</li><li>Give it the name private-ec2.</li><li>Choose the same type and AMI</li><li>In the Network settings:<br><em>VPC: my-vpc<br>Subnet: private-subnet<br>Turn off auto-assign public IP.</em></li><li>Allow SSH from the private IP of your public EC2 instance in the security group.</li><li>Launch the instance.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pq9vqGT8xWNJlkwLQJ5B4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UnqKUcJ0Yq_a1CfE2rqFZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RL6Ca_d84XLE0mpdlrOiAg.png" /></figure><ol><li>Check Connectivity:<br><em>Log on to your public EC2 via SSH.<br>Then, use SSH to connect to the private EC2</em></li><li>Once you go inside, check to see whether you can connect to the internet:</li></ol><pre>curl http://google.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z4toM3g6EgxRM71xwJznJA.png" /></figure><p>You should get an HTML response, which means that the NAT Gateway and routing are both operating well!</p><h3>Step 9: Clean Up (Optional)</h3><p>To keep from getting charged again:</p><ul><li>Stop EC2 instances.</li><li>Get rid of the NAT Gateway and free up the Elastic IP.</li><li>Get rid of the VPC, route tables, and subnets.</li></ul><h3>Best Practices</h3><ul><li>For high availability, use more than one AZ.</li><li>Plan CIDR blocks such that they don’t overlap between VPCs.</li><li>Use VPC Endpoints to get to S3 or DynamoDB without anyone else seeing it.</li><li>To keep an eye on everything, turn on VPC Flow Logs.</li><li>Use IAM roles instead of hardcoding credentials.</li></ul><h3>Conclusion</h3><p>We learned about AWS VPCs in the past article. Now you’ve made one from scratch, with subnets, gateways, and EC2 instances. This arrangement is the basis for safe networking in AWS.</p><h3>Up Next</h3><p><strong><em>In the next article, we’ll talk about how to use VPC Peering to link more than one VPC, which lets you talk to people in different environments privately.</em></strong></p><p>I hope this provided a clear understanding of the concept. Thank you!</p><p>Feel free to share any corrections or suggestions in the comments section.<br>I welcome improvements.<br>For more content related to the DevOps world, please follow me.</p><p>Cheers, happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2285818c44c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand AWS Virtual Private Cloud: A Full Guide for Cloud Professionals]]></title>
            <link>https://medium.com/@buddhikagaveen2021/understand-aws-virtual-private-cloud-a-full-guide-for-cloud-professionals-02585a8cc7b8?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/02585a8cc7b8</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Tue, 21 Oct 2025 10:46:41 GMT</pubDate>
            <atom:updated>2025-10-22T10:34:22.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qUyuZuhxZ6xcvLECwQJBnw.png" /></figure><blockquote>One of the most significant elements of cloud networking is the Amazon Virtual Private Cloud (VPC). A well-planned VPC gives you control, the flexibility to grow, and security throughout your whole AWS environment. This is critical for app deployment, API hosting, and managing complicated infrastructures.</blockquote><h4><strong>What is AWS Virtual Private Cloud (VPC)</strong></h4><p>An Amazon Virtual Private Cloud (VPC) is a different virtual network that lives in the AWS cloud. You can start AWS services like EC2 instances, RDS databases, and Lambda functions in a network setup that you choose.<br> A Virtual Private Cloud (VPC) is like your own AWS data center with its own IP addresses, routing, security, and connectivity.</p><p><strong><em>AWS is like a big, open city. A VPC is like a private, fenced-off area of property in that city. You are responsible for everything that happens on your land. You have the freedom to determine the location of the residences (servers), control access (security), and determine the routes to the external world (internet).</em></strong><br> <br><strong>Some important benefits:</strong></p><ul><li>Make sure your business is entirely different from other AWS clients.</li><li>Managing CIDR blocks, which are sets of IP address ranges</li><li>Routing and security can change.</li><li>Connectivity options: Internet Gateway, Virtual Private Network, Direct Connect</li></ul><p><strong>Example</strong><br>An example of a virtual private cloud (VPC) is one that has a CIDR range of 10.0.0.0/16. By breaking up the 65,536 IP addresses into smaller subnets, we can better manage and protect this data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*7KcaXC2Yx_8bQpL43M3hZg.png" /></figure><h3><strong>Key Components in AWS VPC</strong></h3><h3><strong>Subnets—Divide your network logically</strong></h3><p>You can logically divide your network into subnets. You can think of a subnet as a section of a VPC’s IP range, just like you might divide your office building into floors based on the work each department does. Even though they are all in the same building (VPC), each floor (subnet) has a different purpose.</p><p>AWS uses subnets to logically arrange resources and separate workloads that require different types of connectivity. For instance, we maintain web servers in public subnets that serve customers via the Internet. Private subnets are where backend systems like databases, which should stay inside, are stored.</p><h4><strong>Public subnets</strong></h4><p>An Internet Gateway (IGW) connects public subnets to the Internet.<br>These are similar to the reception area at your job. The main door, often known as the Internet Gateway, lets anyone from outside in and lets them use public-facing systems like web servers.</p><p>You might offer a public subnet the CIDR block 10.0.1.0/24 if your VPC contains the CIDR block 10.0.0.0/16. You can host the front-end EC2 instance for your website here, and users can go to it directly through a public IP address.</p><h4><strong>Private Subnets</strong></h4><p>Private subnets, on the other hand, can’t connect directly to the Internet.<br>Only internal workers (other AWS resources) can get to them, just like your protected data room.<br>These subnets are perfect for keeping your databases, backend software, or internal services that the public should never view.</p><p>For instance, give a private subnet that has a database server the address 10.0.2.0/24. People on the Internet can’t get to this database directly, but it can talk to the web server in the public subnet.</p><h4><strong>Structure of a Subnet</strong></h4><p>Let’s say you’re hosting a simple two-tier web app with a frontend website and a backend database in several availability zones to make this obvious.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fa962fa14a8d10b991b5f79721f6c2d/href">https://medium.com/media/2fa962fa14a8d10b991b5f79721f6c2d/href</a></iframe><p>Your app can stay up even if one data center goes down if you use resources in more than one Availability Zone (AZ). Public subnets take care of the web layer, and private subnets keep data safe by storing it.</p><h3>Route Tables: Your Network’s GPS</h3><p>A route table is needed for each subnet in a VPC to know where to transmit network traffic. Route tables are like GPS systems for your data packets. Route tables direct data packets on how to reach their destinations.</p><p>There are rules in each route table that tell traffic going to certain IP ranges where to go. These rules are called routes.</p><p>For instance, if your VPC has an internal route of 10.0.0.0/16, this keeps all communication within your VPC local. You need to set a route like 0.0.0.0/0 that points to your Internet Gateway (IGW) if you want your public subnet to be able to connect to the Internet.</p><p>We redirect outgoing traffic from private subnets through a NAT Gateway instead of letting it go directly to the Internet. This way, they can access the Internet for software updates or API calls, but outsiders can&#39;t reach them.</p><h4>Example Structure: Public Route Table</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2d0f1beff75d3f82c6ffc39967e1617b/href">https://medium.com/media/2d0f1beff75d3f82c6ffc39967e1617b/href</a></iframe><p><strong><em>The Destination column in a route table tells you the IP address range or network that the traffic is meant to reach. This is basically the answer to the question, “Where does this packet need to go?”<br>The Target column, also called the next hop, shows the gateway, device, or interface that traffic should go through to reach the specified destination. This answers the question, “What is the next step the packet should take to get to its destination?”</em></strong></p><h3>Network ACLs (NACLs)—Security measures at the subnet level.</h3><p>Now, let’s talk about the security checkpoints that protect these subnets. Your subnets have a virtual bouncer called a Network Access Control List (NACL) that decides what traffic can come in and out.</p><p>NACLs work on subnets, while security groups work on individual instances. The main distinction is that NACLs are stateless. This means that if you let traffic come in on a given port, you also have to let traffic go out on that port.</p><p>Think of your VPC as a gated community with two neighborhoods:<br>One for web servers that are open to the public<br>One for databases that are not public</p><p>At the entrance to each neighborhood, there is a guard (the NACL) who checks every vehicle (data packet) that comes in or goes out.</p><p>You might want to let HTTP (port 80) and HTTPS (port 443) traffic come from anywhere on your public subnet. You might also want to only let SSH (port 22) traffic come from your company’s office IP.</p><p>Your NACL rules might look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/146296fdad2b90b5842631a5cabfec1d/href">https://medium.com/media/146296fdad2b90b5842631a5cabfec1d/href</a></iframe><p>In this situation:</p><ul><li>Anyone can use HTTP or HTTPS to go to your web servers.</li><li>You may only SSH into them from your corporate network.</li><li>All other things are blocked.</li><li>Your NACL might only allow internal communication on private subnets. For example, it might only let MySQL traffic (port 3306) from the web server subnet.</li></ul><p>NACLs are very helpful when you need to set broad limits, such as blocking a certain range of malicious IPs over the whole subnet. This is not something you can easily achieve with security groups alone.</p><h3>NAT Gateway—Network Address Translation Gateway</h3><p>Think of your private subnet as a safe office inside that doesn’t have a door to the outside world. But your employees (EC2 instances) still need to get upgrades or use tools that are outside of your network.<br>A NAT gateway is like a safe receptionist. It enables employees to make calls from the office, but it doesn’t let people from outside the office phone in directly.</p><p>This is how it works:</p><ul><li>Your EC2 instance in the private subnet sends a request to an outside website, like when you want to get a Linux update.</li><li>The NAT Gateway, which is in a public subnet, gets the request.</li><li>The NAT Gateway transmits the request to the Internet after replacing the private IP address with its own Elastic IP (public IP).</li><li>The NAT Gateway sends the response back to the right private instance when it gets it back.</li></ul><h3>Internet Gateway (IGW)—Gateway to the Internet.</h3><p>An Internet Gateway (IGW) is an AWS part that is highly available, redundant, and horizontally scaled. It lets resources in your VPC talk to the Internet. It is like the main gate that leads from your private land (VPC) to the rest of the world.</p><p>Without an IGW, all of the public-facing resources in your VPC, such as web servers, would be completely cut off from the rest of the world. Even if you give them public IP addresses, they won’t be able to connect to the Internet because there won’t be a way for traffic to get in or out.</p><p>Important Points:</p><ul><li>Two-way communication: The IGW lets traffic from your VPC go to the Internet and traffic from the Internet come back to your VPC. This is called bidirectional communication.</li><li>Public Subnet Requirement: A subnet can only be called public and accessible from the Internet if it is in a route table that transmits 0.0.0.0/0 traffic to the IGW.</li><li>Highly Available: AWS manages the IGW and ensures it is redundant across Availability Zones so that it doesn’t become a single point of failure.</li></ul><p><strong>An example from the real world:</strong></p><p>Think of your VPC as a private home:<br>The primary gate is the IGW. Public subnets are like roads that lead to the gate, letting guests (Internet traffic) get to your web servers. No matter how well-built your internal roadways (subnets) are, the absence of this gate completely blocks off your estate from the outside world.</p><h3>Conclusion</h3><p>The AWS Virtual Private Cloud (VPC) is the main part of your cloud network. It’s a safe, flexible space where you can regulate how your resources talk to each other, grow, and stay safe. You can create designs that are both strong and efficient if you know the main parts of the Internet, such as subnets, route tables, NACLs, NAT Gateways, and Internet Gateways.</p><p>Each part has a different job to ensure that your apps are available, safe, and running as fast as possible. A well-structured VPC establishes the groundwork for a strong and scalable cloud infrastructure by intelligently routing traffic, keeping sensitive data separate, and allowing Internet access through well-defined gateways.</p><h3>Up Next</h3><p><strong><em>In the next chapter, we’ll show you how to set up your own AWS VPC from scratch, including how to define CIDR blocks and set up subnets, route tables, and gateways. This will help you make a safe and ready-to-use environment.</em></strong></p><p>I hope this provided a clear understanding of the concept. Thank you!</p><p>Feel free to share any corrections or suggestions in the comments section.<br>I welcome improvements.<br>For more content related to the DevOps world, please follow me.</p><p>Cheers, happy learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02585a8cc7b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Istio: An Introduction to Service Meshes]]></title>
            <link>https://medium.com/@buddhikagaveen2021/getting-started-with-istio-an-introduction-to-service-meshes-6d6b4224b912?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d6b4224b912</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 05:12:05 GMT</pubDate>
            <atom:updated>2025-04-28T08:32:25.869Z</atom:updated>
            <content:encoded><![CDATA[<p><em>As applications grow, especially in a microservices architecture, managing communication between services becomes more complex. A </em><strong><em>service mesh</em></strong><em> is a dedicated layer that helps control, monitor, and secure this communication without changing the application code.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*skvXZ68aRSTWu-2c7ioE5A.png" /></figure><h4><strong>What is Istio?</strong></h4><p>At a high level, Istio is a service mesh, which is a framework for managing and securing communication between microservices. However, to properly understand Istio, we first need to explore the concept of a service mesh.</p><h4><strong>Service Meshes: The Concept</strong></h4><p>Service meshes are a relatively new concept, especially in the context of distributed systems. They’ve gained significant attention recently, particularly as microservice architectures running on Kubernetes have become more common. A service mesh is designed to address certain challenges that arise in microservice-based environments, particularly around networking, security, monitoring, and traffic management.</p><h4><strong>The Role of Service Meshes in Microservices</strong></h4><p>Let’s consider a typical microservice architecture running on Kubernetes. In such an architecture, you’ll have numerous Kubernetes pods, each generally containing a single container. These containers are networked together, and Kubernetes provides the service discovery mechanisms that allow containers to communicate with each other.<br>While Kubernetes does a great job of managing pods, it doesn’t provide visibility or control over the network communication between those pods. For example, if one container fails to respond to a request, it’s difficult to diagnose the problem because Kubernetes doesn’t give you insights into what’s happening in that network communication.This is where a service mesh like Istio comes into play.</p><h4><strong>How Does Istio Work?</strong></h4><p>You can think of a service mesh as an additional layer of software that sits beneath the pods in your Kubernetes cluster. When a service mesh is in place, all traffic between containers is routed through the mesh. The mesh can then apply various logic to the traffic, such as monitoring, routing, security, and more.</p><h4><strong>Here’s how it works:</strong></h4><p>When a container (say, Container A) needs to communicate with another container (Container B), instead of calling Container B directly, the network request is routed through the service mesh.The mesh can apply logic to the request before it’s forwarded to the target container. This could involve things like logging, monitoring, traffic routing, or enforcing security policies.Once the response is received from Container B, the mesh can also process the response, adding more logic, such as logging or tracking the time it took to complete the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*5YLoT73Lds8EnL_wdsjpYA.png" /><figcaption>this is how service mesh works</figcaption></figure><h3>Key Features of Service Meshes:</h3><p><strong>Telemetry and Monitoring:</strong></p><ul><li>Collects detailed metrics about network requests, such as response times and success/failure rates.</li><li>Helps monitor microservices and quickly detect issues.</li></ul><p><strong>Tracing:</strong></p><ul><li>Tracks the path of a request as it travels through different microservices.</li><li>Helps diagnose performance bottlenecks and identify failures in complex service chains.</li></ul><p><strong>Traffic Management:</strong></p><ul><li>Manages traffic flows intelligently based on conditions or policies.</li><li>Supports techniques like <strong>blue/green deployments</strong> and <strong>canary releases</strong>.</li></ul><p><strong>Security:</strong></p><ul><li>Encrypts communication between services.</li><li>Enforces authentication and manages access controls.</li></ul><h3>Istio’s Approach to Service Mesh:</h3><p><strong>Sidecar Proxy:</strong></p><ul><li>Istio adds a <strong>proxy container</strong> (sidecar) alongside each application container inside a pod.</li></ul><p><strong>Traffic Interception:</strong></p><ul><li>Every network request from a container is intercepted by its local proxy.</li></ul><p><strong>Mesh Logic Application:</strong></p><ul><li>The proxies apply mesh logic like telemetry, tracing, traffic management, and security to the traffic.</li></ul><p><strong>Request Flow Example:</strong></p><ul><li>When <strong>Container A</strong> sends a request to <strong>Container B</strong>:</li><li>The request first goes to <strong>Container A’s Envoy proxy</strong> (sidecar).</li><li>The proxy forwards the request to <strong>Container B’s Envoy proxy</strong>.</li><li>Finally, the request reaches <strong>Container B</strong>.</li></ul><p>Behind the scenes:</p><ul><li><strong>Istiod</strong> (the control plane) is responsible for:</li><li>Providing <strong>configuration</strong> to the Envoy proxies.</li><li>Managing <strong>service discovery</strong>, <strong>traffic routing rules</strong>, <strong>security policies</strong>, and <strong>certificate management</strong>.</li><li>Continuously updating the proxies as needed without needing to modify the application containers.</li></ul><p>This architecture ensures:</p><ul><li>Traffic policies (like retries, timeouts, access control) are applied at every communication step.</li><li>Centralized management through Istiod, with decentralized enforcement through the proxies.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*JAze5MuMvl_2ChaZtcUpsg.png" /><figcaption>how istio implements service mesh</figcaption></figure><h4>Understanding Istio’s Architecture</h4><p><strong>Data Plane: </strong>The data plane is composed of the proxies deployed alongside your microservices. These proxies intercept all network traffic and apply the mesh logic.</p><p><strong>Control Plane: </strong>The control plane manages the proxies and their configurations. The core of the control plane is the Istio D pod, which handles the majority of Istio’s functionality. Other components of the control plane may include pods for visualization tools like Kiali, which helps you monitor and understand the relationships between your microservices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*PYiNGTjf68WWA3Hk96jIKQ.png" /></figure><h4><strong>How Istio Integrates with Your Microservices</strong></h4><p>One of the key benefits of Istio is that it’s largely non-invasive to your application code. In most cases, you won’t need to make any changes to the containers running your microservices. The service mesh is added to your cluster, and it handles traffic routing transparently without requiring any modification to your application code.<br>There is one exception to this, though, which is related to tracing. But for now, the general idea is that Istio operates as an add-on to Kubernetes that doesn’t impact the functioning of your existing services.</p><h4><strong>Conclusion</strong></h4><p>At a high level, Istio is a service mesh that provides advanced traffic management, security, telemetry, and monitoring capabilities for Kubernetes-based microservice architectures. By adding proxy containers to your pods, Istio intercepts and manages network communication between microservices, providing you with deeper insights and control over your services.</p><p><em>I hope this provided a clear understanding of the concept. Thank you!</em></p><p><em>Feel free to share any corrections or suggestions in the comments section; I welcome improvements.</em></p><p><strong><em>For more content related to the DevOps world, please follow me.</em></strong></p><p><em>Cheers , Happy Learning!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d6b4224b912" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Voting Application on Kubernetes: Step-by-Step Guide (Part 02)]]></title>
            <link>https://medium.com/@buddhikagaveen2021/deploying-voting-application-on-kubernetes-step-by-step-guide-part-02-85a34ae10f43?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/85a34ae10f43</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Thu, 26 Dec 2024 06:31:34 GMT</pubDate>
            <atom:updated>2024-12-26T08:21:48.539Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deployment-Based Architecture</h4><p><em>Kubernetes provides robust tools to manage and scale applications effectively. While pods serve as the foundation for running containers, using </em><strong><em>deployments</em></strong><em> is a more efficient and scalable approach for managing containerized applications in Kubernetes.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Odujyxgl9tZlHohrdWC5Lw.png" /></figure><p><em>In this article, I will explain how I transitioned a </em><strong><em>Voting Application</em></strong><em> from a pod-based implementation to a deployment-based approach, ensuring better scalability, fault tolerance, and manageability.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gtC3sAu7KRm4pQof3aCFdg.png" /></figure><h3>Why Transition to Deployments?</h3><p>Initially, I deployed the application components using individual pods. However, this approach had limitations:</p><ul><li>Lack of <strong>scalability</strong>: Manually scaling pods for high availability can be cumbersome.</li><li>No <strong>self-healing</strong>: If a pod crashes, it needs to be restarted manually.</li><li><strong>Rolling updates</strong>: Updating applications requires recreating pods manually.</li></ul><p>By transitioning to a <strong>deployment-based approach</strong>, these issues were addressed. Deployments allow Kubernetes to manage pods automatically, including self-healing, scaling, and rolling updates.</p><h3>Application Architecture</h3><p>The application consists of the following components, as shown in the architecture diagram:</p><ol><li><strong>Voting App</strong>: A Python-based frontend for voting.</li><li><strong>Redis</strong>: An in-memory database for temporary vote storage.</li><li><strong>Worker</strong>: A background processor that transfers votes from Redis to the database.</li><li><strong>Postgres</strong>: A relational database for persistent storage.</li><li><strong>Result App</strong>: A Node.js-based frontend for displaying voting results.</li></ol><p>Each component was previously deployed as a standalone pod with associated services for intercommunication.</p><p><strong>You can view the codebase for the pods and services at this URL:</strong></p><p><a href="https://github.com/GaveenBuddhika/Deploy-VotingApp-on-Kubernetes/tree/main/Deployment_Approach">https://github.com/GaveenBuddhika/Deploy-VotingApp-on-Kubernetes/tree/main/Deployment_Approach</a></p><h3>Steps for Transitioning to Deployments</h3><h3>1. Define Deployment YAML Files</h3><p>For each application component, I created a deployment YAML file.</p><ul><li><strong>voting- app-deploy.yaml</strong></li><li><strong>redis-deploy.yaml</strong></li><li><strong>worker-deploy.yaml</strong></li><li><strong>postgres-deploy.yaml</strong></li><li><strong>result- app- deploy.yaml</strong></li></ul><p>Below is an example for the <strong>Voting App</strong> deployment:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: voting-app-deploy<br>  labels:<br>    name: voting-app-deploy<br>    app: demo-voting-app<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      name: voting-app-pod<br>      app: demo-voting-app<br>  <br>  template:<br>    metadata:<br>      name: voting-app-pod<br>      labels:<br>        name: voting-app-pod<br>        app: demo-voting-app<br>    spec:<br>      containers:<br>        - name: voting-app<br>          image: kodekloud/examplevotingapp_vote:v1<br>          ports:<br>            - containerPort: 80</pre><p>This configuration ensures:</p><ul><li><strong>Replicas</strong>: Multiple instances of the app for high availability.</li><li><strong>Self-healing</strong>: Automatic pod restart in case of failure.</li><li><strong>Rolling updates</strong>: Smooth application updates.</li></ul><p>I repeated this process for the other components: <strong>Result App</strong>, <strong>Redis</strong>, <strong>Postgres</strong>, and <strong>Worker</strong>.</p><h3>2. Apply the Deployment Files</h3><p>Once the YAML files were ready, I deployed them using the following command:</p><pre>kubectl apply -f &lt;deployment-file&gt;.yaml<br><br>or<br><br>kubectl create -f &lt;deployment-file&gt;.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*gzvUCqXIb9DMoXJQSTG7yQ.png" /></figure><h3>3. Expose Deployments with Services</h3><p>To enable intercommunication between components, I created services. These were already defined in the pod-based approach, so I reused the service configurations.</p><p>Example of a service definition for Redis:</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: redis<br>  labels:<br>    name: redis-service<br>    app: demo-voting-app<br>spec:<br>  ports:<br>    - port: 6379<br>      targetPort: 6379<br>  selector:<br>    name: redis-pod<br>    app: demo-voting-app</pre><p>I applied the services using:</p><pre>kubectl create -f &lt;service-file&gt;.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*S9uER3ceMr_ov7RQsx-_iA.png" /></figure><h3>4. Verify Deployments and Services</h3><p>To ensure everything was running correctly, I used the following commands:</p><pre>kubectl get deployments<br>kubectl get pods<br>kubectl get services<br><br>or<br><br>kubectl get all</pre><p>The output confirmed that all deployments were running successfully, with pods automatically managed by Kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*jjJ1xXVGutMr5dUd3ooO0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*Co3JzUhzUD3yck0uiMnHTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*FVHHnThuoaQQ7YX2WNfE8Q.png" /></figure><h3>5. Scaling Deployments</h3><p>One of the key benefits of using deployments is the ability to scale applications easily. To scale the <strong>Voting App</strong> to 5 replicas, I used:</p><pre>kubectl scale deployment voting-app-deploy --replicas=5</pre><h3>6. Rolling Updates</h3><p>To demonstrate rolling updates, I updated the <strong>Result App</strong> image:</p><pre>spec:<br>  template:<br>    spec:<br>      containers:<br>      - name: result-app<br>        image: kodekloud/result-app:v2</pre><p>I applied the updated deployment:</p><pre>kubectl apply -f result-app-deploy.yaml</pre><p>Kubernetes performed a rolling update, replacing the pods one at a time without downtime.</p><h3>7. Testing the Application</h3><p>Using Minikube, I retrieved the service URLs to test the application in a browser:</p><pre>minikube service &lt;service-name&gt; --url</pre><p>Both the <strong>Voting App</strong> and <strong>Result App</strong> worked as expected, showing seamless interaction with the backend components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*j7ZjEtmYtuIrSYRihLWg-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*hBL27QZVNkbqRIaBODE8xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tdZZKBRbVy9s6YaYqv0iPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjegU9q7TGI1lh7mex55Xw.png" /></figure><h3>Key Benefits of the Deployment-Based Approach</h3><ul><li><strong>High Availability</strong>: Multiple replicas ensure the app is always available.</li><li><strong>Self-Healing</strong>: Failed pods are automatically restarted.</li><li><strong>Scalability</strong>: Easily scale applications up or down.</li><li><strong>Rolling Updates</strong>: Deploy updates without downtime.</li></ul><h3>Conclusion</h3><p>Transitioning from a pod-based to a deployment-based architecture in Kubernetes is a crucial step for managing applications effectively. With deployments, I ensured that the voting application is scalable, resilient, and easy to update.</p><p>This approach not only simplifies operations but also provides the flexibility needed to handle real-world production workloads.</p><p>Feel free to try this setup for your projects and share your experience!</p><p><em>I hope this provided a clear understanding of the concept. Thank you!</em></p><p><em>Feel free to share any corrections or suggestions in the comments section; I welcome improvements.</em></p><p><strong><em>For more content related to the DevOps world, please follow me.</em></strong></p><p><em>Cheers , Happy Learning!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85a34ae10f43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Voting Application on Kubernetes: Step-by-Step Guide (Part 01)]]></title>
            <link>https://medium.com/@buddhikagaveen2021/deploying-voting-application-on-kubernetes-step-by-step-guide-part-01-d6031098ee3e?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6031098ee3e</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Thu, 26 Dec 2024 06:06:42 GMT</pubDate>
            <atom:updated>2024-12-26T06:08:46.655Z</atom:updated>
            <content:encoded><![CDATA[<h4>Pod-Based Architecture</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LAduD2uf8EEDZEgOoyopSw.png" /></figure><p><em>Kubernetes provides an efficient way to manage containerized applications at scale. In this article, I’ll walk you through the process of deploying a simple voting application on Kubernetes. This application consists of multiple components working together, as shown in the architecture diagram:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*p6gfqzTuWWEqlpoqcUNmxw.png" /></figure><h3>Architecture Overview</h3><p>This application was originally developed as part of the <strong>Kubernetes Beginner Course</strong> offered by the KodeKloud learning platform. I utilized the resources and Docker images provided by KodeKloud to implement this project.</p><ol><li><strong>Voting App</strong>: A Python-based front-end for voting.</li><li><strong>Redis</strong>: An in-memory data store for temporarily storing votes.</li><li><strong>Worker</strong>: A background processor for transferring votes from Redis to the database.</li><li><strong>Postgres</strong>: A database for persistent storage of votes.</li><li><strong>Result App</strong>: A Node.js based front-end to display the voting results.</li></ol><p>These components communicate using Kubernetes services, and the setup was initially implemented using pods before converting to a deployment-based approach.</p><p><strong>You can view the codebase for the pods and services at this URL:</strong></p><p><a href="https://github.com/GaveenBuddhika/Deploy-VotingApp-on-Kubernetes/tree/main/Pods_Approach">https://github.com/GaveenBuddhika/Deploy-VotingApp-on-Kubernetes/tree/main/Pods_Approach</a></p><h3>Steps for Deployment</h3><h3>1. Create Individual Pods</h3><p>The first step was to create pods for each component:</p><ul><li><strong>Voting App Pod</strong>: Runs the Python-based frontend.</li><li><strong>Redis Pod</strong>: Stores votes temporarily.</li><li><strong>Worker Pod</strong>: Processes votes and interacts with Redis and Postgres.</li><li><strong>Postgres Pod</strong>: Provides persistent storage for votes.</li><li><strong>Result App Pod</strong>: Displays the voting results.</li></ul><p><em>example: voting-app-pod.yaml</em></p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: voting-app-pod<br>  labels:<br>    name: voting-app-pod<br>    app: demo-voting-app<br>spec:<br>  containers:<br>    - name: voting-app<br>      image: kodekloud/examplevotingapp_vote:v1<br>      ports:<br>        - containerPort: 80</pre><h3><em>Explanation of the Pod Definition File</em></h3><h4><em>[1]. API Version (</em><em>apiVersion)</em></h4><p><em>The </em><em>apiVersion specifies the Kubernetes API version used to define this resource.<br>In this file:</em></p><ul><li><strong><em>apiVersion: v1</em></strong><em> indicates the use of the stable version of the Kubernetes API for core resources like Pods.</em></li></ul><h4><em>[2]. Kind (</em><em>kind)</em></h4><p><em>The </em><em>kind field specifies the type of Kubernetes resource being created.</em></p><ul><li><strong><em>kind: Pod</em></strong><em> signifies that the object being defined is a Pod.</em></li></ul><h4><em>[3]. Metadata (</em><em>metadata)</em></h4><p><em>The </em><em>metadata section provides essential information for identifying and managing the Pod.</em></p><ul><li><strong><em>name: voting-app-pod</em></strong><em>This is the unique name assigned to the Pod within the namespace. It helps in identifying the Pod for operations like monitoring and debugging.</em></li><li><strong><em>labels</em></strong><em>Labels are key-value pairs used to categorize Kubernetes resources.</em></li><li><strong><em>name: voting-app-pod</em></strong><em>: Identifies the Pod name as a label.</em></li><li><strong><em>app: demo-voting-app</em></strong><em>: Groups this Pod under the </em><em>demo-voting-app application. Labels like this are critical for service discovery and workload organization.</em></li></ul><h4><em>[4]. Specification (</em><em>spec)</em></h4><p><em>The </em><em>spec section defines the desired state of the Pod, including the containers and their configurations.</em></p><p><em>This section lists all the containers that will run inside the Pod.</em></p><ul><li><strong><em>name: voting-app</em></strong><em>The name of the container. It is used to identify logs and monitor specific containers within the Pod.</em></li><li><strong><em>image: kodekloud/examplevotingapp_vote:v1</em></strong><em>The Docker image that the container will run. In this example, the image is </em><em>kodekloud/examplevotingapp_vote:v1, which contains the Voting App&#39;s functionality.</em></li><li><strong><em>ports:</em></strong><em>Defines the ports that the container will expose to handle incoming traffic.</em></li><li><strong><em>containerPort: 80</em></strong><em> specifies that the container listens on port </em><em>80, typically used for serving HTTP traffic.</em></li></ul><h3>2. Expose Services</h3><p>To enable communication between components, services were created:</p><ul><li><strong>Voting App Service</strong>: Exposes the voting app on port 80.</li><li><strong>Result App Service</strong>: Exposes the result app on port 80.</li><li><strong>Redis Service</strong>: Exposes Redis on port 6379.</li><li><strong>Postgres Service</strong>: Exposes Postgres on port 5432.</li></ul><p>The worker pod does not require a service as it interacts directly with other services using their DNS names.</p><p><em>example:voting-app-service.yaml</em></p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: voting-service<br>  labels:<br>    name: voting-service<br>    app: demo-voting-app<br>spec:<br>  type: NodePort<br>  ports:<br>    - port: 80<br>      targetPort: 80<br>      nodePort: 30004<br>  selector:<br>    name: voting-app-pod<br>    app: demo-voting-app</pre><h3><em>Explanation of the Service Definition File</em></h3><h4><em>[1]. API Version (</em><em>apiVersion)</em></h4><ul><li><strong><em>apiVersion: v1</em></strong><em> specifies that this Service resource is defined using the stable version of the Kubernetes API for core resources.</em></li></ul><h4><em>[2]. Kind (</em><em>kind)</em></h4><ul><li><strong><em>kind: Service</em></strong><em> indicates that this Kubernetes resource is a Service. Services provide a stable endpoint to access one or more Pods, even if the Pods are replaced or rescheduled.</em></li></ul><h4><em>[3]. Metadata (</em><em>metadata)</em></h4><p><em>This section provides identifying information about the Service.</em></p><ul><li><strong><em>name: voting-service</em></strong><em><br>This assigns a unique name to the Service, used to identify it within the namespace.</em></li><li><strong><em>labels</em></strong><em><br>Labels are key-value pairs used to categorize and organize Kubernetes resources.</em></li><li><strong><em>name: voting-service</em></strong><em>: Identifies the name of the Service as a label.</em></li><li><strong><em>app: demo-voting-app</em></strong><em>: Groups this Service under the </em><em>demo-voting-app application, ensuring association with related resources like Pods.</em></li></ul><h4><em>[4]. Specification (</em><em>spec)</em></h4><p><em>The </em><em>spec section defines the behavior of the Service.</em></p><p><strong><em>Service Type (</em></strong><strong><em>type)</em></strong></p><ul><li><strong><em>type: NodePort</em></strong><em><br>Specifies that this Service exposes the application on a static port on each Node in the cluster. This allows external access to the application using the Node&#39;s IP address and the specified </em><em>nodePort.</em></li></ul><p><strong><em>Ports (</em></strong><strong><em>ports)</em></strong></p><p><em>Defines the ports configuration for the Service.</em></p><ul><li><strong><em>port: 80</em></strong><em><br>This is the port on which the Service is exposed internally to the cluster. Clients accessing the Service within the cluster use this port.</em></li><li><strong><em>targetPort: 80</em></strong><em><br>This is the port on the target Pods that the Service forwards traffic to. In this case, it matches the </em><em>containerPort defined in the Pod.</em></li><li><strong><em>nodePort: 30004</em></strong><em><br>A specific port on the Node that maps to the Service&#39;s </em><em>port. External traffic to this port on the Node is forwarded to the Service and then to the Pod.</em></li></ul><p><strong><em>Selector (</em></strong><strong><em>selector)</em></strong></p><p><em>Defines how the Service identifies the Pods it routes traffic to.</em></p><ul><li><strong><em>name: voting-app-pod</em></strong><em><br>Matches Pods with the label </em><em>name: voting-app-pod.</em></li><li><strong><em>app: demo-voting-app</em></strong><em><br>Ensures the Service targets only Pods associated with the </em><em>demo-voting-app application. Both labels (</em><em>name and </em><em>app) must match for Pods to be selected.</em></li></ul><h3>3. Start Minikube</h3><p><strong>Minikube and Kubectl installation guide :</strong><a href="https://youtu.be/Ttp0c-SX1Pc?si=3gFVBVSwYTuEzejP">https://youtu.be/Ttp0c-SX1Pc?si=3gFVBVSwYTuEzejP</a></p><p>The setup was deployed on a local Kubernetes cluster using Minikube. To start Minikube, the following command was used:</p><pre>minikube start</pre><h3>4. Deploy and Verify Pod and Service Status</h3><p>first you have to make sure no pods are running on minikube cluster:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*UpauHH5yvzfP8G_Xx3JKBw.png" /></figure><ol><li><strong>Each pod was defined in YAML files and deployed using:</strong></li></ol><pre>kubectl apply -f &lt;pod-definition-file&gt;.yaml <br>or<br>kubectl create -f &lt;pod-definition-file&gt;.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*A4h2OUrPY94cHzQ-C55FxQ.png" /></figure><p><strong>2. Creating services using:</strong></p><pre>kubectl apply -f &lt;service-definition-file&gt;.yaml <br>or<br>kubectl create -f &lt;service-definition-file&gt;.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*U0VcZe7FDD71kOnitphl1w.png" /></figure><p><strong>3. After creating the pods and services, the status was checked using:</strong></p><pre>kubectl get pods<br>kubectl get services<br>or<br>kubectl get all</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*jwG_GWOweFAjGGZ1PTaccA.png" /></figure><h3>5. Test the Application</h3><p>To test the application, the URLs for the services were retrieved using:</p><pre>minikube service &lt;service-name&gt; --url</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*bdfhILWdrw0RnFxfMme8vA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*dWSNATQqsYwflqnlSjDYGA.png" /></figure><p><em>As observed in the accessible links above, the application is not reachable through the defined </em><strong><em>NodePorts</em></strong><em>. This occurs due to the networking configuration when using the </em><strong><em>Docker driver</em></strong><em> for Kubernetes.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vp1hJcmb_seZDdUSQTcXHw.png" /><figcaption>Voting-App</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gWU_dd-WwlASoN2gnRjsBg.png" /><figcaption>Result-App</figcaption></figure><h4><strong>In Part 2, we will explore how to convert the application into a deployment-based approach and discuss the rationale behind this transformation.</strong></h4><p><em>I hope this provided a clear understanding of the concept. Thank you!</em></p><p><em>Feel free to share any corrections or suggestions in the comments section; I welcome improvements.</em></p><p><strong><em>For more content related to the DevOps world, please follow me.</em></strong></p><p><em>Cheers , Happy Learning!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6031098ee3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Internal Architecture of Kubernetes]]></title>
            <link>https://medium.com/@buddhikagaveen2021/understanding-internal-architecture-of-kubernetes-4808d5f89e27?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/4808d5f89e27</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 11:26:43 GMT</pubDate>
            <atom:updated>2024-11-02T11:27:56.021Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTfCZQ2Ze1YgJSmoJADUpg.png" /></figure><p><em>Kubernetes is a powerful open-source, container orchestration system for running containerized applications in a distributed environment. It automates the deployment, scaling, and operations of application containers across clusters of hosts. Understanding the internal architecture of Kubernetes is important if one wants to successfully deploy and manage applications in a scalable fashion.</em></p><h3>Core Components of Kubernetes</h3><p>Kubernetes architecture is primarily comprised of two components:<br><strong>1. Control Plane/ Master Node — The overall cluster controller.<br>2. Data Plane/Worker Node— These are the components running on each Node that handle the individual containers.</strong></p><p>Each one has a unique responsibility in orchestrating and keeping the application workloads at their desired state. Let’s look deeper into each of these components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*Obsi2M9FF7Q2gUN_lMchuw.png" /><figcaption>k8 cluster</figcaption></figure><h3><strong>1. The Control Plane</strong></h3><p><em>This is the central decision maker of the Kubernetes cluster, which makes decisions concerning scheduling or manages the state of the cluster. It ensures that applications are running in a desired state and also covers the configuration, scaling, and deployment of applications. The main components of the Control Plane are:</em></p><p><strong>a. API Server (kube-apiserver)</strong></p><ul><li>The kube-apiserver represents the frontend of the Kubernetes Control Plane, being the central point that administrators and users interact with.</li><li>It processes all RESTful requests incoming either from the CLI or from other user interfaces and provides the Kubernetes API.</li><li>All the other components in Kubernetes communicate with each other through the API server.</li></ul><p><strong>b.etcd</strong></p><ul><li>Etcd: A distributed key-value store that Kubernetes uses to persist all cluster data, including configurations, statuses, and metadata.</li><li>This is the single source of truth for the current state of the cluster, and master components of Kubernetes write any changes to cluster resources to etcd.</li><li>Etcd is designed to be highly available and consistently store data through using consensus via Raft.</li></ul><p><strong>c. Scheduler (kube-scheduler)</strong></p><ul><li>The kube-scheduler schedules new workload objects, such as Pods, onto appropriate nodes based on the resources available, policy conformance, and other scheduling needs.</li><li>This involves quite a lot of factors, including but not limited to the CPU, memory, and affinity/anti-affinity requirements of the Pod, that go into deciding the best place for a pod to run.</li><li>Upon selecting a node, this scheduler relays the decision back to the API server, from where the process of creating the pod on the chosen node is started.</li></ul><p><strong>d. Controller Manager (kube-controller-manager)</strong></p><ul><li>The kube-controller-manager runs several controller threads, each of which is responsible to perform a specific task for making reality of the cluster resources align with the declared desire.</li><li>Important controllers include but are not limited to:<br>// <strong>Node Controller:</strong> It manages the state of the nodes and in case of node failure, it can report back.<br><strong>//Replication Controller:</strong> It ensures the right number of pod replicas is running.<br><strong>//Endpoint Controller:</strong> Maintains endpoint objects, populates those endpoint objects for a service, enabling a service to discover the available pods.<br><strong>//Service Account and Token Controller:</strong> It creates default accounts and API access tokens for new namespaces.</li></ul><p><strong>e. Cloud Controller Manager</strong></p><ul><li>If Kubernetes is deployed on a cloud (AWS, GCP, Azure), then the cloud-controller-manager enables the linkage to the underlying cloud platform in order to perform tasks such as load balancing, volume provisioning, and network route maintenance.</li><li>It enables the carrying out of activities which are cloud-specific, such as Dynamic volume provisioning and the creation of load balancers.</li></ul><h3>2. Worker Node</h3><p><em>Each Node or worker machine, in the Kubernetes cluster, runs a set of services that support the management of containerized applications. These components provide the possibility for the node to communicate with the Control Plane and to run application workloads and then resources monitoring.</em></p><p><strong>a. kubelet</strong></p><ul><li>kubelet is an agent running on each node, communicating with the Control Plane in order for the runtime of the containers as scheduled.</li><li>Accepts the API server instructions on deploying and managing containers, reporting on their status.</li><li>kubelet monitors the running pod for its status and updates the API server about any changes in pod status to catch the pod to the desired state.</li></ul><p><strong>b. kube-proxy</strong></p><ul><li>kube-proxy acts as a network proxy and maintains networking rules for each node. This allows pod communication both within and outside the node.</li><li>It does load balancing and IP forwarding for Kubernetes services by keeping track of the routing rules and sending the traffic to the right pod.</li><li>kube-proxy also supports multiple networking modes such as IPVS, IPTables, and userspace mode depending on the type of Kubernetes networking.</li></ul><p><strong>c. Container Runtime</strong><br> <br>The container runtime is responsible to run the containers on each node. Kubernetes has a number of container runtimes including Docker, containerd, and CRI-O.<br>The kubelet communicates with the container runtime to start, stop, and manage the containers in a healthy state, provided the declared intent from the Control Plane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*gDhMWPwpzOqKNCkJnfHaiA.png" /><figcaption>components of k8</figcaption></figure><h3><strong>3. Kubernetes Networking and Storage</strong></h3><p><em>Networking and storage are the two most important components of Kubernetes in terms of communication of pods and persistence storage in applications.</em></p><p><strong>Networking Model</strong></p><ul><li>Each pod can be given its own IP address, which makes communication between services in a cluster easier, without relying on NAT.</li><li>Services provide a consistent endpoint for reaching a set of pods to handle discovery and load balancing smoothly within the cluster.</li></ul><p><strong>Storage Solutions</strong></p><ul><li>Some of the supported storage types in Kubernetes include Persistent Volumes (PVs), Persistent Volume Claims (PVCs), and Storage Classes, which allow for dynamic provisioning of storage resources.</li><li>Integration of cloud providers and on-premises storage solutions allows Kubernetes to offer flexible and scalable storage options that guarantee an application retains data upon termination of pods.</li></ul><h3><strong>4. Kubernetes Objects and Workloads</strong></h3><p><em>Kubernetes exposes various abstractions called objects for orchestrating applications:</em></p><ol><li><strong>Pods :</strong> The basic execution unit in Kubernetes, a pod encapsulates one or more containers that share common networking and storage. Pods are ephemeral; if they die, they can be reconstituted.</li><li><strong>ReplicaSets :</strong> Ensure that a specified number of identical pod replicas are running at any given time. They provide replica redundancy and scaling.</li><li><strong>Deployments : </strong>Desirable state declarative updates to applications and also manage the roll-out and roll-back of changes.</li><li><strong>Services :</strong> A way to expose applications as network services internally and externally to a cluster, and balance incoming traffic accordingly.</li></ol><h3>5. Kubernetes Works: An Overview of the Workflow</h3><p><em>Deploying an application in Kubernetes can be simplified to an overall workflow where:</em></p><ol><li><strong>Deployment Creation:</strong> The developer creates a deployment configuration and sends it to the API server with details on the number of replicas, images, and environment details.</li><li><strong>Pods placement by Scheduler:</strong> The scheduler will place the pods on nodes based on resource requirements and policy constraints.</li><li><strong>kubelet Operates Pods:</strong> The kubelet on each node will speak with the container runtime to start the containers defined and ensure that they are healthy.</li><li><strong>Service and Networking:</strong> The networking rules were created by kube-proxy, and the Service object controls access to the pods so that consistent connectivity can be allowed.</li><li><strong>Controllers Maintain State:</strong> In case pods were to crash or nodes became unavailable, the controllers would do their work in recreating pods on those nodes that are available and making sure that your application is up and running.</li></ol><h3>Conclusion</h3><p><em>Kubernetes, designed for robustness, scalability, and self-healing, is separated into an internal architecture that runs from the Control Plane to the node components. Kubernetes abstracts the underlying complexities of the infrastructure to effectively manage the resources so that developers can focus on deploying and scaling applications. Knowing the inner details of how Kubernetes works will let you tap into its full potential for automating and orchestrating running containerized workloads in diverse environments.</em></p><p><em>I hope this provided a clear understanding of the concept. Thank you!</em></p><p><em>Feel free to share any corrections or suggestions in the comments section; I welcome improvements.</em></p><p><strong><em>For more content related to the DevOps world, please follow me.</em></strong></p><p><em>Cheers , Happy Learning!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4808d5f89e27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Secure Vehicle Reservation System: A Comprehensive Overview]]></title>
            <link>https://medium.com/@buddhikagaveen2021/building-a-secure-vehicle-reservation-system-a-comprehensive-overview-95975b992182?source=rss-ec1e56dce3f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/95975b992182</guid>
            <dc:creator><![CDATA[Gaveen Buddhika]]></dc:creator>
            <pubDate>Fri, 18 Oct 2024 14:23:20 GMT</pubDate>
            <atom:updated>2024-10-18T15:28:43.027Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqPTJl-Z7L9ZP8_26pgpvw.png" /></figure><p><strong>Developing a secure web application is a multifaceted task, especially when safeguarding it from prevalent OWASP Top 10 vulnerabilities. In this article, I will walk through my experience building a vehicle service reservation application with an emphasis on security features, authentication mechanisms, and access control measures.</strong></p><p><strong>Project Overview</strong></p><p>The vehicle reservation system was designed to help users reserve vehicles online. The core features include:</p><ul><li>User authentication and profile management</li><li>A reservation form to book vehicles</li><li>Viewing and managing reservations</li><li>Admin panel to manage reservations</li><li>Security features such as token-based authentication</li></ul><p>You can check out the project on my <a href="https://github.com/GaveenBuddhika/vehicle-reservation-app">GitHub repository</a>.</p><h4>Authentication and Security Considerations</h4><p>One of the most important aspects of the system was implementing secure user authentication and ensuring data privacy. I used <strong>Auth0</strong>, a third-party authentication service that provides a secure and scalable solution for handling user logins and managing sessions.</p><p>Authentication Protocols:</p><ul><li><strong>OAuth 2.0</strong>: For secure authorization, I leveraged OAuth 2.0. OAuth 2.0 is an authorization framework that allows third-party services to exchange tokens for user authentication securely. It supports various flows (like Implicit Flow and Authorization Code Flow) for different types of applications.</li><li><strong>JWT (JSON Web Tokens)</strong>: For session management, I used <strong>JWTs</strong>. This allowed secure communication between the frontend (React) and the backend (Node.js), ensuring that sensitive user data, such as email and name, remained private. The token generated after login is stored in the client’s local storage and used in subsequent requests to validate user sessions.</li></ul><p>Backend Security:</p><ul><li><strong>API Security</strong>: On the backend, I protected the endpoints by checking for the presence of a valid JWT token in the authorization header. This allowed the backend to validate user identities and perform different operations based on user roles (admin or regular user).</li><li><strong>CORS (Cross-Origin Resource Sharing)</strong>: I configured CORS in the backend to only allow requests from trusted origins, protecting the system from cross-site request forgery attacks.</li></ul><p>Database Security:</p><ul><li><strong>SQL Injection Prevention</strong>: I made sure that all user inputs were properly sanitized using prepared statements and ORM (Object Relational Mapping) to prevent SQL injection attacks. This is essential for preventing attackers from gaining unauthorized access to the database.</li><li><strong>Encryption</strong>: User passwords were hashed using <strong>bcrypt</strong>, a widely used encryption algorithm, ensuring that even if someone gains unauthorized access to the database, passwords remain secure.</li></ul><h4>Implementation Strategy</h4><p>The development of the system followed a clear strategy:</p><ol><li><strong>Frontend Development with React</strong>:</li></ol><ul><li>I built the frontend using <strong>React</strong> to offer a responsive and user-friendly interface. The application features a reservation form, user authentication, profile management, and a responsive dashboard.</li><li>I made use of <strong>React Router</strong> for routing and <strong>Axios</strong> for API communication with the backend.</li><li>The UI was styled with custom CSS following a simple yet visually appealing design pattern.</li></ul><p><strong>2. Backend Development with Node.js and Express</strong>:</p><ul><li>The backend was built using <strong>Node.js</strong> with the <strong>Express.js</strong> framework. It served as the main API that communicated with the frontend.</li><li>The backend handled user authentication, reservation management, and the creation of booking entries in the <strong>MySQL</strong> database.</li><li>I used <strong>MySQL</strong> to store user data, reservations, and other details. Data was structured in relational tables for easy querying.</li></ul><p><strong>3. Database with MySQL</strong>:</p><ul><li>The system uses <strong>MySQL</strong> as the relational database. I designed the schema to accommodate users, their reservations, and the vehicle information.</li><li>I utilized <strong>MySQL</strong> queries to retrieve and manipulate the data based on user requests and interactions with the system.</li></ul><h4>Challenges Faced</h4><p>While building the system, I encountered several challenges, including:</p><ol><li><strong>Managing Authentication Tokens</strong>:</li></ol><ul><li>Ensuring secure token storage and handling the authentication flow between the frontend and backend was tricky. Storing JWT tokens securely on the client-side (without exposing them to XSS attacks) required extra care.</li></ul><p><strong>2. CORS Configuration</strong>:</p><ul><li>Properly configuring CORS to restrict access to trusted origins was a challenge. It took several iterations to ensure that the API would only accept requests from the React frontend and block unauthorized attempts.</li></ul><p><strong>3. Database Integrity</strong>:</p><ul><li>Ensuring data integrity when users make reservations simultaneously was another challenge. To prevent race conditions and ensure consistency, I implemented necessary transactional controls in <strong>MySQL</strong> queries.</li></ul><p><strong>4. Cross-Component Communication</strong>:</p><ul><li>Handling communication between multiple components, especially when dealing with user authentication and session management, required careful handling of state in <strong>React</strong>.</li></ul><h4>Learning Outcomes</h4><ol><li><strong>Deep Understanding of Authentication Protocols</strong>:</li></ol><ul><li>Through this project, I gained hands-on experience in implementing <strong>OAuth 2.0</strong>, <strong>JWT</strong>, and <strong>Auth0</strong>. Understanding how tokens are issued, stored, and validated was a key learning outcome.</li></ul><p><strong>2. Database Management</strong></p><ul><li>I learned about designing database schemas for relational databases like <strong>MySQL</strong>, and how to effectively prevent SQL injection attacks through prepared statements and ORM.</li></ul><p><strong>3. Vulnerability Mitigation</strong>:</p><ul><li>Implementing protection against SQL injection and XSS required careful handling of user input and database interactions, offering hands-on experience in securing web applications.</li></ul><p><strong>4. Frontend &amp; Backend Communication</strong>:</p><ul><li>I honed my skills in building full-stack applications by managing data flow between the frontend and backend, handling user requests, and using RESTful API best practices.</li></ul><p><strong>5. Error Handling &amp; Debugging</strong>:</p><ul><li>Debugging and handling errors both on the client and server sides was another valuable experience. I learned how to effectively log errors, handle failed API requests, and provide feedback to users.</li></ul><h4>Conclusion</h4><p>Building the Vehicle Reservation System was an incredibly rewarding experience. From implementing authentication protocols like OAuth 2.0 and JWT to securing the backend with CORS, SQL Injection Prevention, and password hashing, the project provided deep insights into the challenges of building secure web applications.</p><p>This project enhanced my understanding of full-stack development, and I encourage you to explore it further by checking out the <a href="https://github.com/GaveenBuddhika/vehicle-reservation-app">GitHub repository</a>.</p><p><strong><em>Feel free to drop any questions in the comments, or let me know if you’d like further elaboration on any specific aspect!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95975b992182" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>