<?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 Akash Jaiswal on Medium]]></title>
        <description><![CDATA[Stories by Akash Jaiswal on Medium]]></description>
        <link>https://medium.com/@akashjoffical08?source=rss-db4dff553217------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zO3fbo9bDRdzsGtO4pfhLA.jpeg</url>
            <title>Stories by Akash Jaiswal on Medium</title>
            <link>https://medium.com/@akashjoffical08?source=rss-db4dff553217------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 16:47:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akashjoffical08/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[OmniRoute: One AI Gateway for 350+ AI Providers]]></title>
            <link>https://medium.com/@akashjoffical08/omniroute-one-ai-gateway-for-350-ai-providers-0e460364c985?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e460364c985</guid>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[omni-route]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Thu, 01 Oct 2026 16:08:54 GMT</pubDate>
            <atom:updated>2026-10-01T16:08:54.479Z</atom:updated>
            <content:encoded><![CDATA[<h4>AI-assisted development is becoming part of the everyday engineering workflow.Today, developers use tools like Claude Code, Cursor, Cline, Codex, and other AI-powered coding assistants. The problem is that each tool can end up requiring different API keys, providers, models, quotas, and configurations.</h4><p>Then comes the frustrating part:</p><p>You’re in the middle of a coding session, your provider hits a rate limit, and suddenly your workflow stops.</p><p>This is where OmniRoute becomes interesting.</p><p>OmniRoute is an open-source, MIT-licensed AI gateway that provides a single local endpoint in front of 350+ AI providers. Instead of configuring every AI tool separately, you can connect your providers to OmniRoute and let it handle routing and fallback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMDjX7FXJtPX0BQLrawZkA.png" /></figure><h3>The Problem: Too Many AI Providers</h3><p>A typical AI developer workflow might look like this:</p><ul><li>Claude for complex coding tasks</li><li>Gemini for large-context workloads</li><li>OpenAI for specific tasks</li><li>Local or free-tier models for experimentation</li><li>Another provider when the primary provider hits a quota</li><li>Multiple AI coding tools using different configurations</li></ul><p>Managing all of this manually becomes painful.</p><p>You end up managing:</p><ul><li>Multiple API keys</li><li>Different provider endpoints</li><li>Different model names</li><li>Rate limits</li><li>Provider quotas</li><li>Pricing differences</li><li>Configuration across multiple development tools</li></ul><p>OmniRoute puts a gateway in the middle.</p><p>Instead of:</p><p>AI Tool → Provider</p><p>You can have:</p><p>AI Tool → OmniRoute → Multiple AI Providers</p><p>That simple architecture can make multi-provider AI workflows much easier to manage.</p><h3>What Is OmniRoute?</h3><p>OmniRoute acts as a local AI gateway.</p><p>It exposes an OpenAI-compatible endpoint:</p><p><a href="http://localhost:20128/v1">http://localhost:20128/v1</a></p><p>Your AI coding tools communicate with this endpoint, while OmniRoute handles the provider routing behind it.</p><p>One endpoint can therefore be used across tools such as:</p><ul><li>Claude Code</li><li>Cursor</li><li>Cline</li><li>Codex</li><li>Other OpenAI-compatible applications</li></ul><p>The goal is simple:</p><p>One endpoint → Multiple providers → Automatic routing and fallback</p><h3>Key Features</h3><h3>1. One Endpoint for Multiple Providers</h3><p>Instead of configuring every AI tool with different provider endpoints, you can point your tools to OmniRoute.</p><p>This creates a consistent interface for your development environment.</p><h3>2. Automatic Fallback</h3><p>One of the most useful capabilities is provider fallback.</p><p>If a configured provider reaches its quota, encounters a rate limit, or becomes unavailable, OmniRoute can route the request to another healthy provider.</p><p>You can use the auto model configuration to allow OmniRoute to handle the routing.</p><p>This is particularly useful during long coding sessions where hitting a provider limit can interrupt your workflow.</p><h3>3. Multiple Provider Strategy</h3><p>You don’t have to depend entirely on a single AI provider.</p><p>You can configure multiple providers and use them through the same gateway.</p><p>This gives you flexibility to experiment with different models and providers without changing the configuration of every individual AI tool.</p><h3>4. Token Compression</h3><p>Long conversations and large codebases can quickly consume context and token limits.</p><p>OmniRoute includes token compression capabilities that can help reduce token consumption and keep requests within provider limits.</p><p>For developers working with large repositories or long-running AI sessions, this can be particularly useful.</p><h3>5. Local-First Architecture</h3><p>Another interesting aspect is the local-first approach.</p><p>Your AI tools communicate with your local OmniRoute instance, and your provider credentials can remain on your machine rather than being managed separately by every coding tool.</p><p>For engineering teams, this can simplify credential management and reduce configuration sprawl.</p><h3>6. Usage and Provider Dashboard</h3><p>OmniRoute also provides a dashboard where you can monitor things such as:</p><ul><li>Provider usage</li><li>Provider health</li><li>Usage patterns</li><li>Savings</li><li>Routing activity</li></ul><p>This becomes useful when you’re using multiple providers and want visibility into how your AI infrastructure is actually being used.</p><h3>Practical Use Cases</h3><p>The real value of OmniRoute isn’t just the number of supported providers.</p><p>The interesting part is how you can use it in an engineering workflow.</p><h3>Use Case 1: AI Coding Assistants</h3><p>Imagine your team uses multiple AI coding tools.</p><p>Instead of configuring every tool individually:</p><p>Cursor → Provider A</p><p>Claude Code → Provider B</p><p>Cline → Provider C</p><p>You can have:</p><p>Cursor ─┐<br>Claude ─┼→ OmniRoute → Multiple Providers<br>Cline ──┘</p><p>This gives your development environment a consistent AI endpoint.</p><h3>Use Case 2: Rate-Limit Protection</h3><p>You’re working on a large feature and your AI provider suddenly returns:</p><p>Rate limit exceeded.</p><p>Without a fallback mechanism, your workflow stops.</p><p>With multiple providers configured behind OmniRoute, the gateway can route the request to another available provider.</p><p>This can be particularly useful during intensive coding sessions.</p><h3>Use Case 3: Experimenting With Different Models</h3><p>AI models evolve quickly.</p><p>You may want to test different providers without constantly changing your IDE configuration.</p><p>With OmniRoute, your AI tool continues communicating with the same local endpoint while you experiment with different providers behind the gateway.</p><p>This makes model experimentation much easier.</p><h3>Use Case 4: Development and Prototyping</h3><p>For developers experimenting with AI applications, having access to multiple providers through a single interface can significantly reduce setup time.</p><p>Instead of rewriting integrations for every provider, you can use the gateway as a common interface.</p><p>This can be useful when evaluating:</p><ul><li>Different LLM providers</li><li>Different model capabilities</li><li>Free-tier providers</li><li>Provider reliability</li><li>Context limits</li><li>Cost differences</li></ul><h3>Use Case 5: Team Developer Experience</h3><p>For engineering teams, AI configuration can become another piece of developer environment management.</p><p>Instead of asking every engineer to configure multiple providers independently, you can establish a standardized AI gateway approach.</p><p>The developer experience becomes:</p><p>Install OmniRoute → Configure providers → Point AI tools to one endpoint.</p><p>That is much simpler than maintaining provider configuration across every individual tool.</p><h3>Use Case 6: Cost and Usage Visibility</h3><p>When you use several AI providers, understanding where your usage is going becomes important.</p><p>A centralized gateway gives you a place to observe provider usage and understand which providers are being used most frequently.</p><p>This can help teams make more informed decisions around AI usage and provider selection.</p><h3>Getting Started</h3><p>Running OmniRoute locally is straightforward.</p><h3>Option 1: Install With npm</h3><p>Install OmniRoute:</p><pre>npm install -g omniroute</pre><p>Then start it:</p><pre>omniroute</pre><p>Once running, your local endpoint is available at:</p><pre>http://localhost:20128/v1</pre><p>You can then configure your AI coding tool to use this endpoint and set the model to:</p><pre>auto</pre><h3>Option 2: Docker Compose</h3><p>If you prefer containers, you can run the stack using Docker Compose.</p><p>Clone the repository:</p><pre>git clone https://github.com/diegosouzapw/OmniRoute.git</pre><p>Move into the directory:</p><pre>cd OmniRoute</pre><p>Create your environment file:</p><pre>cp .env.example .env</pre><p>Start the base profile:</p><pre>docker compose --profile base up -d</pre><p>After that, configure your AI coding tool to communicate with:</p><pre>http://localhost:20128/v1</pre><p>and use:</p><pre>auto</pre><p>as the model.</p><h3>A Simple Architecture</h3><p>At a high level, the workflow looks like this:</p><pre>                  ┌─────────────────┐<br>                  │   Cursor        │<br>                  ├─────────────────┤<br>                  │   Claude Code   │<br>                  ├─────────────────┤<br>                  │   Cline         │<br>                  ├─────────────────┤<br>                  │   Codex         │<br>                  └────────┬────────┘<br>                           │<br>                           ▼<br>                  ┌─────────────────┐<br>                  │    OmniRoute    │<br>                  │  Local Gateway  │<br>                  └────────┬────────┘<br>                           │<br>             ┌─────────────┼─────────────┐<br>             ▼             ▼             ▼<br>        Provider A     Provider B     Provider C<br>             │             │             │<br>             └─────────────┼─────────────┘<br>                           ▼<br>                    Automatic Routing<br>                    &amp; Provider Fallback</pre><p>The important idea is that your development tools don’t need to know about every provider.</p><p>They communicate with one gateway.</p><h3>Why This Is Interesting for DevOps and Platform Engineers</h3><p>From a DevOps or Platform Engineering perspective, the architecture is particularly interesting.</p><p>We’re already used to putting abstraction layers in front of infrastructure:</p><p>Load Balancer → Multiple application instances</p><p>API Gateway → Multiple backend services</p><p>Service Mesh → Multiple services</p><p>CI/CD Platform → Multiple deployment targets</p><p>OmniRoute applies a similar concept to AI providers:</p><p>AI Tools → AI Gateway → Multiple LLM Providers</p><p>This creates an abstraction layer between developers and the underlying AI infrastructure.</p><p>As AI becomes another component of the developer platform, concepts such as routing, fallback, observability, cost management, and provider resilience become increasingly relevant.</p><h3>Things to Consider</h3><p>OmniRoute can simplify multi-provider AI workflows, but there are still things to evaluate before using it broadly across a team.</p><p>Consider:</p><ul><li>Provider pricing and quotas</li><li>Model compatibility</li><li>Context-window differences</li><li>Data/privacy requirements</li><li>Provider-specific capabilities</li><li>Reliability of fallback providers</li><li>Credential management</li><li>Organizational security policies</li></ul><p>Automatic fallback also doesn’t mean that every provider is interchangeable. Different models can produce different results, latency, context limits, and tool-calling behavior.</p><p>So routing should be treated as an engineering decision rather than simply assuming all models are equivalent.</p><h3>Final Thoughts</h3><p>AI development is moving toward a multi-provider world.</p><p>Instead of depending on a single model or provider, developers increasingly have access to a large ecosystem of models with different capabilities, pricing, limits, and performance characteristics.</p><p>The challenge is managing that complexity.</p><p>That’s where an AI gateway like OmniRoute can be useful.</p><p>The concept is simple:</p><p>One endpoint.</p><p>Multiple providers.</p><p>Automatic fallback.</p><p>Centralized configuration.</p><p>Better visibility.</p><p>Less key management.</p><p>For developers and platform teams experimenting with AI-heavy workflows, OmniRoute is an interesting open-source project to explore.</p><h4>GitHub:</h4><h4><a href="https://github.com/diegosouzapw/OmniRoute">https://github.com/diegosouzapw/OmniRoute</a></h4><p>If you’re already using multiple AI coding tools or providers, the bigger question isn’t just which model you’re using.</p><p>It’s how you’re managing the AI layer behind your engineering workflow.</p><p>#AI #OpenSource #LLM #DeveloperTools #DevOps #PlatformEngineering #DeveloperExperience #AIEngineering #Coding</p><h4>Reference:</h4><ul><li><a href="https://www.omniroute.online/">OmniRoute by Cheaper Inference | #1 Open Source AI Router</a></li><li><a href="https://github.com/diegosouzapw/OmniRoute">GitHub - diegosouzapw/OmniRoute: Never stop coding. Free MIT AI gateway: one endpoint, 359 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline &amp; Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by hundreds of contributors</a></li></ul><p><a href="https://www.reddit.com/r/opencodeCLI/comments/1shzxyw/omniroute_opensource_ai_gateway_that_pools_all/">https://www.reddit.com/r/opencodeCLI/comments/1shzxyw/omniroute_opensource_ai_gateway_that_pools_all/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e460364c985" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Automating Password Rotation on AWS Secrets Manager with EventBridge & SSM Documents]]></title>
            <link>https://medium.com/@akashjoffical08/automating-password-rotation-on-aws-secrets-manager-with-eventbridge-ssm-documents-a25065369f1e?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/a25065369f1e</guid>
            <category><![CDATA[aws-eventbridge]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[secretes]]></category>
            <category><![CDATA[aws-system-manager]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Mon, 10 Nov 2025 11:19:07 GMT</pubDate>
            <atom:updated>2025-11-10T11:19:26.732Z</atom:updated>
            <content:encoded><![CDATA[<p>Managing secrets securely is a fundamental pillar of DevOps and cloud security. But storing passwords safely is only half the story — <strong>rotating them automatically</strong> is what ensures continuous protection against potential misuse or credential leaks.</p><p>Recently, I automated <strong>password rotation</strong> for an application running across multiple EC2 instances using <strong>AWS Secrets Manager</strong>, <strong>EventBridge</strong>, and <strong>AWS Systems Manager (SSM)</strong> — no manual intervention needed.<br> This post breaks down how I achieved it.</p><h3>🎯 The Problem</h3><p>We had an application whose credentials were stored in <strong>AWS Secrets Manager</strong> and consumed by multiple EC2 instances.</p><p>The challenges:</p><ul><li>The same password was used across multiple application instances.</li><li>Password updates were manual and inconsistent.</li><li>Post-update sync between Secrets Manager and EC2 was prone to delay.</li><li>Security policies mandated <strong>automatic password rotation</strong> every X days.</li></ul><p>The goal was simple:</p><blockquote><em>“Whenever the secret rotates in AWS Secrets Manager, automatically push the updated password to all EC2 instances where the application is running.”</em></blockquote><h3>The Solution — Automation with AWS EventBridge + SSM Documents</h3><p>To automate the end-to-end flow, I designed the following architecture:</p><h3>🏗️ Architecture Overview</h3><p><strong>1 .AWS Secrets Manager</strong> — holds the application password.</p><p><strong>2. EventBridge Rule</strong> — listens for secret rotation events.</p><p><strong>3. AWS Systems Manager (SSM) Document</strong> — runs commands on EC2 instances to update the application with the new password.</p><p>4. <strong>IAM Roles and Permissions</strong> — allow secure interaction between EventBridge, SSM, and EC2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7VNcB1KlPW4rJGA3h7ckFQ.png" /><figcaption>Automation with AWS EventBridge + SSM Documents</figcaption></figure><h3>🛠️ Implementation Steps</h3><h3>Step 1: Configure the EventBridge Rule</h3><p>You need an EventBridge rule to listen for the specific event that signals a successful secret rotation.</p><ul><li><strong>Service:</strong> Amazon EventBridge</li><li><strong>Event Source:</strong> AWS Services</li><li><strong>Service Name:</strong> Secrets Manager</li><li><strong>Event Type:</strong> AWS API Call via CloudTrail or AWS Service Event via CloudTrail</li><li><strong>Event Pattern:</strong> Use a pattern to match successful rotation events for your specific secret.</li></ul><p>A good event pattern to match successful rotation:</p><pre>{<br>  &quot;source&quot;: [&quot;aws.secretsmanager&quot;],<br>  &quot;$or&quot;: [{<br>    &quot;detail-type&quot;: [&quot;AWS API Call via CloudTrail&quot;]<br>  }, {<br>    &quot;detail-type&quot;: [&quot;AWS Service Event via CloudTrail&quot;]<br>  }],<br>  &quot;detail&quot;: {<br>    &quot;eventSource&quot;: [&quot;secretsmanager.amazonaws.com&quot;],<br>    &quot;eventName&quot;: [&quot;RotationSucceeded&quot;, &quot;PutSecretValue&quot;, &quot;UpdateSecret&quot;],<br>    &quot;requestParameters&quot;: {<br>       &quot;secretId&quot;: [&quot;arn:aws:secretsmanager:REGION:ACCOUNT_ID:secret:YOUR_SECRET_NAME-XXXXXX&quot;]    }<br>  }<br>}</pre><p><strong>Note:</strong> Replace REGION, ACCOUNT_ID, and the ARN with your actual secret details. The The RotationSucceeded event is key, but including PutSecretValue and UpdateSecret covers manual updates too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oTlhbB0p-7x85LiVOXv7dA.png" /><figcaption>Create EventBridge Rule</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AFeF7Wt_Bmkb5vxBpaa31g.png" /><figcaption>Add Rule Pattern</figcaption></figure><h3>Step 2: Set Up the EC2 Instance for SSM</h3><p>To run a script on your EC2 instance from AWS services, you must use <strong>AWS Systems Manager (SSM)</strong>.</p><ol><li><strong>Install/Verify SSM Agent:</strong> Ensure the <strong>SSM Agent</strong> is installed and running on your EC2 instance. Most modern Amazon Machine Images (AMIs) come with it pre-installed.</li><li><strong>IAM Role:</strong> Attach an <strong>IAM Instance Profile</strong> (role) to your EC2 instance with the <strong>AmazonSSMManagedInstanceCore</strong> policy. This gives the SSM Agent the necessary permissions to communicate with the Systems Manager service.</li></ol><h3>Step 3: Create the SSM Run Command Document (Optional but Recommended)</h3><p>For an organized approach, define your script logic in an <strong>SSM Document</strong>. This makes the script reusable and easy to manage.</p><ol><li>Navigate to <strong>AWS Systems Manager</strong> -&gt; <strong>Documents</strong>.</li><li>Choose <strong>Create document</strong> -&gt; <strong>Command document</strong>.</li><li>Define a document (e.g., using AWS-RunShellScript) that contains the script you want to execute on the EC2 instance (e.g., a script to restart your application or fetch the new secret).</li><li>Document version look as below:</li></ol><pre>---<br>schemaVersion: &quot;2.2&quot;<br>description: &quot;Rotate hue Cred for Test Application&quot;<br>parameters:<br>  Message:<br>    type: &quot;String&quot;<br>    description: &quot;Example&quot;<br>    default: &quot;Hello World&quot;<br>mainSteps:<br>- action: &quot;aws:runShellScript&quot;<br>  name: &quot;roatatepassword&quot;<br>  inputs:<br>    #rotate-cred-for-apps.sh is already present on Target ec2,which get ASM from secrete &amp; restart application<br>    runCommand:<br>    - &quot;sudo sh /tmp/rotate-cred-for-apps.sh&quot;</pre><p>5. Configure EventBridge Target</p><p>The target of your EventBridge rule will be an <strong>SSM Run Command</strong> task.</p><h3>Step 4. Configure EventBridge Target</h3><p>The target of your EventBridge rule will be an <strong>SSM Run Command</strong> task.</p><ol><li>In the EventBridge rule you created in step 1, select <strong>AWS Service</strong> as the target.</li></ol><p>2. For the <strong>Target Type</strong>, choose <strong>Systems Manager RunCommand</strong>.</p><p>3.For <strong>Document</strong>, select the <strong>SSM Document</strong> you created in step 3 (or use a built-in one like AWS-RunShellScript).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_CzWepmBWG5RXYyQiMMy9g.png" /></figure><p>4. Specify the <strong>Target EC2 instances</strong> by using an <strong>Tag</strong> or, preferably, <strong>Tags</strong> to ensure the command runs on the correct instance(s).<br>In the <strong>Configure parameters</strong> section, you can pass parameters to your script if needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47pkvS_jg0U2SgTUA6i0EA.png" /></figure><p>5. Update Policy for IAM attached to Event Bridge Rule:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Action&quot;: &quot;ssm:SendCommand&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:ec2:ap-south-1:XXXXXXXXXXX:instance/*&quot;<br>            ],<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;ec2:ResourceTag/*&quot;: [<br>                        &quot;target-ec2-&quot;<br>                    ]<br>                }<br>            }<br>        },<br>        {<br>            &quot;Sid&quot;: &quot;SSMAccess&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ssm:SendCommand&quot;,<br>                &quot;ssm:StartAutomationExecution&quot;,<br>                &quot;ssm:GetAutomationExecution&quot;,<br>                &quot;ec2:DescribeInstanceStatus&quot;,<br>                &quot;ec2:DescribeInstances&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Action&quot;: &quot;ssm:SendCommand&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:ssm:ap-south-1::document/AWS-RunDocument&quot;,<br>                &quot;arn:aws:ssm:ap-south-1:*:document/roatate-cred-aws-secrete-apps&quot;<br>                        ]<br>        },<br>        {<br>            &quot;Action&quot;: [<br>                &quot;ssm:StartAutomationExecution&quot;<br>            ],<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:ssm:ap-south-1:XXXXXXXXXXX:automation-definition/event-bridege-rule-name:*&quot;<br>            ]<br>        }<br>    ]<br>}</pre><h3>Step 5: End-to-End Testing Steps</h3><ol><li><strong>Update the secret</strong> in AWS Secrets Manager — this action will automatically trigger the <strong>EventBridge rule</strong>.</li><li><strong>Verify the SSM Document execution</strong> — check the latest run in the Systems Manager console to ensure it executed successfully.</li><li><strong>Validate the application behavior</strong> — confirm that the application fetched the updated credentials from Secrets Manager and that the service restarted as expected.</li></ol><h3>💡 Key Takeaways</h3><p>Automating secret rotation isn’t just about compliance — it’s about building <strong>secure and self-healing systems</strong>.<br> AWS provides all the building blocks — <strong>Secrets Manager</strong>, <strong>EventBridge</strong>, and <strong>SSM</strong> — to achieve this in a modular and scalable way.</p><p>As a DevOps engineer, this kind of automation not only saves time but ensures that your environments remain secure by design.</p><p>Thanks to Reading! Please open for Feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a25065369f1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Level Up Your Node.js]]></title>
            <link>https://medium.com/@akashjoffical08/level-up-your-node-js-2d03c3a5dd96?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d03c3a5dd96</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[pm2]]></category>
            <category><![CDATA[aws-eks]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 06:43:55 GMT</pubDate>
            <atom:updated>2025-07-30T06:43:55.801Z</atom:updated>
            <content:encoded><![CDATA[<h3>Level Up Your Node.js Deployments: Why PM2 is Your Production Superpower (and npm start isn&#39;t enough)</h3><h3>Running Your Node.js Applications in Containerized Production</h3><p>If you’re running Node.js applications, chances are you’ve used npm start to get things going. It&#39;s fantastic for development – quick, easy, and gets your app spinning. But when it comes to deploying to production, whether on bare metal, VMs, or especially within containers like Docker or Kubernetes, npm start quickly reveals its limitations.</p><p>This is where <strong>PM2</strong> (Process Manager 2) and its specialized variant, <strong>pm2-runtime</strong>, come into play. Let&#39;s dive into why these tools are indispensable for any serious Node.js deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ldrN2T_vlVnhoV9GKMoceg.png" /></figure><h3>The Command That Unlocks Production Power</h3><p>Consider this command, often seen in production-ready Node.js setups:</p><pre>pm2-runtime start -i $NUM_CORES dist/main.js --name app-name</pre><p>This single line is doing a lot of heavy lifting for your application:</p><ul><li><strong>pm2-runtime</strong>: This isn&#39;t just regular PM2. It&#39;s a version specifically optimized for <strong>container environments</strong>. It ensures your Node.js app gracefully handles container lifecycle events (like shutdown signals) and plays nicely with the container&#39;s process management.</li><li><strong>start</strong>: Tells PM2 to launch your application.</li><li><strong>-i $NUM_CORES (Cluster Mode)</strong>: This is the game-changer for Node.js. Node.js is inherently single-threaded. By using $NUM_CORES (typically set to the number of CPU cores available), PM2 automatically forks your application into multiple instances, one per core.<br>This allows your app to:<br><strong>a. Utilize all CPU power</strong>: Distribute the workload across all available processors.<br><strong>b. Boost throughput</strong>: Handle significantly more concurrent requests.<br><strong>c. Improve resilience</strong>: If one instance crashes, others keep serving traffic, and PM2 will automatically restart the crashed one.</li><li><strong>dist/main.js</strong>: Your compiled Node.js application entry point.</li><li><strong>--name app-name</strong>: Assigns a human-readable name, making it easy to monitor and manage your application processes with PM2.</li></ul><h3>Why PM2 Reigns Supreme Over npm start in Production</h3><p>While npm start is a trusty steed for development, it&#39;s a pony in a horse race when it comes to production demands. Here’s why PM2 is the thoroughbred:</p><ul><li><strong>Automatic High Availability (Self-Healing):</strong></li><li><strong>npm start</strong>: Your app crashes, it&#39;s down. Period.</li><li><strong>PM2</strong>: Automatically detects crashes and immediately restarts your application. It acts as a vigilant guardian, ensuring maximum uptime.</li></ul><p><strong>Unlocking Multi-Core Performance (Scalability):</strong></p><ul><li><strong>npm start</strong>: Your Node.js app runs on a single CPU core, no matter how many are available. This leaves significant computing power on the table.</li><li><strong>PM2</strong>: Its “Cluster Mode” (-i &lt;instances&gt;) allows you to effortlessly launch multiple instances of your Node.js app, distributing incoming load across all available CPU cores. This dramatically increases throughput and responsiveness.</li></ul><p><strong>Robust Process Management:</strong></p><ul><li><strong>npm start</strong>: No built-in way to manage processes beyond manually stopping and restarting.</li><li><strong>PM2</strong>: Provides a comprehensive CLI for starting, stopping, restarting (even zero-downtime reloads!), listing, and deleting applications. It ensures your app runs persistently, even surviving server reboots.</li><li><strong>Centralized Monitoring &amp; Logging:</strong></li><li><strong>npm start</strong>: Logs just stream to your console, making management difficult in production.</li><li><strong>PM2</strong>: Collects logs from all instances, centralizes them, and offers features like log rotation to prevent disk space issues. It also provides real-time monitoring of CPU, memory, and requests, giving you critical insights into your application’s health.</li></ul><p><strong>Graceful Shutdowns (Crucial for Data Integrity):</strong></p><ul><li><strong>npm start</strong>: Can abruptly terminate, potentially leaving connections open or data unsaved.</li><li><strong>pm2-runtime</strong>: Designed to handle OS signals gracefully, giving your Node.js application time to close database connections, save state, and clean up before shutting down, reducing the risk of data corruption.</li></ul><h3>Conclusion :</h3><p>For any Node.js application moving beyond development into a <strong>containerized production environment</strong> — whether on Docker, Kubernetes, or other platforms — embracing PM2 (or pm2-runtime) isn&#39;t just a recommendation; it&#39;s a necessity. It transforms your basic Node.js process into a resilient, performant, and easily manageable service.</p><p>Stop leaving performance and reliability on the table. Make PM2 your standard for Node.js deployments and experience the difference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d03c3a5dd96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smooth Exits: Achieving Graceful EC2 Termination with Aws CodeDeploy and ASG Hooks]]></title>
            <link>https://medium.com/@akashjoffical08/smooth-exits-achieving-graceful-ec2-termination-with-aws-codedeploy-and-asg-hooks-3b8919e16173?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b8919e16173</guid>
            <category><![CDATA[codedeploy]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[aws-asg]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 07:33:20 GMT</pubDate>
            <atom:updated>2025-07-07T07:33:20.005Z</atom:updated>
            <content:encoded><![CDATA[<p>When your application scales down, terminating EC2 instances abruptly can lead to interrupted user sessions, data loss, or incomplete processes. This blog post will show you how to leverage AWS Auto Scaling Group (ASG) lifecycle hooks with AWS CodeDeploy to achieve graceful termination, ensuring your applications shut down cleanly before instances are removed.</p><p>We’ll focus on enabling the termination hook specifically to run your CodeDeploy ApplicationStop lifecycle event, assuming you already have CodeDeploy and an ASG set up.</p><h3>Why Graceful Termination Matters</h3><p>Imagine a user submitting an order on your e-commerce site, and just as the transaction is processing, the EC2 instance handling it is terminated. This results in a failed order and a frustrated customer. Graceful termination allows your application to:</p><ul><li><strong>Complete ongoing tasks:</strong> Finish processing requests, flush caches, or close database connections.</li><li><strong>Drain connections:</strong> Remove the instance from load balancer target groups, allowing existing connections to finish before new ones are routed elsewhere.</li><li><strong>Perform cleanup:</strong> Save unsaved data, upload logs, or de-register from external services.</li><li><strong>Prevent data corruption:</strong> Ensure no data is lost or corrupted due to an abrupt shutdown.</li></ul><p>AWS Auto Scaling Groups provide lifecycle hooks that pause an instance during scaling events, giving you a window to perform these critical actions. CodeDeploy can then utilize these hooks to execute specific scripts from your AppSpec file, such as the ApplicationStop hook.</p><h3>Understanding the Workflow: CodeDeploy and ASG Termination Hooks</h3><p>Here’s how the graceful termination process will work:</p><ol><li><strong>Scale-In Event:</strong> Your ASG determines it needs to terminate an instance (e.g., due to reduced load or a health check failure).</li><li><strong>EC2_INSTANCE_TERMINATING Hook:</strong> Instead of immediately terminating, the ASG places the instance in a Terminating:Wait state and triggers a EC2_INSTANCE_TERMINATING lifecycle hook. This hook sends a notification (typically to an SQS queue or SNS topic, which CodeDeploy monitors).</li><li><strong>CodeDeploy Intervention:</strong> CodeDeploy, which is integrated with your ASG’s deployment group, recognizes this termination event. It then initiates a “termination deployment” specifically for that instance.</li><li><strong>ApplicationStop Hook Execution:</strong> As part of this termination deployment, CodeDeploy executes the ApplicationStop lifecycle hook defined in your application&#39;s appspec.yml file. This is where your custom graceful shutdown script will run.</li><li><strong>Heartbeat and Completion:</strong> While your ApplicationStop script is running, CodeDeploy sends heartbeats to the ASG to keep the instance in the Terminating:Wait state. Once your script finishes its graceful shutdown logic, CodeDeploy signals the ASG to continue the termination process.</li><li><strong>Instance Termination:</strong> The ASG receives the continue signal and proceeds to terminate the EC2 instance.</li></ol><p><strong>Diagram: Graceful Termination Flow</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBfsDG2dbiQX35BY4ESJMQ.png" /></figure><h3>Steps to Enable Termination Hook with CodeDeploy in an Existing ASG</h3><p>Since you already have CodeDeploy set up and your ASG in place, we’ll focus on the specific configuration changes required.</p><h4>Prerequisites:</h4><ul><li>An existing AWS CodeDeploy application and deployment group.</li><li>An existing Auto Scaling Group associated with your CodeDeploy deployment group.</li><li>The EC2 instances in your ASG have the CodeDeploy agent installed and running, and the instance IAM role has the necessary permissions for CodeDeploy.</li><li>Your appspec.yml file defines an ApplicationStop hook.</li></ul><h4>Step 1: Ensure your appspec.yml has the ApplicationStop hook</h4><p>Your appspec.yml file, located at the root of your application revision, is crucial. It defines the lifecycle events and the scripts to run for each. For graceful termination, the ApplicationStop hook is what you&#39;ll utilize.</p><p>Here’s an example of what your appspec.yml might look like:</p><pre>version: 0.0<br>os: linux<br><br>file_exists_behavior: OVERWRITE<br><br>hooks:<br>  AfterInstall:<br>    - location: startUp.sh<br>      timeout: 300<br>      runas: root<br>  ApplicationStop:<br>    - location: stop_application.sh<br>      timeout: 300<br>      runas: root</pre><p><strong>Important Note:</strong> The timeout for your ApplicationStop hook is critical. This defines how long CodeDeploy will wait for your script to complete before it considers the hook failed. Ensure this timeout is sufficient for your application to shut down gracefully. The lifecycle hook itself also has a HeartbeatTimeout that defaults to 1 hour, which gives you ample time, but your ApplicationStop timeout should be realistic for your application&#39;s shutdown needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*qMmIYQ_Ttsf9yj1IMUvXiQ.png" /><figcaption>ApplicationStop Worksflow</figcaption></figure><h4>Step 2: Create or Update your stop_application.sh script</h4><p>This is the script that will perform your graceful termination logic. It should be located at the path specified in your appspec.yml (e.g., stop_application.sh).</p><p>The provided script snippet is a good starting point to conditionally run your stop logic only during ASG termination events only:</p><pre>#!/bin/bash<br><br># Get the deployment type from CodeDeploy environment variable<br># https://aws.amazon.com/blogs/devops/using-codedeploy-environment-variables/<br>DeploymentType=$(aws deploy get-deployment --deployment-id &quot;${DEPLOYMENT_ID}&quot; --query &#39;deploymentInfo.creator&#39; --output text --region YOUR_AWS_REGION)<br><br>echo &quot;CodeDeploy Deployment Type: ${DeploymentType}&quot;<br><br># Stop the service only if the deployment is triggered by autoscaling termination<br>if [ &quot;${DeploymentType}&quot; = &quot;autoscalingTermination&quot; ]; then<br>  echo &quot;Initiating graceful shutdown for autoscaling termination...&quot;<br>  # Replace the following lines with your actual application shutdown commands<br>  # Example for a Node.js application running with PM2:<br>  # pm2 stop my-node-app<br>  # pm2 save<br><br>  # Example for a Java application running as a systemd service:<br>  # sudo systemctl stop my-java-app<br><br>  # Example for a web server like Nginx (optional, depending on your setup)<br>  # sudo systemctl stop nginx<br><br>  # Add any other cleanup or data flushing commands here<br>  echo &quot;Application graceful shutdown complete.&quot;<br>else<br>  echo &quot;Deployment is not an autoscaling termination. Skipping graceful shutdown.&quot;<br>fi<br><br>exit 0 # It&#39;s important to exit with 0 for success</pre><p><strong>Key Points for your </strong><strong>stop_application.sh script:</strong></p><ul><li><strong>DeploymentType=$(aws deploy get-deployment ...):</strong> This command retrieves information about the current CodeDeploy deployment. Specifically, it extracts the creator field.</li><li><strong>&quot;autoscalingTermination&quot;:</strong> CodeDeploy sets the creator to autoscalingTermination when a deployment is initiated by an Auto Scaling Group&#39;s termination lifecycle hook. This allows you to differentiate between a regular deployment (e.g., user-initiated, CodePipeline) and a termination event.</li><li><strong>Replace Placeholder Commands:</strong> The commented-out lines are placeholders. <strong>You MUST replace them with the actual commands to gracefully stop your specific application.</strong> This could involve stopping a web server, a background process, draining connections from a load balancer (though CodeDeploy usually handles deregistration), or any other cleanup.</li><li><strong>Error Handling:</strong> While not explicitly shown, consider adding robust error handling within your script to ensure it exits gracefully even if a command fails.</li><li><strong>Permissions:</strong> Ensure the IAM role attached to your EC2 instances has permissions to call aws deploy get-deployment.</li></ul><h4>Step 3: Enable the Termination Hook in your CodeDeploy Deployment Group</h4><p>This is the crucial step that connects your ASG’s termination events to CodeDeploy. You’ll enable the termination hook setting in your CodeDeploy deployment group.</p><p><strong>Using the AWS Management Console:</strong></p><ol><li>Navigate to the <strong>AWS CodeDeploy</strong> console.</li><li>In the left navigation pane, choose <strong>Applications</strong>.</li><li>Select your application, then choose your <strong>Deployment group</strong>.</li><li>Click on <strong>Edit</strong> for your deployment group.</li><li>Scroll down to the <strong>Advanced</strong> section.</li><li>Expand <strong>Deployment settings</strong>.</li><li>Look for the <strong>“Enable termination hooks”</strong> checkbox. <strong>Check this box.</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*JzIvGtcCAPbVvq7n8eMqTg.png" /></figure><p>8. Save the changes to your deployment group.</p><p><strong>Using the AWS CLI:</strong></p><p>You can update your existing deployment group to enable the termination hook:</p><pre>aws deploy update-deployment-group \<br>    --application-name YourApplicationName \<br>    --current-deployment-group-name YourDeploymentGroupName \<br>    --auto-scaling-groups &#39;[&quot;YourAutoScalingGroupName&quot;]&#39; \<br>    --ec2-tag-filters &#39;[{&quot;Key&quot;:&quot;Name&quot;,&quot;Value&quot;:&quot;YourInstanceTag&quot;,&quot;Type&quot;:&quot;KEY_AND_VALUE&quot;}]&#39; \<br>    --termination-hook-enabled</pre><h3>Testing Your Graceful Termination</h3><p>To test your setup, initiate a scale-in event on your Auto Scaling Group:</p><ol><li><strong>Manually reduce desired capacity:</strong> In the ASG console, reduce the “Desired capacity” of your ASG by one or more instances.</li><li><strong>Monitor CodeDeploy deployments:</strong> Go to the CodeDeploy console and observe the deployments. You should see a new deployment triggered with the Creator as autoscalingTermination.</li><li><strong>Check instance logs:</strong> During the Terminating:Wait state (visible in the ASG&#39;s &quot;Instances&quot; tab), log into the instance that is being terminated. Check the CodeDeploy agent logs (/var/log/aws/codedeploy-agent/codedeploy-agent.log on Linux) to confirm that your ApplicationStop script is executing and performing the intended shutdown.</li><li><strong>Verify application behavior:</strong> If your application exposes metrics or logs, verify that it is shutting down gracefully and not abruptly.</li></ol><h3>Conclusion</h3><p>By integrating AWS CodeDeploy with Auto Scaling Group termination hooks, you can ensure your applications shut down cleanly and gracefully when instances are terminated due to scale-in events. This not only improves the reliability and resilience of your applications but also enhances the user experience by preventing abrupt interruptions. With a few simple configuration steps and a well-defined ApplicationStop script, you can achieve robust and automated graceful termination for your EC2 instances.</p><p><strong>Reference</strong>: <br><a href="https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html#appspec-hooks-server">https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html#appspec-hooks-server</a></p><p><a href="https://aws.amazon.com/blogs/devops/using-codedeploy-environment-variables/">https://aws.amazon.com/blogs/devops/using-codedeploy-environment-variables/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b8919e16173" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scale Smarter, Not Harder: Your Guide to EC2 Right-Sizing in AWS]]></title>
            <link>https://medium.com/@akashjoffical08/scale-smarter-not-harder-your-guide-to-ec2-right-sizing-in-aws-36ce5c0bd711?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/36ce5c0bd711</guid>
            <category><![CDATA[scalability-in-cloud]]></category>
            <category><![CDATA[right-size]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-auto-scaling]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Sat, 17 May 2025 10:32:24 GMT</pubDate>
            <atom:updated>2025-05-17T10:32:24.668Z</atom:updated>
            <content:encoded><![CDATA[<p>Scaling your application in the cloud feels like wielding a powerful, elastic beast. AWS Auto Scaling Groups (ASGs) offer incredible agility, expanding and contracting your EC2 fleet to meet demand. But just like any powerful force, it needs careful guidance. Spin up too few instances, and you risk performance bottlenecks and unhappy users. Overscale, and you’re left with a hefty bill for idle resources.</p><p>The sweet spot lies in <strong>right-sizing</strong> your EC2 instance count within your ASGs — ensuring you have precisely what you need, when you need it, without wasting a single compute cycle. This isn’t about guesswork; it’s about adopting a strategic, data-driven methodology.</p><p>At Our Company, we’ve developed a robust approach to right-sizing our EC2 infrastructure, focusing on maintaining a target CPU utilization while gracefully handling the ebb and flow of traffic. Here’s a peek into our playbook:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*K4KFKUwgOqcBF9mS" /></figure><h3>Our Right-Sizing Approach: A Step-by-Step Guide</h3><p>Our methodology hinges on a blend of real-time observation and the wisdom of historical data. Here’s how we bring those together:</p><p><strong>1. Establishing the Benchmark: Target CPU Utilization</strong></p><p>Every optimization journey starts with a goal. For us, that’s maintaining an average CPU utilization of <strong>60%</strong> on our EC2 instances under load. This target strikes a balance: providing ample headroom to absorb sudden traffic spikes while ensuring we’re not leaving significant compute power on the table. Your ideal target might vary based on your application’s characteristics and cost sensitivity, but having a clear benchmark is the crucial first step.</p><p><strong>2. Real-time Traffic Analysis: Max Requests Per Target (RPT) on a Single EC2</strong></p><p>Next, we dive into the live traffic patterns hitting our individual EC2 instances. Using our monitoring tools (think CloudWatch, Prometheus, Datadog, etc.), we identify the <strong>maximum number of requests per target (RPT)</strong> a single instance can reliably handle <em>while staying within our 60% CPU utilization target</em>. This provides a fundamental unit of capacity — the workhorse capability of a single server under our desired load.</p><p><strong>3. Correlating Traffic and CPU Utilization</strong></p><p>Understanding the individual instance capacity is vital, but so is the behavior of our entire fleet. We continuously monitor our existing servers to understand the current correlation between incoming traffic volume and the resulting CPU utilization across all instances in the ASG. This helps us establish a baseline, identify any existing bottlenecks, and understand how our current configuration responds to load.</p><p><strong>4. Calculating EC2 Instance Requirements for Target Traffic</strong></p><p>With the maximum RPT for a single EC2 instance firmly in hand, we can now predict the number of instances required to handle various traffic volumes. The calculation is straightforward:</p><pre>Estimated EC2 Count = ⌈Total Expected Requests / Maximum RPT per Instance⌈</pre><p>Let’s bring this to life with an example. Imagine our real-time analysis reveals that a single EC2 instance can handle a maximum of <strong>500 requests per minute (RPM)</strong> while maintaining our target 60% CPU utilization. Here’s how we’d estimate instance needs for different traffic scenarios:</p><p>Target Traffic (Requests Per Minute — RPM) Estimated EC2 Count</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T-9fG8oD0Y42t2Vpnu93Nw.png" /></figure><p>This simple calculation provides a powerful way to anticipate our scaling needs based on projected traffic.</p><h3>The Indispensable Role of Historical Data in Large Infrastructures</h3><p>While real-time analysis gives us a snapshot of the present, historical data provides the crucial context for long-term efficiency, especially when managing large-scale infrastructures. By analyzing past traffic patterns, peak loads, and the performance of our EC2 instances over time, we can:</p><ul><li><strong>Refine our benchmarks:</strong> We can revisit and adjust our target CPU utilization based on observed performance and cost efficiency over extended periods. Perhaps we consistently see headroom even at higher utilization, allowing us to optimize further.</li><li><strong>Predict future traffic:</strong> Historical data reveals recurring patterns (daily, weekly, seasonal peaks) and helps us anticipate future traffic growth. This allows for proactive scaling adjustments, preventing reactive fire drills.</li><li><strong>Optimize scaling policies:</strong> We can fine-tune our ASG scaling policies (target tracking, step scaling) based on how our infrastructure has historically responded to traffic fluctuations. This ensures our scaling actions are both timely and appropriate.</li></ul><h3>Seamless Integration with Auto Scaling Groups</h3><p>The insights we glean from this analysis are directly translated into our Auto Scaling Group configurations. We set our <strong>minimum and maximum instance counts</strong> based on our projected traffic, factoring in historical peaks and anticipated growth. Crucially, we configure <strong>scaling policies</strong> to dynamically adjust the number of instances to maintain our target CPU utilization.</p><p>Continuous monitoring via CloudWatch is the bedrock of this process. It provides the real-time metrics that trigger our scaling policies, ensuring our ASGs respond effectively to actual traffic changes.</p><h3>Conclusion: A Data-Driven Path to Efficient Scaling</h3><p>Right-sizing your cloud infrastructure isn’t a one-time task; it’s an ongoing, iterative process. By embracing a data-driven approach that combines the immediacy of real-time traffic analysis with the long-term wisdom of historical data, we can move beyond reactive scaling and implement a proactive strategy.</p><p>This approach not only guarantees optimal application performance and a seamless user experience, even during peak loads, but also delivers significant cost efficiencies by eliminating the waste of underutilized resources. It’s about taming the elastic beast, guiding its power with data, and achieving true cloud optimization.</p><p>Now, we’d love to hear from you! What are your preferred strategies and experiences when it comes to right-sizing your cloud infrastructure? Share your insights in the comments below!</p><p>#AWS #CloudComputing #AutoScaling #EC2 #PerformanceOptimization #CostOptimization #DevOps #SRE #CloudEngineering #DataDriven #RightSizing</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36ce5c0bd711" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Delegate Subdomains to Different Cloud Providers: AWS & GCP]]></title>
            <link>https://medium.com/@akashjoffical08/how-to-delegate-subdomains-to-different-cloud-providers-aws-gcp-786e08b48c0c?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/786e08b48c0c</guid>
            <category><![CDATA[cloud-dns]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[delegate]]></category>
            <category><![CDATA[route-53]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 14:15:19 GMT</pubDate>
            <atom:updated>2024-04-26T12:55:53.518Z</atom:updated>
            <content:encoded><![CDATA[<p>When managing a domain, such as example.com, you may want to delegate control of specific subdomains to different cloud platforms. This guide will walk you through how to delegate aws.example.com to Amazon Web Services (AWS) and gcp.example.com to Google Cloud Platform (GCP), enabling each provider to manage the DNS settings for their respective subdomains independently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*qLu-Y2saddSIHfB7iVra7Q.png" /></figure><h3>Delegating aws.example.com to AWS</h3><h3>Step 1: Create a Subdomain in AWS</h3><p>First, decide that you want to delegate the subdomain aws.example.com. This forms the basis of your delegation process in AWS.</p><h3>Step 2: Set Up DNS Servers for the Subdomain in AWS Route 53</h3><p>For DNS management, AWS offers Amazon Route 53. Here’s how to set it up:</p><ol><li>Create a hosted zone for aws.example.com in Route 53.</li><li>Note down the nameserver (NS) records that Route 53 assigns to your new hosted zone.</li></ol><h3>Step 3: Update the Parent Domain’s DNS Records for AWS Subdomain</h3><p>To delegate the DNS control, you need to update the DNS settings of your primary domain example.com:</p><ol><li>Go to where example.com is hosted.</li><li>Add NS records for aws.example.com, pointing to the nameservers you noted from AWS Route 53.</li></ol><p>This configuration delegates the management of aws.example.com to AWS.</p><h3>Delegating gcp.example.com to GCP</h3><h3>Step 1: Create a Subdomain in GCP</h3><p>Identify gcp.example.com as the subdomain you wish to delegate to GCP.</p><h3>Step 2: Set Up DNS Servers for the Subdomain in GCP</h3><p>Google Cloud DNS will be used to manage DNS services for the subdomain:</p><ol><li>Create a managed zone for gcp.example.com in Google Cloud DNS.</li><li>Note down the nameserver (NS) records assigned to the managed zone.</li></ol><h3>Step 3: Update the Parent Domain’s DNS Records for GCP Subdomain</h3><p>Like with AWS, update the DNS settings for your primary domain example.com to delegate GCP:</p><ol><li>Access the DNS settings where example.com is hosted.</li><li>Add NS records for gcp.example.com, pointing to the nameservers noted from Google Cloud DNS.</li></ol><p>This configures the delegation of gcp.example.com to GCP.</p><h3>Testing the Subdomain Delegation</h3><h3>Step 1: Test the AWS Subdomain Delegation</h3><p>After DNS settings have propagated, test that aws.example.com resolves correctly by querying the DNS records.</p><p>You can use : <a href="https://dnschecker.org/ns-lookup.php">https://dnschecker.org/ns-lookup.php</a> to verify</p><h3>Step 2: Test the GCP Subdomain Delegation</h3><p>Similarly, ensure that gcp.example.com resolves correctly after DNS propagation by querying its DNS records.</p><h3>Conclusion:</h3><p>By following these steps, you have successfully delegated aws.example.com to AWS and gcp.example.com to GCP, allowing each cloud platform to manage its respective subdomain. This setup not only enhances your domain&#39;s organizational structure but also optimizes the management capabilities across different cloud environments.</p><p><strong>Reference :</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=reddit&amp;url=https%3A//www.reddit.com/r/aws/comments/16x9g37/is_it_possible_to_use_an_existing_domain/&amp;image=" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bfe6d409769b8c2ecc3c1ff2d62a74a/href">https://medium.com/media/4bfe6d409769b8c2ecc3c1ff2d62a74a/href</a></iframe><p><a href="https://www.cloudns.net/blog/dns-delegation/">https://www.cloudns.net/blog/dns-delegation/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=786e08b48c0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform and Grafana: A Dynamic Duo for Dashboard Deployment]]></title>
            <link>https://medium.com/@akashjoffical08/terraform-and-grafana-a-dynamic-duo-for-dashboard-deployment-6b0b282764d4?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b0b282764d4</guid>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[grafana]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Sun, 21 Jan 2024 16:19:24 GMT</pubDate>
            <atom:updated>2024-01-21T16:29:51.426Z</atom:updated>
            <content:encoded><![CDATA[<p>Embarking on a DevOps journey often involves grappling with challenges that demand innovative solutions. In my recent exploration, I delved into the complexities of creating and managing Grafana dashboards using Helm charts. The process, which typically entails storing dashboards as Kubernetes ConfigMaps and mounting them to the Grafana instance, revealed nuances that can make customizing Helm charts for dashboard deployment a daunting task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0r69fxzlc8GKVHfh0d9GWQ.png" /><figcaption>Manage grafana with terraform</figcaption></figure><h3>Challenges Unveiled:</h3><p>After an extensive Proof of Concept (POC) and through research, the challenges with Helm charts became apparent. Storing dashboards in Kubernetes ConfigMaps, though a common practice, introduced complexities that made the process less flexible and more intricate than desired. Customizing Grafana Helm charts for dashboard deployment proved to be a complex and cumbersome endeavor, requiring a more efficient and scalable alternative.</p><h3>Embracing Best Practices with Terraform:</h3><p>In the pursuit of a superior solution, the beacon of light was Terraform. The decision to opt for Terraform stems from its proven efficiency in managing operational tasks at scale for Grafana. This powerful infrastructure-as-code tool allows for streamlined workflows, making operational task management, customization, and automation significantly more accessible.</p><p>💡💡<strong> Key Insight</strong>: Terraform emerges as the superior choice, aligning with best practices for Grafana management at scale.</p><h3>The Terraform Advantage:</h3><p>Our decision to leverage Terraform for deploying and managing Grafana dashboards marks a strategic shift. This approach promises to simplify workflows, making the management of operational tasks a breeze. The Grafana Terraform provider serves as our tool of choice, offering a robust foundation for deployment automation.</p><p>This blog help you to enable manageability of grafana with Terraform.</p><h3>Let’s Get Started</h3><h3>Prerequisites:</h3><p>Before we dive into the process, ensure that you have the following prerequisites:</p><ol><li>Grafana instance set up and running(<em>Example: https://test.grafan.com</em>).</li><li>Terraform installed on your local machine.</li><li>Access to the Grafana API for configuration.</li></ol><p><strong>Step 1 : Let Authentication with Grafana &amp; create Service account :</strong> <strong><br></strong> <br>In Terraform, we need to add the Grafana provider to give us access to the Grafana resources. Here’s how to do that:</p><pre>// Update versions as appropriate for time of reading<br>terraform {<br>  required_version = &quot;&gt;= 1.1.0&quot;<br>  required_providers {<br>    grafana = {<br>      source  = &quot;grafana/grafana&quot;<br>      version = &quot;1.34.0&quot;<br>    }<br>  }<br>}</pre><pre>provider &quot;grafana&quot; {<br>  url  = &quot;https://grafana.example.com/&quot;<br>  auth = var.grafana_auth<br>}</pre><p>In this example, the URL corresponds to your Grafana instance, and authentication is achieved using Terraform credentials. To authenticate with Grafana, it’s possible to use a username and password combination in basic auth, such as <strong><em>username:password</em>.</strong> However, a more secure practice is to employ an API key.</p><p>Although Grafana API keys have been replaced with Service Accounts in recent versions, creating a Service Account poses a bit of a challenge. Ideally, Terraform would be used to manage Grafana Service Accounts, but a manual creation is necessary to enable Terraform usage initially. Once Terraform is operational, you can subsequently replace the manually created account with one managed by Terraform.</p><p>To create a Service Account in Grafana:</p><ol><li>Click on the settings (cog) icon in the left-hand menu.</li><li>Select “Service Accounts” from the menu ribbon.</li><li>Choose “Add service account” and assign it a name, for instance, “Terraform.” Grant it “Editor” permissions</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*__cTO-wdLjpl9_LbslHb0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8zKs2Ww0lnm83i1IWKgXIg.png" /></figure><p>Once created Service account API key use in you terrafrom code.</p><h3>Step 2 : let write terraform code :</h3><p>Terraform directory structure looks like the below <br>.<br>├── dashboards<br>│ └── mygrafana-dashboard.json<br>├── main.tf<br>├── variables.tf<br>└── versions.tf</p><p><strong>versions.tf</strong></p><pre>// Update versions as appropriate for time of reading<br>terraform {<br>  required_version = &quot;&gt;= 1.1.0&quot;<br>  required_providers {<br>    grafana = {<br>      source  = &quot;grafana/grafana&quot;<br>      version = &quot;1.34.0&quot;<br>    }<br>  }<br>}<br><br></pre><p><strong>main.tf :</strong></p><pre>provider &quot;grafana&quot; {<br>  url  = var.grafana_endpoint<br>  auth = var.grafana_service_account_api_key<br>}<br><br>resource &quot;grafana_folder&quot; &quot;create_folder_on_grafana&quot; {<br>  title = var.grafana_dashboard_folder_name<br>}<br><br>resource &quot;grafana_dashboard&quot; &quot;deploy_dashboard&quot; {<br>  for_each    = fileset(&quot;${var.dashboard_file_path}&quot;, &quot;**&quot;)<br>  config_json = file(&quot;${var.dashboard_file_path}/${each.key}&quot;)<br>  folder      = grafana_folder.create_folder_on_grafana.id<br>}</pre><p>This Terraform code automates the creation of a folder in Grafana and deploys dashboards from JSON files located in a specified directory. The variables (var) are expected to be defined elsewhere, providing flexibility and reusability.</p><p><strong>variables.tf:</strong></p><pre>variable &quot;grafana_dashboard_folder_name&quot; {<br>  description = &quot;Folder name created on grafana istance&quot;<br>  type        = string<br>  default     = &quot;stage&quot;<br>}<br><br>variable &quot;dashboard_file_path&quot; {<br>  description = &quot;Grafana dashboard file  local path&quot;<br>  type        = string<br>  default     = &quot;dashboards/&quot;<br>}<br>variable &quot;grafana_endpoint&quot; {<br>  type        = string<br>  description = &quot;Define Endpoint of Grafana&quot;<br>  default     = &quot;https://grafana.monitoring.codepipes.io/&quot;<br>}<br><br><br>variable &quot;grafana_service_account_api_key&quot; {<br>  type        = string<br>  description = &quot;Define API key to conect Grafana instance&quot;<br>  default     = &quot;XXXXXXXXXXXXXXXX&quot;<br>}</pre><h3><strong>Step 3 : Once you have written your code, proceed with the Terraform commands</strong></h3><ol><li>Run terraform init to initialize the configuration.</li><li>Create the necessary directory structure.</li><li>Deploy the dashboard on Grafana by executing terraform apply.</li></ol><p>Simply run terraform apply to apply the configurations and orchestrate the deployment of your Grafana dashboard.</p><p>Go &amp; check your dashboard on grafana stance</p><p>In this way, your automate whole workflow of grafana using terrafrom</p><h3>Conclusion:</h3><p>By using Terraform to manage Grafana configurations, you can simplify the process of deploying dashboards and ensure consistency across different environments. This approach is particularly beneficial for teams managing Grafana instances at scale.</p><p>Feel free to customize and extend the Terraform configurations based on your specific requirements. With Terraform, Grafana management becomes more efficient, and deploying dashboards becomes a standardized, automated process.</p><p>Certainly! Feel free to explore other capabilities of the Grafana Terraform provider, such as creating data sources, managing users, and more. The provider allows you to extend your Terraform configurations to automate various Grafana-related tasks, enhancing the efficiency of your infrastructure management. Try experimenting with creating data sources, setting up users, and other functionalities to fully leverage the power of Terraform for Grafana administration.<br><a href="https://registry.terraform.io/providers/grafana/grafana/latest/docs">https://registry.terraform.io/providers/grafana/grafana/latest/docs</a></p><p>Happy Grafana dashboarding with Terraform! 🚀</p><p><strong>Reference : </strong><br><strong>Grafana Offical doc</strong> : <a href="https://grafana.com/docs/grafana-cloud/developer-resources/infrastructure-as-code/terraform/dashboards-github-action/#add-dashboards-to-a-github-repository">https://grafana.com/docs/grafana-cloud/developer-resources/infrastructure-as-code/terraform/dashboards-github-action/#add-dashboards-to-a-github-repository</a></p><p><strong>Github link:</strong> <a href="https://github.com/grafana/terraform-provider-grafana/tree/master">https://github.com/grafana/terraform-provider-grafana/tree/master</a></p><p>Grafana website: <a href="https://grafana.com/">https://grafana.com</a></p><p>Grafana Cloud website: <a href="https://grafana.com/products/cloud/">https://grafana.com/products/cloud/</a></p><p>Provider Documentation: <a href="https://registry.terraform.io/providers/grafana/grafana/latest/docs">https://registry.terraform.io/providers/grafana/grafana/latest/docs</a></p><p>Grafana Chat: <a href="https://grafana.slack.com/archives/C017MUCFJUT">Grafana #terraform Slack channel</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b0b282764d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Helm’s — atomic Option for Rollback Leaves You in the Dark]]></title>
            <link>https://medium.com/@akashjoffical08/helms-atomic-option-for-rollback-leaves-you-in-the-dark-73841d8a5842?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/73841d8a5842</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[helm-chart]]></category>
            <category><![CDATA[helm]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 13:37:40 GMT</pubDate>
            <atom:updated>2023-10-27T13:37:40.431Z</atom:updated>
            <content:encoded><![CDATA[<h3>Helm’s — atomic Option for Rollback Leaves You in the Dark</h3><h3>Introduction:</h3><p>The world of DevOps is an exciting journey full of exploration and problem-solving. As a DevOps enthusiast, I recently embarked on a new adventure into the realms of Kubernetes deployments. My trusty companion for this journey was Helm, the Kubernetes package manager. It promised seamless application deployments, and my initial experience was smooth sailing.</p><p>I harnessed the power of Helm charts to deploy my applications in a Kubernetes cluster, and I had a nifty command at my disposal:</p><pre>helm upgrade - install -f values.yaml &lt;release-name&gt; . - atomic - timeout &lt;timeout-sec&gt;</pre><p>This command made my deployments effortless and reliable.</p><p>The `<strong> — atomic</strong>` option acted like a safety net, ensuring that if anything went wrong during deployment, Helm would gracefully roll back to the previous version. It was a reassuring feature, much like a safety rope while climbing a steep mountain.</p><p><strong>The Challenge: Unveiling the Darkness in Helm’s — atomic Option</strong></p><p>Imagine a scenario where you’ve implemented a safety mechanism in your CI/CD pipeline. If a Kubernetes pod enters a crash loop for 300 seconds, Helm triggers an automatic rollback to the previous version if we use the atomic option. This is an essential fail-safe mechanism. <strong>The problem is that, in some cases, even after a successful rollback, if the subsequent deployment attempt fails, the pipeline may still be marked as successful in case of rollback</strong>. This can be confusing for users who might not immediately realize that Helm executed a rollback due to a failed deployment.</p><p>Pipeline will always be successful because it has successfully executed helm command with an automatic rollback option. Without — atomic option it might fail. The pipeline doesn’t know about helm rollback feature it only know about command that you’re running is successfully executed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*BfMIjG27YDbYsSjCtey04w.png" /></figure><h4>Our Solution: Handling Rollbacks with Finesse</h4><p>To tackle this issue, we’ve refined our Helm deployment script to enhance the pipeline’s clarity and user-friendliness. Here’s a breakdown of the improvements:</p><ol><li><strong>Deployment Command Optimization:</strong> We’ve updated our deployment command to include the --wait and --timeout flags. These additions ensure that Helm waits for the deployment to complete and specifies a timeout period for the deployment.</li></ol><pre>helm upgrade --install -f values.yaml {{Release_Name}} . --wait --timeout {{deployment_timeout_second}}</pre><p><strong>2. Tracking Helm Exit Status:</strong></p><p>It’s crucial to track the Helm deployment exit status. We retrieve the exit status and use it to determine the success or failure of the deployment.</p><pre>helm_upgrade_exit_status=$?</pre><p><strong>3. Handling Rollbacks:</strong></p><p>In the event of a deployment failure, we’ve implemented a rollback mechanism. Here’s how it works:</p><ul><li>If the Helm deployment fails (indicated by a non-zero exit status), we initiate a rollback to the previous version.</li><li>If the rollback is successful, we perform additional actions to address the issue that caused the rollback. This may include restarting the deployment and checking the rollout status.</li></ul><p>Here’s the script that became my guiding star:</p><pre>helm upgrade --install -f values.yaml {{Release_name}} . --wait --timeout {{deployment_timeout_second}}<br># Capturing Helm&#39;s Exit Status<br>helm_upgrade_exit_status=$?<br>echo &#39;Helm release failed with EXIT_CODE: &#39;$helm_upgrade_exit_status&#39;&#39;<br><br># Verifying the Helm upgrade/install status<br>if [ $helm_upgrade_exit_status -eq 0 ]; then<br>  echo &quot;Helm upgrade/install successful....&quot;<br>else<br>  # When Helm&#39;s release fails, it&#39;s time to set the sails for a rollback<br>  echo &quot;Helm upgrade/install failed. Rolling back to the previous version...&quot;<br><br>  # Initiating the Helm rollback<br>  helm rollback {{Release_name}} 0 --wait --timeout {{deployment_timeout_second}}<br>  if [ $? -eq 0 ]; then<br>    echo &quot;Helm rollback completed...&quot;<br>    echo &quot;Action Required: Check your deployment on the K8s cluster to understand why it rolled back.&quot;<br><br>    # We exit with a non-zero status code to indicate pipeline failure<br>    exit 1<br>  else<br>    echo &quot;Helm Rollback also failed ...&quot;<br>    exit 1<br>  fi<br>fi</pre><p>This script brought a new dawn to my Helm deployments. It ensured that every successful rollback was marked as “incomplete,” with a clear indication that something had gone awry.</p><p><strong>Impact: Improved User Experience</strong></p><p>These enhancements have had a positive impact on our CI/CD pipeline:</p><ul><li>Rollbacks are now explicitly marked as failures, avoiding confusion.</li><li>Users receive custom notifications that keep them informed.</li><li>Our CI/CD pipeline is more robust and user-friendly.</li></ul><h4>Conclusion</h4><p>In the world of DevOps, transparency and accuracy are paramount. This journey with Helm and a custom script helped me bring clarity and precision to my CD pipeline. Rollbacks were no longer silent heroes; they were vividly marked as a part of the story.</p><p>As I continue to explore the ever-evolving landscape of Kubernetes deployments, I share this tale in the hope that it will illuminate the path for fellow DevOps explorers. With Helm as your trusty companion and a custom script as your navigator, you can sail confidently through the seas of CD deployments, ensuring that the story of your pipeline is as complete and transparent as the journey itself.</p><p>May your Helm deployments always be clear, and your CD pipelines shine brightly.</p><p>Happy Helm deploying!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73841d8a5842" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting Google Cloud Build to Google Cloud SQL Using Cloud SQL GCE Proxy]]></title>
            <link>https://medium.com/@akashjoffical08/connecting-google-cloud-build-to-google-cloud-sql-using-cloud-sql-gce-proxy-a0876b23105e?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0876b23105e</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[cloud-sql-proxy]]></category>
            <category><![CDATA[cloud-sql]]></category>
            <category><![CDATA[cloud-build]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Wed, 18 Oct 2023 17:17:53 GMT</pubDate>
            <atom:updated>2023-10-19T08:23:00.024Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>In the modern cloud-driven development landscape, ensuring smooth integration between cloud services is key. Google Cloud Build, a fully managed CI/CD platform, can be connected to a Google Cloud SQL database through the Google Cloud SQL GCE Proxy. In this blog post, we’ll guide you through the process of setting up this connection to efficiently manage your database within your CI/CD pipeline.</p><p>First let understand ,GCE Proxy and Cloud SQL Proxy are two different tools used in the context of Google Cloud Platform (GCP) for different purposes:</p><p><strong>1. GCE Proxy:</strong><br> — GCE stands for Google Compute Engine, which is Google’s infrastructure-as-a-service (IaaS) platform.<br> — GCE Proxy typically refers to a setup where you use a Google Compute Engine instance as a proxy server. This can be used for various purposes like load balancing, security, or routing traffic through a specific point in your network architecture.<br> — GCE Proxies are typically used for routing traffic within your virtual network or between different networks in GCP.</p><p><strong>2. Cloud SQL Proxy:</strong><br> — Cloud SQL is a managed database service provided by Google Cloud Platform, which supports various database engines like MySQL, PostgreSQL, and SQL Server.<br> — Cloud SQL Proxy is a client-side tool that simplifies connecting to your Cloud SQL instances from your local machine or from your applications running in GCP. It provides a secure and convenient way to access your Cloud SQL databases without exposing them to the public internet. You can use it to connect to your database instances without requiring external IP addresses and through a secure channel. Connect instances without having to whitelist IP addresses or configure SSL.</p><p>GCE Proxy is generally used for routing traffic within Google Compute Engine instances and networks, while Cloud SQL Proxy is specifically designed to facilitate secure connections to Google Cloud SQL databases. The choice between the two depends on your use case, and they serve different purposes within the Google Cloud ecosystem.</p><p>If you are running your application on Google Compute Engine, you can use the CloudSQL GCE Proxy for a more straightforward setup. If your application is hosted outside of GCP, you would typically use the Cloud SQL Auth Proxy to securely connect to your Cloud SQL database. The choice between them depends on your specific infrastructure and deployment requirements.</p><p>So for our use we have the choice of GCE Proxy to connect to SQL</p><p><strong>Prerequisites</strong>:</p><p>Before we dive into the setup, make sure you have the following in place:<br>- A Google Cloud project with billing enabled.<br>- A Google Cloud SQL database instance.<br>- A Cloud Build configuration file (cloudbuild.yaml).<br>- A service account JSON key file for your Google Cloud project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlD2-c1wAoNF_L2XdrXHNw.png" /></figure><p>Let&#39;s start setting up the Cloud build pipeline</p><p><strong>Step 1: Running the Google Cloud SQL GCE Proxy</strong><br>The first step is to run the Google Cloud SQL GCE Proxy in your Cloud Build pipeline. This proxy enables your Cloud Build environment to connect to your Google Cloud SQL database securely.</p><p><strong>cloudbuild.yaml</strong></p><pre>- id: Running gce-cloud-sql-proxy<br>  name: gcr.io/cloud-builders/docker:latest<br>  script: |<br>    docker run -d -v /workspace:/config -p 127.0.0.1:5432:5432 \<br>      --name cloudsql-db-proxy --network cloudbuild \<br>      gcr.io/cloudsql-docker/gce-proxy:1.33.1 \<br>      /cloud_sql_proxy -instances=project:region:instance-name=tcp:0.0.0.0:5432 \<br>      -credential_file=/config/GCP-SA-Cred.json<br>    sleep 20<br>    docker ps -a<br>    docker logs cloudsql-db-proxy</pre><p><strong>In this script:</strong><br>- `<strong>project:region:instance-name</strong>` should be replaced with your actual Google Cloud SQL instance connection details.<br>- `/<strong>config/GCP-SA-Cred.json</strong>` should be replaced with the path to your Google Cloud service account JSON key file.</p><p>This step starts the GCE Proxy container, which establishes a tcp secure connection to your database.</p><p><strong>Step 2: Testing the Connection</strong><br>Now that the Google Cloud SQL GCE Proxy is running, it’s time to test the connection to your database.</p><p><strong>cloudbuild.yaml</strong></p><pre>- id: Cloudsql-test<br>  name: mikesplain/telnet:latest<br>  script: |<br>    telnet cloudsql-db-proxy 5432</pre><p>Using telnet to db hostname with proxy docker container name, we check if the connection to the database proxy is successful. A successful response indicates a working connection.</p><p><strong>Step 3: Stopping the Cloud Sql GCE Proxy</strong></p><p>After you’ve completed your database tasks, it’s crucial to stop the Google Cloud SQL GCE Proxy.</p><p><strong>cloudbuild.yaml</strong></p><pre>- id: Stopping cloudsql-db-proxy<br>  name: gcr.io/cloud-builders/docker:latest<br>  script: |<br>    docker stop cloudsql-db-proxy<br>    docker ps</pre><p>This step ensures that the proxy container is properly shut down after use.</p><p><strong>Step 4: </strong>You can now initiate the Cloud Build process.</p><p>Complete <strong>cloudbuild.yaml</strong> file looks like this :</p><pre>- id: Running gce-cloud-sql-proxy<br>  name: gcr.io/cloud-builders/docker:latest<br>  script: |<br>    docker run -d -v /workspace:/config -p 127.0.0.1:5432:5432 \<br>      --name cloudsql-db-proxy --network cloudbuild \<br>      gcr.io/cloudsql-docker/gce-proxy:1.33.1 \<br>      /cloud_sql_proxy -instances=project:region:instance-name=tcp:0.0.0.0:5432 \<br>      -credential_file=/config/GCP-SA-Cred.json<br>    sleep 20<br>    docker ps -a<br>    docker logs cloudsql-db-proxy<br><br>- id: Cloudsql-test<br>  name: mikesplain/telnet:latest<br>  script: |<br>    telnet cloudsql-db-proxy 5432<br><br>- id: Stopping cloudsql-db-proxy<br>   name: gcr.io/cloud-builders/docker:latest<br>   script: |<br>     docker stop cloudsql-db-proxy<br>     docker ps</pre><p>Run the pipeline with the below command :</p><pre>gcloud builds submit  --config cloud-build.yaml --project test-project .</pre><h3>Conclusion:</h3><p>Connecting Google Cloud Build to Google Cloud SQL using the Google Cloud SQL GCE Proxy streamlines your CI/CD pipeline and allows for efficient database management. This setup enables you to keep your database synchronized with your codebase and apply updates seamlessly when changes occur. By following the steps provided in this guide, you can create a robust and cloud-native environment for your development workflow.</p><p><strong>Reference</strong> :</p><ul><li><a href="https://cloud.google.com/sql/docs/mysql/connect-auth-proxy">Connect using the Cloud SQL Auth Proxy | Cloud SQL for MySQL | Google Cloud</a></li><li><a href="https://cloud.google.com/sql/docs/sqlserver/connect-docker">Connecting SQL Server client using the Cloud SQL Auth Proxy Docker image | Cloud SQL for SQL Server | Google Cloud</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0876b23105e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keeping It Simple: The Wisdom of Short Deployment Names in Kubernetes]]></title>
            <link>https://medium.com/@akashjoffical08/keeping-it-simple-the-wisdom-of-short-deployment-names-in-kubernetes-e06402220262?source=rss-db4dff553217------2</link>
            <guid isPermaLink="false">https://medium.com/p/e06402220262</guid>
            <category><![CDATA[k8s-series]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[k8s]]></category>
            <dc:creator><![CDATA[Akash Jaiswal]]></dc:creator>
            <pubDate>Mon, 25 Sep 2023 20:44:14 GMT</pubDate>
            <atom:updated>2023-09-25T20:44:14.427Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever considered that the length of a name could make or break your Kubernetes (K8s) deployment strategy? In the fast-paced world of container orchestration, the nuances of naming might seem trivial, but they play a pivotal role in keeping your operations smooth and efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LL4UwXhnwIv7ggfYh5xbRA.png" /><figcaption>Select a Kubernetes deployment name that falls within the specified limit.</figcaption></figure><p>In the realm of Kubernetes, where every character counts, it’s essential to understand how the length of your deployment names can impact your entire ecosystem. Most K8s objects, including Deployments, offer a generous character limit of 253 characters for naming. However, this freedom comes with a caveat: it’s advisable to keep your<em> Deployment names under </em><strong><em>47 characters</em></strong><em> to ensure harmony within your cluster and avoid potential naming-related bottlenecks.</em></p><p>Most Kubernetes objects, including <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/">Deployment</a>s, can have names that are <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names">≤ 253 characters in length</a>. You should, however, consider restricting your Deployment names to ≤ 47 characters because of the implications that exceeding this threshold will have on your <a href="https://kubernetes.io/docs/concepts/workloads/pods/">Pod</a> names.</p><h4><strong>Pod and ReplicaSet Naming</strong></h4><p>To comprehend the significance of this character limit, let’s delve into the intricacies of Pod and ReplicaSet naming. Deployments in Kubernetes are the architects of ReplicaSets, and these ReplicaSets, in turn, give birth to Pods. When your Deployment names are succinct and to the point (e.g., “mydeployment”), the naming structure follows a straightforward pattern.</p><p>The ReplicaSet name echoes the Deployment’s name, adorned with a dash/hyphen suffix followed by a unique 9-character pod-template-hash (e.g., “mydeployment–548f955bf”). Consequently, Pod names are crafted from the ReplicaSet name, featuring a dash/hyphen followed by 5 random hexadecimal characters (e.g., “mydeployment–548f955bf-j8wng”).</p><p>This naming convention brings clarity to your Kubernetes world. It allows you to effortlessly trace the lineage from Pods to ReplicaSets and Deployments while ensuring that each name remains distinctive and unambiguous.</p><h4><strong>The Perils of Lengthy Deployment Names</strong></h4><p>Now, let’s explore the challenges posed by deployment names exceeding 47 characters. Theoretically, a ReplicaSet name can stretch up to 253 characters. However, when a Deployment creates a ReplicaSet, it caps the ReplicaSet’s name at the first 80 characters of the Deployment’s name. It then attaches the dash/hyphen and the 9-character pod-template-hash, resulting in a maximum name length of 90 characters. Pod names, on the other hand, have a stricter limit of 63 characters.</p><p>For ReplicaSets with lengthy names, Kubernetes truncates the ReplicaSet name after the initial 58 characters. It then appends the 5 random hexadecimal characters, sans the dash/hyphen. If the ReplicaSet name is 57 characters or less, Kubernetes retains the dash/hyphen before the 5 random characters.</p><h4><strong>Implications for Day-to-Day Operations</strong></h4><p>This naming intricacy has far-reaching implications for everyday operational tasks. When your Deployment names adhere to the 47-character guideline, all is well in your Kubernetes universe. However, as your Deployment names grow beyond this limit, complications arise, particularly when distinguishing Pods from different ReplicaSets.</p><p>Consider this scenario: you have two Deployments in the same Namespace with similar names. In such cases, Pod names become virtually indistinguishable, introducing potential headaches when handling rollouts, resource quotas, or manual Pod deletions to facilitate a smoother deployment process.</p><h4><strong>What’s the Solution?</strong></h4><p>If you find yourself needing longer Deployment names, fear not. Kubernetes offers a solution through the “ownerReferences” stanza in metadata, establishing parent-child relationships between Pods and ReplicaSets. Additionally, leveraging Namespaces can help maintain order in your Kubernetes landscape. Although Namespaces are also subject to a 63-character naming limit, they allow you to create distinct environments and simplify Deployment naming within those spaces.</p><h4><strong>In summary</strong></h4><p>while Kubernetes provides flexibility in naming, it’s prudent to keep your Deployment names concise, especially if you anticipate multiple Deployments in the same Namespace. A clear and structured naming convention can streamline your Kubernetes management, reducing the likelihood of errors and ensuring a smooth sailing journey in the world of K8s.</p><p><strong>Reference :</strong></p><p><a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names">Object Names and IDs</a></p><p><a href="https://stackoverflow.com/questions/74779843/what-is-max-length-for-pod-name-in-k8s">https://stackoverflow.com/questions/74779843/what-is-max-length-for-pod-name-in-k8s</a><strong><br></strong><a href="https://pauldally.medium.com/why-you-try-to-keep-your-deployment-names-to-47-characters-or-less-1f93a848d34c">https://pauldally.medium.com/why-you-try-to-keep-your-deployment-names-to-47-characters-or-less-1f93a848d34c</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e06402220262" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>