<?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 Aneeq Rana on Medium]]></title>
        <description><![CDATA[Stories by Aneeq Rana on Medium]]></description>
        <link>https://medium.com/@aneeqr25?source=rss-aa0b967c6fd0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5AFJzI2-zG2DsSvU-Wt3Uw.png</url>
            <title>Stories by Aneeq Rana on Medium</title>
            <link>https://medium.com/@aneeqr25?source=rss-aa0b967c6fd0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 18:34:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aneeqr25/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[Every AI Session Starts From Zero. Your Engineering Organization Shouldn’t.]]></title>
            <link>https://medium.com/@aneeqr25/every-ai-session-starts-from-zero-your-engineering-organization-shouldnt-3165381285f6?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3165381285f6</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[platform-engineering]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 19:51:03 GMT</pubDate>
            <atom:updated>2026-08-04T19:51:03.145Z</atom:updated>
            <content:encoded><![CDATA[<h3>The breakthrough wasn’t making the AI smarter. It was making the repository smart enough to teach it.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h2PA-IPfgi5MYoHMvbv21w.png" /></figure><p>Everyone is talking about making AI coding assistants more capable.</p><p>Larger models. Longer context windows. Better prompts. More tools. More autonomous agents.</p><p>After spending time experimenting with AI-assisted platform engineering, I became convinced that we may be solving the wrong problem.</p><p>The biggest limitation was not the model.</p><p>It was the organisation around it.</p><p>I would give an AI assistant a routine infrastructure task. It would inspect the repository, search through several directories, compare multiple implementations and reconstruct enough context to propose a technically reasonable change.</p><p>Then I would start a fresh session.</p><p>It would repeat the entire process.</p><p>The assistant had not become less capable. The repository had simply failed to preserve and communicate what had already been learned.</p><blockquote>This repetition was not only consuming tokens. It was increasing review time, slowing onboarding, pulling senior engineers back into routine discovery, and making inconsistent changes more likely. What looked like an AI-context problem was actually an engineering-productivity problem.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3I5JxH8O6DvQXOIO4vrRsg.png" /></figure><p>That was the moment I stopped asking:</p><blockquote><strong><em>How do I make the AI smarter?</em></strong></blockquote><p>And started asking:</p><blockquote><strong><em>How do I make the repository smart enough to teach the AI?</em></strong></blockquote><p>That question changed the direction of the work completely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EssMRruPeRrDr1Vhlz1-Xg.png" /></figure><h3>AI did not create the knowledge problem</h3><p>Every engineering organisation already pays a hidden tax.</p><p>It does not appear neatly on a cloud invoice. It rarely triggers an alert. It may not be visible in delivery metrics.</p><p>But engineers experience it every day.</p><p>A new engineer joins and spends weeks learning where changes belong.</p><p>A senior engineer searches old pull requests because they cannot remember which implementation became the standard.</p><p>A platform team maintains several technically similar modules, but only one is authoritative.</p><p>An architecture decision is discussed, implemented and then gradually forgotten.</p><p>Documentation exists, but nobody is certain whether it still reflects reality.</p><p>AI coding assistants inherit exactly the same problem.</p><p>A model may understand Terraform, Kubernetes, IAM, Python, CI/CD and cloud architecture. It may be able to generate technically correct code within seconds.</p><p>What it does not inherently understand is how <strong>your organisation</strong> expects that code to be introduced.</p><p>It does not automatically know:</p><ul><li>which repository owns a capability;</li><li>which implementation is trusted;</li><li>why one pattern is current and another is deprecated;</li><li>which team should review a change;</li><li>which governance rules apply;</li><li>where related documentation must be updated.</li></ul><p>Those are not programming-language questions.</p><p>They are organisational knowledge questions.</p><p>And giving the model access to more files does not necessarily solve them.</p><h3>More context is not always better context</h3><p>One of the common assumptions in AI-assisted development is that better results will come from giving the model more context.</p><p>Sometimes they do.</p><p>But a larger context window can still contain several competing patterns, obsolete examples and technically valid implementations without telling the assistant which one the organisation actually trusts.</p><p>The model may find an answer.</p><p>That does not mean it has found the <strong>right organisational answer</strong>.</p><p>This is particularly important in enterprise platform repositories, where years of delivery create layers of exceptions, regional differences, ownership boundaries, migration paths and historical decisions.</p><p>The problem is therefore not simply repository search.</p><p>It is repository understanding.</p><p>Or, more precisely:</p><blockquote><strong><em>AI does not struggle because it lacks Terraform knowledge. It struggles because it does not know which Terraform your organisation trusts.</em></strong></blockquote><p>That distinction is where the real opportunity begins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ugyUNCbvD1kFbm0f41Qwig.png" /></figure><h3>The repository should not be passive storage</h3><p>Most repositories are designed primarily to store code.</p><p>They tell you what exists, but not always:</p><ul><li>why it exists;</li><li>which decisions shaped it;</li><li>which implementation should be followed;</li><li>how a similar change should be performed;</li><li>what must remain synchronised after the change.</li></ul><p>The knowledge is usually present, but fragmented.</p><p>Some of it lives in documentation.</p><p>Some lives in pull requests.</p><p>Some lives in architecture conversations.</p><p>Some is reflected indirectly in naming conventions.</p><p>Some exists only in the memory of experienced engineers.</p><p>The repository stores the outcome, while the reasoning slowly disappears.</p><p>I started thinking about repositories differently.</p><p>Not simply as collections of files, but as collections of engineering knowledge.</p><p>Knowledge about architecture.</p><p>Knowledge about operations.</p><p>Knowledge about ownership.</p><p>Knowledge about standards.</p><p>Knowledge about previous decisions.</p><p>Knowledge about how the organisation expects engineering work to be performed.</p><p>Once that knowledge is structured and governed, the repository can stop behaving like passive storage.</p><p>It can become an active teacher.</p><h3>From repeated discovery to reusable engineering intelligence</h3><p>The approach I designed was intended to reduce one specific form of waste: repeatedly reconstructing knowledge that the organisation already possesses.</p><p>Instead of allowing each request to begin with an unrestricted search across the repository, the assistant is first guided toward the relevant, reviewed context.</p><p>Conceptually, the system needs four types of intelligence.</p><h3>Operational knowledge</h3><p>This explains how recurring engineering work should be carried out.</p><p>Not the syntax of Terraform or Python, but the organisation’s expected process around changes, validation, review and documentation.</p><p>For example:</p><ul><li>how infrastructure changes should be prepared;</li><li>how existing patterns should be reused;</li><li>how changes should be validated;</li><li>which tasks require human approval;</li><li>how related knowledge should be updated.</li></ul><p>This reduces repeated interpretation of routine practices.</p><h3>Repository knowledge</h3><p>This helps the assistant understand the engineering environment it is entering.</p><p>It may include the repository’s purpose, architecture, ownership boundaries, dependencies, trusted patterns and the responsibilities of different components.</p><p>The goal is not to document every line of code.</p><p>The goal is to make the repository’s structure and intent discoverable.</p><h3>Engineering memory</h3><p>This preserves significant decisions and changes.</p><p>Most teams are reasonably good at recording what changed. Far fewer consistently preserve why it changed.</p><p>That difference matters.</p><p>A future engineer may see that a repository was restructured, but not know what problem the restructure solved. They may see a new module without understanding why an older one should no longer be used.</p><p>Engineering memory should retain enough context to help future decisions, not merely describe the current state.</p><h3>Governance</h3><p>Any repository-intelligence layer must inherit the same access controls and environment boundaries as the systems it describes. Making trusted context easier to retrieve must never become a shortcut around least privilege or expose knowledge that the requesting engineer or workflow is not authorised to access.</p><p>Knowledge used by AI must be reviewed, maintained and bounded.</p><p>Without governance, a repository intelligence layer can gradually become a repository misinformation layer.</p><p>The system therefore needs clear rules around:</p><ul><li>what knowledge is authoritative;</li><li>who can approve changes to it;</li><li>when human review is mandatory;</li><li>how stale guidance is identified;</li><li>how significant engineering changes update the associated knowledge.</li></ul><p>This is not optional.</p><p>AI can follow outdated instructions just as confidently as current ones.</p><h3>Documentation must move with engineering activity</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFbl3xK_2YNU7dlS4LfKuA.png" /></figure><p>One of the most important lessons from this work was that documentation cannot remain a separate, end-of-project activity.</p><p>Documentation drift is not just inconvenient for people.</p><p>It is dangerous for AI-assisted engineering.</p><p>Once engineers stop trusting documentation, they stop using it. Once an AI assistant is guided by outdated documentation, it can make incorrect recommendations with impressive confidence.</p><p>A meaningful engineering change should therefore improve two things:</p><ol><li>the system itself;</li><li>the knowledge describing the system.</li></ol><p>If a repository is restructured, the architecture knowledge should reflect it.</p><p>If a new operating pattern is introduced, the relevant guidance should evolve.</p><p>If an older approach is retired, the repository should stop presenting it as an equally valid option.</p><p>If a significant decision is made, the reasoning should not disappear into a pull request or meeting transcript.</p><p>The important capability is not simply automatic documentation updates.</p><p>The business value is that:</p><blockquote><strong><em>Engineering knowledge remains synchronised with engineering activity.</em></strong></blockquote><p>That creates continuity.</p><p>The next engineer does not have to rediscover the same decision.</p><p>The next AI session does not have to infer the same architecture from scratch.</p><p>The organisation gets to reuse what it has already learned.</p><h3>What changed in early testing</h3><p>I have been testing this approach against recurring platform-engineering workflows.</p><p>The purpose was not to create unrestricted autonomous infrastructure. Human review remained mandatory throughout.</p><p>The early improvements were more practical.</p><p>The assistant performed less broad repository scanning.</p><p>It became faster at locating relevant implementations.</p><p>It was less likely to select technically plausible but non-authoritative files.</p><p>Recurring infrastructure tasks became more predictable.</p><p>Repository knowledge became useful not only to the AI assistant, but also to engineers trying to understand unfamiliar areas of the platform.</p><blockquote>Across a small number of comparable workflows, model usage fell materially. In some tests, approximate task cost moved from around $7–9 to roughly $2. These are directional observations rather than a controlled benchmark, and results will vary by repository size, task complexity, model choice and implementation quality.</blockquote><p>The more important outcome was not the token reduction.</p><p>It was the reduction in repeated analysis.</p><p>The assistant spent less effort rediscovering what had already been reviewed and captured.</p><p>In routine workflows involving infrastructure access, encryption, storage and regional changes, that translated into faster progress and fewer incorrect starting points.</p><p>The same approach also showed potential for onboarding.</p><p>A new engineer can use structured repository knowledge to understand what exists, where changes belong and which patterns are trusted — without relying on continuous supervision from a senior engineer.</p><p>That does not eliminate mentoring.</p><p>It makes mentoring more valuable by reducing the number of questions that should already have been answered by the engineering system.</p><h3>The business problem is larger than AI cost</h3><p>It would be easy to position this as a token-optimisation exercise.</p><p>That would miss the point.</p><p>The real problem is knowledge friction.</p><p>Knowledge friction appears when:</p><ul><li>senior engineers repeatedly answer the same questions;</li><li>new joiners take too long to become productive;</li><li>teams implement the same capability in different ways;</li><li>architecture decisions disappear after delivery;</li><li>documentation drifts away from implementation;</li><li>AI assistants repeatedly reconstruct the same context;</li><li>engineering work slows because trusted knowledge is difficult to retrieve.</li></ul><p>This affects far more than model usage.</p><p>It affects delivery speed.</p><p>It affects consistency.</p><p>It affects operational risk.</p><p>It affects governance.</p><p>It affects how much of a senior engineer’s time is spent making high-value decisions versus explaining where something lives.</p><p>The broader business opportunity is not merely to help AI generate more code.</p><p>It is to reduce the cost of rediscovery across the engineering organisation.</p><p>Every time a team solves the same contextual problem again, the organisation pays twice:</p><p>Once to create the knowledge.</p><p>And again to rediscover it.</p><h3>What this approach is not</h3><p>It is important not to overstate what has been built or tested.</p><p>This is not:</p><ul><li>a replacement for platform engineers;</li><li>a fully autonomous infrastructure platform;</li><li>a substitute for architecture review;</li><li>a reason to stop inspecting Terraform plans;</li><li>a guarantee that generated changes will be correct;</li><li>a claim that every form of organisational knowledge can be captured;</li><li>an excuse to remove human approval from sensitive workflows.</li></ul><p>AI can still misunderstand requirements.</p><p>Knowledge can become stale.</p><p>A trusted pattern can still be wrong for a new use case.</p><p>Human judgement remains essential — particularly for security, compliance, production infrastructure and architectural trade-offs.</p><p>The aim is not to remove engineers from the process.</p><p>It is to help them begin with better context.</p><h3>The real intelligence is organisational</h3><p>The biggest opportunity in AI-assisted engineering is not teaching a model how to write Terraform.</p><p>Models already understand infrastructure code remarkably well.</p><p>The harder challenge is teaching AI how an engineering organisation expects infrastructure to be:</p><ul><li>designed;</li><li>reviewed;</li><li>governed;</li><li>documented;</li><li>maintained.</li></ul><p>That is not purely an AI problem.</p><p>It is a platform-engineering, knowledge-management and governance problem.</p><p>I do not yet know whether this becomes the dominant pattern for AI-assisted engineering.</p><p>But one thing has become increasingly clear during the workflows I have tested:</p><blockquote><em>The improvements came from making organisational knowledge more usable — not from making the language model larger.</em></blockquote><p>The model mattered.</p><p>The surrounding engineering system mattered more.</p><h3>Five questions every engineering system should be able to answer</h3><p>A repository — or the wider engineering system around it — should help both people and AI answer five questions:</p><h3>Why does this exist?</h3><p>What problem is the component, pattern or decision intended to solve?</p><h3>Who owns it?</h3><p>Which team or capability is responsible for maintaining and approving it?</p><h3>Which implementation is trusted?</h3><p>Where is the authoritative pattern, and which alternatives are obsolete or exceptional?</p><h3>What changed?</h3><p>Which significant decisions shaped the current state?</p><h3>What should happen next?</h3><p>Which process, validation and governance steps apply to the requested change?</p><p>If engineers and AI assistants cannot answer these questions reliably, the organisation does not simply have a documentation gap.</p><p>It has an organisational memory gap.</p><h3>Final thought</h3><p>Every engineering organisation creates knowledge.</p><p>Very few preserve it consistently.</p><p>Fewer still make it reusable.</p><p>The organisations that benefit most from AI will not necessarily be the ones with the largest models, the longest context windows or the most autonomous agents.</p><p>They will be the ones that build better engineering systems.</p><p>Systems that preserve decisions.</p><p>Systems that keep knowledge current.</p><p>Systems that distinguish trusted patterns from convenient examples.</p><p>Systems that help every engineer — and every AI session — start from something stronger than the one before.</p><p>The real competitive advantage will not be artificial intelligence alone.</p><p>It will be institutional intelligence.</p><p><em>This article reflects early, anonymised observations from internal experimentation. The concepts are intentionally vendor-neutral and do not describe proprietary repository structures, internal tools or production architecture. Human review remained mandatory throughout the workflows discussed.</em></p><p>I am continuing to test how structured engineering knowledge can improve repository navigation, onboarding, governance and AI-assisted platform work. I would be interested to hear how other engineering teams are approaching organisational context and engineering memory in their AI workflows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3165381285f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Saved a Quarter-Million a Year on Cloud Bills Just by Right-Sizing Infrastructure]]></title>
            <link>https://medium.com/@aneeqr25/how-i-saved-a-quarter-million-a-year-on-cloud-bills-just-by-right-sizing-infrastructure-2a55152ec248?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a55152ec248</guid>
            <category><![CDATA[platform-engineering]]></category>
            <category><![CDATA[cloud-cost-optimization]]></category>
            <category><![CDATA[cloud-finops]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 17:43:37 GMT</pubDate>
            <atom:updated>2026-02-10T17:43:37.314Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wqiLo3ibuK0X49k4vg8BOQ.png" /></figure><h3>The Most Expensive Cloud Bills Don’t Look Expensive at First</h3><p>In large enterprises, especially regulated environments, cloud overspend rarely comes from flashy mistakes. It comes from <strong>quiet, invisible inefficiencies</strong>.</p><p>No alarms go off.<br>Nothing breaks.<br>Finance only notices months later.</p><p>I’ve seen teams burn hundreds of thousands annually not because they scaled too much, but because they <strong>never questioned how resources were chosen in the first place</strong>.</p><p>This article isn’t about cutting corners.<br> It’s about <strong>engineering discipline</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3p2PLaTsJbf099Dc2NhxQ.png" /></figure><p>Two areas consistently hide the biggest cost leaks:</p><ul><li>Unoptimized <strong>BigQuery queries</strong></li><li>Over-provisioned <strong>Dataproc / Vertex AI infrastructure</strong></li></ul><p>Fixing both didn’t require new tools, discounts, or negotiations.<br> It required understanding how the systems actually work.</p><h3>BigQuery: When “It Works” Is the Most Expensive Outcome</h3><p>BigQuery is deceptively easy to use. That’s both its strength and its biggest financial risk.</p><p>In corporate environments, analysts and engineers often:</p><ul><li>Query massive date ranges “just in case”</li><li>Use SELECT *</li><li>Ignore partition pruning</li><li>Treat BigQuery as a traditional database</li></ul><p>The result?<br> Queries that scan <strong>months of data</strong> when only <strong>days are needed</strong>.</p><p>BigQuery charges by <strong>data scanned</strong>, not by result size.<br> So even if a query returns 10 rows, it may still scan terabytes.</p><h3>Why Quotas Don’t Solve the Problem</h3><p>A common reaction is to introduce:</p><ul><li>Daily query quotas</li><li>Project-level caps</li><li>User limits</li></ul><p>These controls help, but they <strong>don’t fix inefficient queries</strong>.</p><p>An unoptimized query will still:</p><ul><li>Consume the entire daily quota</li><li>Block legitimate workloads</li><li>Create friction between teams</li></ul><p>Quotas treat the symptom.<br> Optimization treats the disease.</p><h3>What Actually Saves Money in BigQuery</h3><p>The biggest cost reductions I’ve seen came from <strong>query discipline</strong>, not restrictions.</p><p>Key principles:</p><ul><li>Always filter on <strong>partitioned columns</strong></li><li>Avoid scanning historical data unless required</li><li>Replace SELECT * with explicit fields</li><li>Understand clustering and how filters are applied</li><li>Educate users on <em>why</em> a query is expensive</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RQThyhNbdWR0wDBas-pPeQ.png" /></figure><p>This is “hidden money”:</p><ul><li>No one notices day to day</li><li>Costs compound silently</li><li>Savings show up only after months</li></ul><p>Once teams internalize this, BigQuery bills stabilize naturally.</p><h3>The Bigger Leak: Over-Provisioned Data &amp; ML Infrastructure</h3><p>The second — and often larger — problem lives in <strong>Dataproc and ML environments.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_thjZVWTZ_43YgK3HI5GQw.png" /></figure><p>A pattern I’ve repeatedly seen:</p><ul><li>Architecture designed for worst-case scenarios</li><li>Massive machine types “to be safe”</li><li>High node counts with low utilization</li><li>No feedback loop from real workloads</li></ul><p>The infrastructure looks impressive.<br> The utilization metrics tell a different story.</p><h3>A Common Anti-Pattern in Cluster Design</h3><p>A typical setup I’ve encountered looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCdt8N8alGWYDwTaYV3ZSQ.png" /></figure><ul><li>Large master node with excessive memory</li><li>Large worker nodes</li><li>Double-digit worker count</li><li>Minimal autoscaling logic</li></ul><p>On paper, it feels robust.<br> In reality:</p><ul><li>The master node is mostly idle</li><li>Only a fraction of workers do real work</li><li>Costs scale linearly, performance does not</li></ul><p>This is not a tooling issue.<br> It’s a misunderstanding of <strong>how Dataproc and YARN actually behave</strong>.</p><h3>Right-Sizing by Understanding the System (Not Guessing)</h3><p>The fix wasn’t downsizing blindly.<br> It was <strong>designing intentionally</strong>.</p><h3>1. Right-Sizing the Master Node</h3><p>The master node:</p><ul><li>Receives job submissions</li><li>Coordinates scheduling</li><li>Does not perform heavy computation</li></ul><p>Oversizing it is one of the most common mistakes.</p><p>A smaller, well-chosen master:</p><ul><li>Performs identically</li><li>Costs dramatically less</li><li>Has zero impact on job execution</li></ul><p>This single change often removes a large fixed cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNg3E8EttxUt51N6W5t_Gw.png" /></figure><h3>2. Separating Baseline Capacity from Burst Capacity</h3><p>Instead of many large workers, the approach becomes:</p><ul><li>A <strong>small number of stable primary workers</strong></li><li>A <strong>separate pool of preemptible workers</strong> for bursts</li></ul><p>Baseline workers:</p><ul><li>Handle predictable workloads</li><li>Keep the cluster responsive</li></ul><p>Preemptible workers:</p><ul><li>Scale from zero when parallelism is needed</li><li>Absorb heavy processing</li><li>Disappear when no longer required</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjuw7ZFftaseH_AmshdOXg.png" /></figure><p>You pay for power <strong>only when you actually use it</strong>.</p><h3>3. Autoscaling That Reflects Real Demand</h3><p>Autoscaling isn’t just a checkbox.</p><p>A well-designed policy:</p><ul><li>Keeps minimum workers low</li><li>Scales preemptibles only when pressure increases</li><li>Prevents idle compute during quiet periods</li></ul><p>This turns the cluster into an <strong>elastic system</strong>, not a fixed tax.</p><h3>Where Most of the Money Is Actually Saved: Spark &amp; YARN Tuning</h3><p>This is the part many architectures completely skip.</p><p>Even with fewer nodes, costs explode if:</p><ul><li>Executors don’t fit the machine shape</li><li>Memory overheads are misconfigured</li><li>YARN allocates resources inefficiently</li></ul><p>Key areas that matter:</p><ul><li>Executor memory vs cores</li><li>Driver memory sizing</li><li>Executor and driver memory overhead</li><li>Auto-broadcast join thresholds</li><li>YARN NodeManager memory limits</li><li>Scheduler maximum allocation</li><li>Logging and observability for feedback</li></ul><p>When these are aligned:</p><ul><li>Fewer nodes do more work</li><li>Executors stop wasting memory</li><li>Jobs complete faster with lower cost</li></ul><p>This is where engineering skill pays dividends.</p><h3>The Real Lesson: Cost Optimization Is an Engineering Skill</h3><p>What saved the money wasn’t:</p><ul><li>Cheaper machines</li><li>Vendor discounts</li><li>Aggressive quotas</li></ul><p>It was:</p><ul><li>Understanding workload behavior</li><li>Designing for utilization, not fear</li><li>Matching resources to reality</li></ul><p>The same jobs ran.<br> The same outcomes were delivered.<br> The bill changed dramatically.</p><h3>Practical Takeaways</h3><p>If you want to avoid silent cloud overspend:</p><ul><li>Treat query optimization as part of engineering quality</li><li>Design BigQuery tables and queries intentionally</li><li>Stop oversizing master nodes by default</li><li>Separate baseline and burst compute</li><li>Use preemptibles where failure is acceptable</li><li>Tune Spark and YARN before adding nodes</li><li>Measure utilization before scaling hardware</li></ul><p>Right-sizing isn’t about being cheap.<br> It’s about being <strong>competent</strong>.</p><h3>Final Thought</h3><p>In large organizations, cloud costs don’t spiral because teams are careless.<br> They spiral because systems are designed once — and never questioned again.</p><p>Right-sizing is one of the few optimizations that:</p><ul><li>Improves performance</li><li>Reduces cost</li><li>Strengthens reliability</li></ul><p>And once you see it, you can’t unsee it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a55152ec248" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Career Transition Handbook: From Zero to Cloud Engineer]]></title>
            <link>https://medium.com/@aneeqr25/career-transition-handbook-from-zero-to-cloud-engineer-072f49130361?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/072f49130361</guid>
            <category><![CDATA[vpc]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Sat, 26 Jul 2025 14:44:06 GMT</pubDate>
            <atom:updated>2025-07-26T14:45:23.403Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*epNJbD5ShhAh8HN5LvDrng.png" /></figure><p>Welcome to your <strong>career transition playbook</strong> — a <strong>beginner-to-job-ready guide</strong> to help you break into <strong>Cloud Engineering</strong>, even if you’re starting from a <strong>technical support background</strong> or have <strong>no prior cloud experience</strong>.</p><p>This guide isn’t just written by theory-driven experts — it’s authored from <strong>lived experience</strong>.</p><p>I started my journey in <strong>cloud support</strong>, transitioned into <strong>cloud engineering</strong>, moved through the ranks to become a <strong>systems engineer</strong>, and now serve as a <strong>DevOps Tech Lead</strong> and <strong>interview</strong> for DevOps and Cloud Engineering roles. Along the way, I’ve helped dozens of professionals pivot into cloud through <strong>mentorship</strong>, <strong>project-based coaching</strong>, and <strong>real-world insights</strong> that bridge the gap between “learning the cloud” and <strong>getting hired</strong>.</p><h3>Introduction</h3><p>This guide is a <strong>career transition handbook into cloud engineering</strong> that t<strong>argets beginners</strong> or people currently in <strong>technical support or non-engineering roles</strong></p><p>Is written from <strong>three expert perspectives</strong>:</p><ul><li>This guide is built from <strong>three lenses</strong>:</li><li>A <strong>Professional Cloud Engineer</strong> — focusing on the exact technologies you’ll use on the job</li><li>A <strong>Career Coach</strong> — providing learning paths, strategy, and mindset for career changers</li><li>An <strong>HR/Talent Acquisition Insider</strong> — explaining what hiring managers are <em>really</em> looking for in junior engineers</li><li>Prioritizes <strong>real-world, job-focused skills</strong></li><li>Is <strong>heavily project-based</strong> — learn by <strong>building</strong></li><li>Provides <strong>two curated resources per concept</strong>:</li><li>A video/article <strong>explaining the concept</strong></li><li>A <strong>hands-on project</strong> using that concept</li><li>Helps you build a<strong> public portfolio (GitHub + LinkedIn</strong>)</li><li>Prepares you for <strong>technical interviews</strong></li></ul><p>Let’s begin the journey.</p><h3>“Do I Need to Know AWS, Azure, or GCP?”</h3><p>The answer? <strong>Pick one. Master it.</strong><br> Cloud platforms may look different on the outside, but under the hood, <strong>they all offer the same core services</strong>: compute, storage, networking, identity, and automation. I started as an AWS expert and have been working in <strong>GCP</strong> for years — the transition was <strong>natural</strong> because <strong>the fundamentals stay the same</strong>. Whether it’s <strong>EC2 or Compute Engine</strong>, <strong>S3 or Cloud Storage</strong>, the <strong>concepts are transferable</strong>.</p><blockquote><em>Once you master one provider, </em><strong><em>switching becomes a UI and syntax change</em></strong><em>, not a total restart.</em></blockquote><h3>What This Guide Will Give You</h3><ul><li>A <strong>clear path</strong> from zero to employable</li><li>Deep understanding of <strong>in-demand cloud technologies</strong> like EC2, S3, IAM, VPC, Lambda, ECS, and more</li><li>A focus on <strong>real-world projects</strong> — because job-readiness comes from building, not watching</li><li><strong>Curated resources</strong>: each topic includes an explanation + a hands-on project tutorial</li><li><strong>Portfolio and resume guidance</strong> — so you can confidently apply and stand out</li></ul><p>Whether you’re aiming to be a <strong>Cloud Engineer</strong>, <strong>DevOps Engineer</strong>, or eventually a <strong>Tech Lead</strong>, this guide will help you <strong>get unstuck</strong>, <strong>build real experience</strong>, and <strong>start applying with confidence</strong>.</p><p>Let’s build your cloud career — one project at a time.</p><h3>SECTION 1: Cloud Career Roadmap &amp; Mindset</h3><p><strong>(From the Career Coach’s Perspective)</strong></p><h3>Why Cloud Engineering Is a Great Pivot</h3><ul><li>💼 High demand across all industries</li><li>🌎 Remote-friendly with global job access</li><li>💰 Junior salaries often exceed £45,000+ per anum</li><li>📈 Strong growth path into DevOps, SRE, Security, and Architecture</li></ul><h3>🪜 Beginner-Friendly Learning Path</h3><p>StageFocus AreaTools/Concepts</p><p>1️⃣Cloud FoundationsAWS, IAM, S3, EC2</p><p>2️⃣Networking &amp; InfrastructureVPC, Route 53, Load Balancers</p><p>3️⃣Compute &amp; ContainersEC2, ECS, Lambda</p><p>4️⃣DevOps &amp; AutomationIAM, CloudFormation, CI/CD</p><p>5️⃣Projects &amp; PortfolioGitHub, Terraform, Multi-service builds</p><p>6️⃣Job Hunt PrepResume, LinkedIn, Interviews</p><p>✅ <em>Note: You don’t need to master everything before applying for jobs. 60–70% is enough, especially with strong projects.</em></p><h3>⚙️ SECTION 2: Core Skills &amp; Projects</h3><p>For each key AWS concept, you’ll find:</p><ul><li>🔍 <strong>What It Is (Beginner Explanation)</strong></li><li>🔗 <strong>Intro Video or Article</strong></li><li>🛠️ <strong>Hands-On Project Tutorial</strong></li></ul><h3>1. 🌐 Amazon EC2 — Virtual Servers in the Cloud</h3><ul><li><strong>What It Is:</strong> Elastic Compute Cloud (EC2) lets you run virtual servers in AWS.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=lZMkgOMYYIg">EC2 Explained Simply — FreeCodeCamp (YouTube)</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=tlTdbc5byAs">Host a Website on EC2 (YouTube Tutorial)</a></li></ul><h3>2. 📦 Amazon S3 — Object Storage</h3><ul><li><strong>What It Is:</strong> Simple Storage Service (S3) is scalable cloud storage for files, backups, static websites, etc.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=6jbrj0zZ_KQ">AWS S3 for Beginners — ByteByteGo (YouTube)</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=ZV1cGvRW3pE">Deploy Static Website to S3 + Enable CDN + HTTPS (YouTube)</a></li></ul><h3>3. 🔐 IAM — Identity and Access Management</h3><ul><li><strong>What It Is:</strong> Manage users, roles, and permissions securely.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=F0H6wZV3dro">IAM in AWS Explained — TechWorld with Nana</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=EVgN4nlnZZc">Create IAM Roles &amp; Secure S3 Buckets (YouTube)</a></li></ul><h3>4. 🛰️ Route 53 — DNS Management</h3><ul><li><strong>What It Is:</strong> AWS’s Domain Name System service for routing traffic.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=h8KXk40lZBQ">Route 53 in Plain English — AWS Simplified</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=eBW7Qz6DDUk">Connect Custom Domain to S3 Site using Route 53 (YouTube)</a></li></ul><h3>5. 🕸️ VPC — Virtual Private Cloud</h3><ul><li><strong>What It Is:</strong> Isolated AWS network environment. Fundamental for securing your resources.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=Vb3IuSCGcHc">VPC Basics for Beginners — FreeCodeCamp</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=k9TUPpGqYTo">Build a Secure VPC with Subnets, NAT, and EC2 (YouTube)</a></li></ul><h3>6. 🐳 ECS — Elastic Container Service</h3><ul><li><strong>What It Is:</strong> Run Docker containers on AWS using ECS.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=-Wfllq1kZSU">ECS in AWS Explained — ByteByteGo</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=Gnxcw9gVuZQ">Deploy Docker App to ECS Fargate (YouTube)</a></li></ul><h3>7. ⚙️ Lambda — Serverless Compute</h3><ul><li><strong>What It Is:</strong> Run code without managing servers.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=eOBq__h4OJ4">AWS Lambda Basics — AWS Official</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=usm5L6fS1PI">Build a Serverless API with Lambda + API Gateway (YouTube)</a></li></ul><h3>8. 🧱 CloudFormation — Infrastructure as Code</h3><ul><li><strong>What It Is:</strong> Define cloud resources in YAML/JSON to automate deployments.</li><li>🔗 <strong>Intro Video:</strong> <a href="https://www.youtube.com/watch?v=Ia-UEYYR44s">CloudFormation Basics — Nana</a></li><li>🛠️ <strong>Project:</strong> <a href="https://www.youtube.com/watch?v=I1JGXWTV2_E">Deploy EC2 &amp; S3 with CloudFormation Template (YouTube)</a></li></ul><h3>🧩 Bonus: DevOps Tools You’ll Eventually Use</h3><p>GitHubProject hosting</p><p>Terraform Infra as Code (like CloudFormation)</p><p>Jenkins / GitHub ActionsCI/CD automation</p><p>CloudWatchMonitoring</p><h3>💼 SECTION 3: Job Prep &amp; Landing Interviews</h3><p><strong>(From the HR &amp; Recruiter’s Perspective)</strong></p><h3>📁 Build Your Portfolio</h3><p>Host all projects on <strong>GitHub</strong> with:</p><p>📌 README files explaining what you did</p><p>📸 Screenshots</p><p>📎 Architecture Diagrams (use draw.io or Excalidraw)</p><p>Include:</p><p>✅ S3 static site</p><p>✅ EC2-hosted app</p><p>✅ IAM secure setup</p><p>✅ Docker to ECS project</p><p>✅ Lambda + API Gateway serverless project</p><h3>🧾 Resume Tips</h3><ul><li>Use <strong>achievement-driven bullets</strong>:</li><li>“Designed and deployed a static website using S3, Route 53, and IAM policies to secure content.”</li><li>Tools Section: List AWS services and tools used</li><li>Projects Section: Link to your GitHub</li></ul><h3>🧑‍💻 Mock Interview Practice</h3><ul><li>Use <strong>free mock interview platforms</strong>: Pramp, Interviewing.io</li><li>Practice explaining:</li><li>How EC2 works and when to use it</li><li>Why S3 is better than storing files on a server</li><li>How IAM prevents security issues</li></ul><h3>🌐 LinkedIn Optimization</h3><ul><li>Headline: “Aspiring Cloud Engineer | AWS Practitioner | Building on EC2, S3, Lambda”</li><li>About: Mention career pivot, what you’re building, and your future goals</li><li>Share projects weekly → “Built a serverless API using AWS Lambda and API Gateway!”</li></ul><h3>📦 Certifications That Help</h3><ul><li>🟢 <strong>AWS Certified Cloud Practitioner</strong> — (Beginner friendly)</li><li>🔵 <strong>AWS Certified Solutions Architect — Associate</strong> — (After doing projects)</li></ul><h3>Final Words (From All 3 Perspectives)</h3><blockquote><em>🧑‍💻 </em><strong><em>Engineer:</em></strong><em> “The best way to learn cloud is to build. Don’t overthink, just ship projects.”</em></blockquote><blockquote><em>🎯 </em><strong><em>Coach:</em></strong><em> “Progress beats perfection. You don’t need to know everything. You need to show something.”</em></blockquote><blockquote><em>👥 </em><strong><em>HR:</em></strong><em> “We hire for demonstrated skills. A solid GitHub with cloud projects speaks louder than any resume line.”</em></blockquote><h3>Conclusion: Your Future in Cloud Starts Now</h3><p>Transitioning into cloud engineering isn’t reserved for computer science graduates or industry veterans — it’s for anyone willing to learn, build, and grow. Whether you’re coming from technical support or an unrelated field, this guide has shown you that the <strong>path is clear</strong>, <strong>achievable</strong>, and <strong>in-demand</strong>.</p><p>You don’t need to know everything. You need to <strong>start with the core</strong>, <strong>build real projects</strong>, and <strong>show your work</strong>. Every tool you master, every problem you solve, and every project you complete brings you closer to landing that first cloud role — and from there, the sky’s the limit.</p><p><strong>I’ve walked this path</strong> — from cloud support to cloud engineer, systems engineer, DevOps engineer, and now a DevOps tech lead interviewing the next wave of engineers. If I could do it, you can too — and this guide is your launchpad.</p><p>Start building.<br> Keep learning.<br> Share your journey.<br> The cloud is waiting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=072f49130361" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ensuring Fair Code Reviews: How to Block Self-Approval in GitHub Pull Requests]]></title>
            <link>https://medium.com/@aneeqr25/ensuring-fair-code-reviews-how-to-block-self-approval-in-github-pull-requests-6338341e4765?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6338341e4765</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[sdlc-methodologies]]></category>
            <category><![CDATA[github-pull-request]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 15:38:23 GMT</pubDate>
            <atom:updated>2025-07-21T15:38:23.459Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yd4dyHU5kp_jDBSE" /></figure><h3>Introduction</h3><p>In the world of collaborative software development, maintaining code quality and ensuring unbiased code reviews are paramount. One common challenge teams face is the potential for contributors to approve their own pull requests (PRs), which can lead to conflicts of interest and compromise the integrity of the review process. To address this issue, implementing a workflow that blocks self-approval in GitHub can be a game-changer. In this article, we will explore a GitHub Actions workflow designed specifically to prevent a pull request from being approved and merged by anyone who has also contributed code to that PR. We will break down each component of the workflow, explaining its purpose and functionality in a way that is accessible to developers of all skill levels. By the end, you’ll have a clear understanding of how to implement this workflow in your own projects, ensuring a fair and thorough code review process.</p><pre># This workflow prevents a pull request from being approved and merged by someone who also contributed code (i.e., made a commit) to that same PR.<br><br>name: Block PR Approval by Committers<br>on:<br>  pull_request:<br>    types: [opened, synchronize, reopened]<br>  pull_request_review:<br>    types: [submitted, edited]<br>jobs:            <br>  block_self_approval:   <br>    runs-on: ubuntu_latest<br>    steps:<br>      - name: Get list of committers<br>        id: commiters<br>        run: | <br>          commits_url=&quot;${{ github.event.pull_request.commits_url }}&quot;<br>          commiters=$(curl -k -s -H &quot;Authorization: token ${{ secrets.TEMPLATE_SYNC_GITHUB_TOKEN }}&quot; \<br>              &quot;$commits_url&quot; | jq -r &#39; .[].author.login&#39; | sort -u | paste -sd &quot;,&quot; -)<br>          echo &quot;commiters=$commiters&quot; &gt;&gt; $GITHUB_OUTPUT<br><br>      - name: Get list of approvers<br>        id: approvers<br>        run: | <br>          pr_number=${{ github.event.pull_request.number || github.event.pull_request_review.pull_request.number }}<br>          repo=${{ github.repository }}<br>          reviews_url=&quot;https://api.github.com/repos/$repo/pulls/$pr_number/reviews&quot;<br>          approvers=$(curl -k -s -H &quot;Authorization: token ${{ secrets.TEMPLATE_SYNC_GITHUB_TOKEN }}&quot; &quot;$reviews_url&quot; \<br>               | jq -r &#39;[.[] | select(.state==&quot;APPROVED&quot;)] | .[].user.login&#39; | sort -u | paste -sd &quot;,&quot; -)<br>          echo &quot;approvers=$approvers&quot; &gt;&gt; $GITHUB_OUTPUT<br><br>      - name: Check if any approvers is a commiter<br>        run: | <br>          echo &quot;Commiters: ${{ steps.commiters.outputs.commiters }}&quot;<br>          echo &quot;Approvers: ${{ steps.approvers.outputs.approvers }}&quot;<br><br>          IFS=&#39;,&#39; read -ra commiter_list &lt;&lt;&lt; &quot;${{ steps.commiters.outputs.commiters }}&quot;<br>          IFS=&#39;,&#39; read -ra approver_list &lt;&lt;&lt; &quot;${{ steps.approvers.outputs.approvers }}&quot;<br>        <br>          echo &quot;Checking for conflict between commiters and approvers...&quot;<br>          conflict=0<br>          for approver in &quot;${approver_list[@]}&quot;; do<br>            for commiter in &quot;${commiter_list[@]}&quot;; do<br>              if [[ &quot;$approver&quot; == &quot;$commiter&quot; ]]; then<br>                echo &quot;Conflict: $approver is both a commiter and an approver!&quot;<br>                conflict=1<br>              fi<br>            done<br>          done<br><br>          if [[ $conflict -eq 1 ]]; then<br>            echo &quot;Error: PR has approval(s) from commit author(s). Not allowed.&quot;<br>            exit 1<br>          else<br>            echo &quot;All approvers are valid (not commiters).&quot;<br>          fi</pre><h4>Overview of the Workflow</h4><p>This GitHub Actions workflow is designed to prevent a pull request (PR) from being approved and merged by someone who has also contributed code to that PR. This is a common practice to ensure code reviews are unbiased and maintain code quality.</p><p>Workflow Name and Trigger Events</p><ul><li>Name: The workflow is named “Block PR Approval by Committers”.</li><li>Triggers:</li><li>The workflow is triggered on specific events:</li><li>When a pull request is opened, synchronized (updated), or reopened.</li><li>When a pull request review is submitted or edited.</li></ul><p>Jobs Section</p><ul><li>Job Definition: The workflow contains a single job named block_self_approval.</li><li>Execution Environment:</li><li>The job runs on a specified Docker container (ubuntu_latest), which is likely set up with the necessary tools and environment for executing the steps.</li></ul><p>Steps Breakdown</p><ol><li>Get List of Committers</li></ol><ul><li>Purpose: This step retrieves the list of users who have made commits to the pull request.</li><li>Process:</li><li>It constructs the URL to access the commits of the PR using the commits_url from the GitHub event context.</li><li>It uses curl to make an API request to GitHub, passing an authorization token for access.</li><li>The response is processed with jq to extract the usernames of the commit authors, which are then sorted and combined into a single string.</li><li>Finally, the list of committers is saved to the GitHub output for use in later steps.</li></ul><ol><li>Get List of Approvers</li></ol><ul><li>Purpose: This step retrieves the list of users who have approved the pull request.</li><li>Process:</li><li>It determines the pull request number from the event context.</li><li>It constructs the URL to access the reviews of the PR.</li><li>Similar to the previous step, it uses curl to fetch the reviews and jq to filter out the usernames of users who have approved the PR.</li><li>The list of approvers is also saved to the GitHub output.</li></ul><ol><li>Check for Conflicts Between Committers and Approvers</li></ol><ul><li>Purpose: This step checks if any of the approvers are also committers to the PR.</li><li>Process:</li><li>It retrieves the lists of committers and approvers from the outputs of the previous steps.</li><li>It splits these lists into arrays for easier comparison.</li><li>A nested loop checks each approver against each committer to find any conflicts.</li><li>If a conflict is found (i.e., an approver is also a committer), an error message is printed, and the workflow exits with a failure status.</li><li>If no conflicts are found, a success message is printed.</li></ul><p>Error Handling</p><ul><li>The workflow includes error handling to ensure that if a conflict is detected, it will not allow the PR to be approved by someone who has contributed code to it. This is crucial for maintaining the integrity of the code review process.</li></ul><h4>Conclusion</h4><p>In summary, the implementation of a workflow that blocks self-approval in GitHub pull requests is a crucial step in maintaining the integrity of the software development lifecycle (SDLC). By ensuring that contributors cannot approve their own changes, we mitigate the risk of conflicts of interest and uphold the quality of code reviews. This workflow effectively prevents any user who has made a commit in the feature branch from being able to approve the PR, thereby reinforcing accountability and transparency within the development process. As teams strive for excellence in their code quality and collaboration, adopting such practices not only enhances the review process but also fosters a culture of trust and diligence. By integrating this workflow into your projects, you can safeguard against potential SDLC control failures and ensure that every code change is subject to thorough and impartial scrutiny.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6338341e4765" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AHYBRID061 Securing Traffic with Anthos Service Mesh]]></title>
            <link>https://medium.com/@aneeqr25/ahybrid061-securing-traffic-with-anthos-service-mesh-683f02b63571?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/683f02b63571</guid>
            <category><![CDATA[anthos-service-mesh]]></category>
            <category><![CDATA[anthos]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cloud-security]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Mon, 09 Dec 2024 11:46:59 GMT</pubDate>
            <atom:updated>2024-12-09T11:46:59.314Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1yM1uTxYaNhxfR0M.png" /></figure><h3>Overview</h3><p>Anthos Service Mesh security helps you mitigate insider threats and reduce the risk of a data breach by ensuring that all communications between workloads are encrypted, mutually authenticated, and authorized.</p><p>In this lab, you learn how PERMISSIVE mode mTLS allows services to receive both plaintext and mTLS traffic from clients, allowing you to incrementally adopt mTLS. You also enabled STRICT mode mTLS across your service mesh effectively blocking plaintext traffic to all your Istio injected services and then you scoped STRICT mode mTLS down to a single namespace</p><h3>Objectives</h3><p>In this lab, you learn how to perform the following tasks:</p><ul><li>Enforce STRICT mTLS mode across the service mesh</li><li>Enforce STRICT mTLS mode on a single namespace</li><li>Explore the security configurations in the Anthos Service Mesh Dashboard</li><li>Add authorization policies to enforce access based on a JSON Web Token (JWT)</li><li>Add authorization policies for HTTP traffic in an Istio mesh</li></ul><h3>Setup and requirements</h3><p>login to gcp console, open cloud shell and authenticate to project by running the command</p><pre>gcloud config set project &quot;PROJECT_ID&quot;</pre><h3>Task 1. Confirm Anthos Service Mesh setup</h3><ul><li>This lab environment has already been partially configured. A GKE cluster with 2 nodes has been provisioned for you. If you would like to investigate how the cluster creation process happened, look at the <strong>setup-vm</strong> startup-script.</li></ul><p>Configure cluster access for kubectl</p><ul><li>Set the Zone environment variable:</li></ul><pre>CLUSTER_ZONE=&quot;Zone added at lab start&quot;</pre><ul><li>Set environment variables for the zone and cluster name:</li></ul><pre>export CLUSTER_NAME=gke</pre><ul><li>In Cloud Shell, configure <strong>kubectl</strong> command line access by running:</li></ul><pre># get the project id<br>export GCLOUD_PROJECT=$(gcloud config get-value project)<br><br># configure kubectl<br>gcloud container clusters get-credentials $CLUSTER_NAME \<br>    --zone $CLUSTER_ZONE --project $GCLOUD_PROJECT</pre><p>Verify cluster and Anthos Service Mesh installation</p><ul><li>Check that your cluster is up and running:</li></ul><pre>gcloud container clusters list</pre><p><strong>Output:</strong></p><pre>NAME: gke<br>LOCATION: &quot;ZONE&quot;<br>MASTER_VERSION: 1.28.8-gke.1095000<br>MASTER_IP: 35.186.181.121<br>MACHINE_TYPE: e2-standard-2<br>NODE_VERSION: 1.28.8-gke.1095000<br>NUM_NODES: 3<br>STATUS: RUNNING   </pre><ul><li>Ensure the following Kubernetes <strong>istiod</strong> services are deployed:</li></ul><pre>kubectl get service -n istio-system</pre><p><strong>Output:</strong></p><pre>NAME                      TYPE             CLUSTER-IP<br>istiod-asm-1153-6         ClusterIP        10.7.249.134<br>istiod                    ClusterIP        10.7.249.95</pre><ul><li>Ensure the corresponding Kubernetes <strong>istiod-*</strong> pods are deployed and all containers are up and running:</li></ul><pre>kubectl get pods -n istio-system</pre><p><strong>Output:</strong></p><pre>NAME                                      READY   STATUS<br>istiod-asm-1153-6-6d66584796-865d8        1/1     Running<br>istiod-asm-1153-6-6d66584796-bph5h        1/1     Running<br>...</pre><h3>Task 2. Deploy sleep and httpbin services</h3><ul><li>In this task, you create a set of namespaces to host the <a href="https://github.com/istio/istio/tree/release-1.6/samples/httpbin">httpbin</a>, and <a href="https://github.com/istio/istio/tree/release-1.6/samples/sleep">sleep</a> services. You will use those services to explore the impact of mTLS on traffic. The <strong>sleep</strong> service acts as the client and will call the <strong>httpbin</strong> service, which acts as a server.</li><li>Setup the authentication example</li><li>You will deploy this example configuration and then use it to explore the authentication options that Istio offers:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/0*sr3cnySqPwPTMpKE" /></figure><ul><li>In Cloud Shell, create namespaces for the example clients and services. Traffic in the <strong>legacy-</strong>* namespaces takes place over plain text, while traffic in the <strong>mtls-</strong>* namespaces happens over mTLS:</li></ul><pre>kubectl create ns mtls-client<br>kubectl create ns mtls-service<br>kubectl create ns legacy-client<br>kubectl create ns legacy-service<br><br>kubectl get namespaces</pre><ul><li><strong>Output:</strong></li></ul><pre>NAME              STATUS   AGE<br>...<br>legacy-client     Active   5m50s<br>legacy-service    Active   5m34s<br>mtls-client       Active   5m56s<br>mtls-service      Active   5m40s</pre><ul><li>Deploy the legacy services in the <strong>legacy-</strong>* namespaces. You call them legacy because they are not part of the mesh:</li></ul><pre>#configurations are stored in Github<br><br>kubectl apply -f \<br>https://raw.githubusercontent.com/istio/istio/release-1.6/samples/sleep/sleep.yaml \<br>-n legacy-client<br><br>kubectl apply -f \<br>https://raw.githubusercontent.com/istio/istio/release-1.6/samples/httpbin/httpbin.yaml \<br>-n legacy-service</pre><ul><li>Enable auto-injection of the Istio sidecar proxy on the <strong>mtls-</strong>* namespaces:</li></ul><pre># get the revision label<br>export DEPLOYMENT=$(kubectl get deployments -n istio-system | grep istiod)<br>export VERSION=asm-$(echo $DEPLOYMENT | cut -d&#39;-&#39; -f 3)-$(echo $DEPLOYMENT \<br>    | cut -d&#39;-&#39; -f 4 | cut -d&#39; &#39; -f 1)<br><br># enable auto-injection on the namespaces<br>kubectl label namespace mtls-client istio.io/rev=${VERSION} --overwrite<br>kubectl label namespace mtls-service istio.io/rev=${VERSION} --overwrite</pre><ul><li>Deploy the services in the <strong>mtls-</strong>* namespaces:</li></ul><pre>kubectl apply -f \ https://raw.githubusercontent.com/istio/istio/release-1.6/samples/sleep/sleep.yaml \ -n mtls-client kubectl apply -f \ https://raw.githubusercontent.com/istio/istio/release-1.6/samples/httpbin/httpbin.yaml \ -n mtls-service</pre><ul><li>Verify that the <strong>sleep</strong> service and the <strong>httpbin</strong> service are each deployed in both the <strong>mtls-service</strong> and <strong>legacy-service</strong> namespaces:</li></ul><pre>kubectl get services - all-namespaces</pre><ul><li><strong>Output:</strong></li></ul><pre>NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE … legacy-client sleep ClusterIP 10.7.248.186 80/TCP 31s legacy-service httpbin ClusterIP 10.7.248.121 8000/TCP 14s mtls-client sleep ClusterIP 10.7.252.127 80/TCP 99s mtls-service httpbin ClusterIP 10.7.247.200 8000/TCP 50s</pre><ul><li>Verify that a <strong>sleep</strong> pod is running in the <strong>mtls-client</strong> and <strong>legacy-client</strong>namespaces and that an <strong>httpbin</strong> pod is running in the <strong>mtls-service</strong> and <strong>legacy-service</strong> namespaces:</li></ul><pre>kubectl get pods - all-namespaces</pre><p><strong>Output:</strong></p><pre>NAMESPACE NAME READY STATUS RESTARTS AGE … legacy-client sleep-f8cbf5b76–5v8f9 1/1 Running 0 65s legacy-service httpbin-779c54bf49–5fr9k 1/1 Running 0 47s mtls-client sleep-64d4546bdb-gnpc5 2/2 Running 0 2m13s mtls-service httpbin-5d7bdc9d78–7mfn5 2/2 Running 0 84s</pre><ul><li>Verify that the two sleep clients can communicate with the two httpbin services</li><li>Use Cloud Shell to run this nested command loop:</li></ul><pre>for from in &quot;mtls-client&quot; &quot;legacy-client&quot;; do for to in &quot;mtls-service&quot; &quot;legacy-service&quot;; do kubectl exec $(kubectl get pod -l app=sleep -n ${from} -o jsonpath={.items..metadata.name}) -c sleep -n ${from} - curl &quot;http://httpbin.${to}:8000/ip&quot; -s -o /dev/null -w &quot;sleep.${from} to httpbin.${to}: %{http_code}\n&quot; done done</pre><p><strong>Output:</strong></p><pre>sleep.mtls-client to httpbin.mtls-service: 200 sleep.mtls-client to httpbin.legacy-service: 200 sleep.legacy-client to httpbin.mtls-service: 200 sleep.legacy-client to httpbin.legacy-service: 200</pre><ul><li>Now you’re ready to enforce security policies for this application.</li></ul><h3>Task 3. Understand authentication and enable service to service authentication with mTLS</h3><p>Anthos Service Mesh</p><ul><li>In the console, go to <strong>Navigation Menu &gt; Kubernetes Engine &gt; Service Mesh</strong>.</li><li>In the Anthos Service Mesh dashboard, you will see the 2 services that were created in the mtls-service and mtls-client/sleep namespaces. You don&#39;t see the legacy services because you did not label their namespace, and therefore they remain outside of the mesh.</li><li>In the list view section Click on <strong>&gt;</strong> icon next to <strong>httpbin</strong> (<strong>mtls-service/httpbin</strong>) namespace.</li></ul><p>Click on <strong>Go to dashboard</strong></p><ul><li>In the left side panel, go to <strong>Connected Services</strong>.</li><li>Notice that you have 2 services:</li><li>The sleep service in the mtls-client namespace, which is part of the mesh and has a sidecar proxy. Therefore you see the real name and communication goes over mTLS, as it&#39;s the default behavior in Istio.</li><li>An unknown service, which represents the sleep service in the legacy-client, which is not part of the mesh and has no sidecar proxy. Therefore you do not see the real name and the communication goes over plain text.</li><li>Use your mouse to hover over the lock symbol in the <strong>Request port</strong> column, and verify that green means mTLS and red means plain text.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kSbm0AyTFA4qkAPQ" /></figure><ul><li>Now check out the <strong>Security</strong> tab in the left side panel. It shows you that the <strong>httpbin</strong> service has received both plaintext and mTLS traffic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kHXnaidERx5e2ZCv" /></figure><ul><li>Test auto mutual TLS</li><li>By default, Istio configures destination workloads in PERMISSIVE mode. WhenPERMISSIVE mode is enabled a service can accept both plaintext and mTLS traffic. mTLS is used when the request contains the <strong>X-Forwarded-Client-Cert</strong> header.</li><li>Use the Cloud Shell to send a request from the <strong>sleep</strong> service in the <strong>mtls-client</strong>namespace to the <strong>httpbin</strong> service in the <strong>mtls-service</strong> namespace:</li></ul><pre>kubectl exec $(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name}) -c sleep -n mtls-client - curl http://httpbin.mtls-service:8000/headers -s | grep X-Forwarded-Client-Cert</pre><ul><li><strong>Output:</strong></li></ul><pre>&quot;X-Forwarded-Client-Cert&quot;: &quot;By=spiffe:// …</pre><ul><li>The traffic included the <strong>X-Forwarded-Client-Cert</strong> header and therefore was mutually authenticated and encrypted</li><li>Now send a request from the <strong>sleep</strong> service in the <strong>mtls-client</strong> namespace to the <strong>httpbin</strong> service in the <strong>legacy-service</strong> namespace:</li></ul><pre>kubectl exec $(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name}) -c sleep -n mtls-client - curl http://httpbin.legacy-service:8000/headers -s | grep X-Forwarded-Client-Cert</pre><ul><li>The <strong>X-Forwarded-Client-Cert</strong> header isn’t present so the traffic was sent and received in plaintext.</li><li>Finally, send a request from the <strong>sleep</strong> service in the <strong>legacy-client</strong> namespace to the <strong>httpbin</strong> service in the <strong>mtls-service</strong> namespace:</li></ul><pre>kubectl exec $(kubectl get pod -l app=sleep -n legacy-client -o jsonpath={.items..metadata.name}) -c sleep -n legacy-client - curl http://httpbin.mtls-service:8000/headers -s | grep X-Forwarded-Client-Cert</pre><ul><li>The <strong>X-Forwarded-Client-Cert</strong> header isn’t present so the traffic was sent and received in plaintext</li><li><strong>Note: </strong>The <strong>httpbin</strong> service in the <strong>mtls-service</strong> namespace accepted mTLS traffic from the <strong>sleep</strong> service in the <strong>mtls-client</strong> namespace and plaintext from the <strong>sleep</strong>service in the <strong>legacy-client</strong> namespace.</li><li>Enforce STRICT mTLS mode across the service mesh</li><li>In STRICT mode, services injected with the Istio proxy will not accept plaintext traffic and will mutually authenticate with their clients.</li><li>You can enforce STRICT mTLS mode across the whole mesh or on a per-namespace basis by creating PeerAuthentication resources.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/0*7eth9m9lXBlXr89S" /></figure><ul><li>Create a Peer Authentication resources for the entire Service Mesh:</li></ul><pre>kubectl apply -n istio-system -f - &lt;&lt;EOF apiVersion: &quot;security.istio.io/v1beta1&quot; kind: &quot;PeerAuthentication&quot; metadata: name: &quot;mesh-wide-mtls&quot; spec: mtls: mode: STRICT EOF</pre><ul><li>Run this nested command loop:</li></ul><pre>for from in &quot;mtls-client&quot; &quot;legacy-client&quot;; do for to in &quot;mtls-service&quot; &quot;legacy-service&quot;; do kubectl exec $(kubectl get pod -l app=sleep -n ${from} -o jsonpath={.items..metadata.name}) -c sleep -n ${from} - curl &quot;http://httpbin.${to}:8000/ip&quot; -s -o /dev/null -w &quot;sleep.${from} to httpbin.${to}: %{http_code}\n&quot; done done</pre><pre>sleep.mtls-client to httpbin.mtls-service: 200 sleep.mtls-client to httpbin.legacy-service: 200 sleep.legacy-client to httpbin.mtls-service: 000 command terminated with exit code 56 sleep.legacy-client to httpbin.legacy-service: 200</pre><ul><li><strong>Note: </strong>The <strong>httpbin</strong> service in the <strong>mtls-service</strong> namespace now rejects the plaintext traffic it receives from the <strong>sleep</strong> client in the <strong>legacy-client</strong> namespace.</li><li>Remove the mesh wide mTLS PeerAuthentication resource by running this command in Cloud Shell:</li></ul><pre>kubectl delete pa mesh-wide-mtls -n istio-system</pre><ul><li>Enforce STRICT mTLS mode on a single namespace</li><li>In Cloud Shell create a namespace for STRICT mTLS:</li></ul><pre>kubectl create ns strict-mtls-service</pre><ul><li>Enable auto-injection of the Istio sidecar proxy on the new namespace:</li></ul><pre># get the revision label export DEPLOYMENT=$(kubectl get deployments -n istio-system | grep istiod) export VERSION=asm-$(echo $DEPLOYMENT | cut -d&#39;-&#39; -f 3)-$(echo $DEPLOYMENT \ | cut -d&#39;-&#39; -f 4 | cut -d&#39; &#39; -f 1) # enable auto-injection on the namespaces kubectl label namespace strict-mtls-service istio.io/rev=${VERSION} - overwrite</pre><ul><li>Use Cloud Shell to deploy another instance of the httpbin service in the <strong>strict-mtls-service</strong> namespace:</li></ul><pre>kubectl apply -f \ https://raw.githubusercontent.com/istio/istio/release-1.6/samples/httpbin/httpbin.yaml \ -n strict-mtls-service</pre><ul><li>Create a PeerAuthentication resource for the <strong>strict-mtls-service</strong> namespace:</li></ul><pre>kubectl apply -n strict-mtls-service -f - &lt;&lt;EOF apiVersion: &quot;security.istio.io/v1beta1&quot; kind: &quot;PeerAuthentication&quot; metadata: name: &quot;restricted-mtls&quot; namespace: strict-mtls-service spec: mtls: mode: STRICT EOF</pre><ul><li>Verify that the <strong>httpbin</strong> service in the <strong>mtls-service</strong> namespace still accepts plaintext traffic:</li></ul><pre>kubectl exec $(kubectl get pod -l app=sleep -n legacy-client -o jsonpath={.items..metadata.name}) -c sleep -n legacy-client - curl &quot;http://httpbin.mtls-service:8000/ip&quot; -s -o /dev/null -w &quot;sleep.legacy-client to httpbin.mtls-service: %{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>sleep.legacy-client to httpbin.mtls-service: 200</pre><ul><li>Now check to see that the <strong>strict-mtls-service</strong> namespace <strong>httpbin</strong> service does not accept plaintext traffic:</li></ul><pre>kubectl exec $(kubectl get pod -l app=sleep -n legacy-client -o jsonpath={.items..metadata.name}) -c sleep -n legacy-client - curl &quot;http://httpbin.strict-mtls-service:8000/ip&quot; -s -o /dev/null -w &quot;sleep.legacy-client to httpbin.strict-mtls-service: %{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>sleep.legacy-client to httpbin.strict-mtls-service: 000 command terminated with exit code 56</pre><ul><li>Verify that the <strong>httpbin</strong> service in the <strong>strict-mtls-service</strong> namespace does accept mTLS traffic:</li></ul><pre>kubectl exec $(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name}) -c sleep -n mtls-client - curl &quot;http://httpbin.strict-mtls-service:8000/ip&quot; -s -o /dev/null -w &quot;sleep.mtls-client to httpbin.strict-mtls-service: %{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>sleep.mtls-client to httpbin.strict-mtls-service: 200</pre><ul><li>In the Google Cloud console, select <strong>Navigation Menu &gt; Kubernetes Engine &gt; &gt; Service Mesh</strong>.</li><li>In Anthos Service Mesh dashboard, you will see that you have 3 services now.</li><li>In the list view section Click on <strong>&gt;</strong> icon next to <strong>strict-mtls-service/httpbin</strong>namespace.</li><li>Click on <strong>Go to dashboard</strong></li><li>In the left side panel, click on <strong>Connected Services</strong>.</li><li>Use your mouse to hover over the lock symbol in the <strong>Request Port</strong> column to see that only <strong>mTLS</strong> traffic has been received. Traffic might take a couple of minutes to be reflected in the dashboard. If you don’t see the sleep service, wait 1-2 minutes and refresh the dashboard.</li><li>Now check out the <strong>Security</strong> tab in the left side panel. Again only <strong>mTLS</strong> traffic has been received.</li><li>Remove the <strong>strict-mtls-service</strong> peer authentication policy by running this command in Cloud Shell:</li></ul><pre>kubectl delete pa restricted-mtls -n strict-mtls-service</pre><h3>Task 4. Leverage RequestAuthentication and AuthorizationPolicy resources</h3><ul><li>This task shows you how to set up and use RequestAuthentication and AuthorizationPolicy resources. Ultimately, you will allow requests that have an approved JWT, and deny requests that don’t.</li></ul><p><strong>RequestAuthentication</strong></p><ul><li>A RequestAuthentication resource defines the request authentication methods that are supported by a workload. Requests with invalid authentication information will be rejected. Requests with no authentication credentials will be accepted but will not have any authenticated identity.</li><li>Create a RequestAuthentication resource for the httpbin workload in themtls-service namespace. This policy allows the workload to accept requests with a JWT issued by testing@secure.istio.io.</li></ul><pre>kubectl apply -f - &lt;&lt;EOF apiVersion: &quot;security.istio.io/v1beta1&quot; kind: &quot;RequestAuthentication&quot; metadata: name: &quot;jwt-example&quot; namespace: mtls-service spec: selector: matchLabels: app: httpbin jwtRules: - issuer: &quot;testing@secure.istio.io&quot; jwksUri: &quot;https://raw.githubusercontent.com/istio/istio/release-1.8/security/tools/jwt/samples/jwks.json&quot; EOF</pre><ul><li>Verify that a request with an invalid JWT is denied:</li></ul><pre>kubectl exec &quot;$(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name})&quot; -c sleep -n mtls-client - curl &quot;http://httpbin.mtls-service:8000/headers&quot; -s -o /dev/null -H &quot;Authorization: Bearer invalidToken&quot; -w &quot;%{http_code}\n&quot;</pre><pre>401</pre><ul><li>Verify that a request without any JWT is allowed:</li></ul><pre>kubectl exec &quot;$(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name})&quot; -c sleep -n mtls-client - curl &quot;http://httpbin.mtls-service:8000/headers&quot; -s -o /dev/null -w &quot;%{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>200</pre><p>AuthorizationPolicy</p><ul><li>Create an AuthorizationPolicy resource for the httpbin workload in the mtls-service namespace:</li></ul><pre>kubectl apply -f - &lt;&lt;EOF apiVersion: security.istio.io/v1beta1 kind: AuthorizationPolicy metadata: name: require-jwt namespace: mtls-service spec: selector: matchLabels: app: httpbin action: ALLOW rules: - from: - source: requestPrincipals: [&quot;testing@secure.istio.io/testing@secure.istio.io&quot;] EOF</pre><ul><li>The policy requires all requests to the httpbin workload to have a valid JWT with requestPrincipal set to testing@secure.istio.io/testing@secure.istio.io. Istio constructs the requestPrincipal by combining the iss and sub of the JWT token with a / separator as shown:</li><li>Download a legitimate JWT that can be used to send accepted requests:</li></ul><pre>TOKEN=$(curl https://raw.githubusercontent.com/istio/istio/release-1.8/security/tools/jwt/samples/demo.jwt -s) &amp;&amp; echo &quot;$TOKEN&quot; | cut -d &#39;.&#39; -f2 - | base64 - decode -</pre><ul><li><strong>Output:</strong></li></ul><pre>{&quot;exp&quot;:4685989700,&quot;foo&quot;:&quot;bar&quot;,&quot;iat&quot;:1532389700,&quot;iss&quot;:&quot;testing@secure.istio.io&quot;,&quot;sub&quot;:&quot;testing@secure.istio.io&quot;}</pre><ul><li>Note that the iss and sub keys are set to testing@secure.istio.io. This causes Istio to generate the attribute requestPrincipal with the value testing@secure.istio.io/testing@secure.istio.io:</li><li>Verify that a request with a valid JWT is allowed:</li></ul><pre>kubectl exec &quot;$(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name})&quot; -c sleep -n mtls-client - curl &quot;http://httpbin.mtls-service:8000/headers&quot; -s -o /dev/null -H &quot;Authorization: Bearer $TOKEN&quot; -w &quot;%{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>200</pre><ul><li>Verify that a request without a JWT is denied:</li></ul><pre>kubectl exec &quot;$(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name})&quot; -c sleep -n mtls-client - curl &quot;http://httpbin.mtls-service:8000/headers&quot; -s -o /dev/null -w &quot;%{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>403</pre><h3>Task 5. Authorizing requests based on method and path</h3><ul><li>This task shows you how to control access to workloads by using an AuthorizationPolicy that evaluates the request type and URL.</li><li>Update the require-jwt authorization policy for the httpbin workload in the mtls-service namespace. The new policy will still have the JWT requirement that you set up in the previous task. In addition, you are going to limit the type of HTTP requests, so that clients can only perform GET requests to the /ipendpoint:</li></ul><pre>kubectl apply -f - &lt;&lt;EOF apiVersion: security.istio.io/v1beta1 kind: AuthorizationPolicy metadata: name: require-jwt namespace: mtls-service spec: selector: matchLabels: app: httpbin action: ALLOW rules: - from: - source: requestPrincipals: [&quot;testing@secure.istio.io/testing@secure.istio.io&quot;] to: - operation: methods: [&quot;GET&quot;] paths: [&quot;/ip&quot;] EOF</pre><ul><li>Verify that a request to the httpbin&#39;s /ip endpoint works:</li></ul><pre>kubectl exec &quot;$(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name})&quot; -c sleep -n mtls-client - curl &quot;http://httpbin.mtls-service:8000/ip&quot; -s -o /dev/null -H &quot;Authorization: Bearer $TOKEN&quot; -w &quot;%{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>200</pre><ul><li>Verify that a request to the httpbin&#39;s /headers endpoint is denied:</li></ul><pre>kubectl exec &quot;$(kubectl get pod -l app=sleep -n mtls-client -o jsonpath={.items..metadata.name})&quot; -c sleep -n mtls-client - curl &quot;http://httpbin.mtls-service:8000/headers&quot; -s -o /dev/null -H &quot;Authorization: Bearer $TOKEN&quot; -w &quot;%{http_code}\n&quot;</pre><ul><li><strong>Output:</strong></li></ul><pre>403</pre><ul><li>Remove the <strong>require-jwt</strong> authorization policy by running this command:</li></ul><pre>kubectl delete AuthorizationPolicy require-jwt -n mtls-service</pre><p><strong>Review</strong></p><ul><li>In this lab, you explored <strong>mutual TLS</strong> authentication in Istio. You saw how PERMISSIVE mode mTLS allows services to receive both plaintext and mTLS traffic from clients, allowing you to incrementally adopt mTLS. You also enabled STRICT mode mTLS across your service mesh effectively blocking plaintext traffic to all your Istio injected services and then you scoped STRICT mode mTLS down to a single namespace.</li><li>In addition, you explored <strong>RequestAuthentication</strong> and <strong>AuthorizationPolicy</strong> resources in Istio.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=683f02b63571" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving Merge Conflicts in Github Protected Branches]]></title>
            <link>https://medium.com/@aneeqr25/resolving-merge-conflicts-in-protected-branches-af0778ebd69d?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/af0778ebd69d</guid>
            <category><![CDATA[merge-conflicts]]></category>
            <category><![CDATA[protected-branch]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[branching-strategy]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Fri, 29 Nov 2024 16:24:57 GMT</pubDate>
            <atom:updated>2024-11-29T16:34:23.615Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>This document outlines the steps to resolve merge conflicts between the UAT and main branches in our Git repository. The main and UAT branches are protected, which means direct changes cannot be made to it. This guide will help team members effectively manage and resolve conflicts while adhering to best practices.</p><h3>Prerequisites</h3><ul><li>Ensure you have the necessary permissions to create branches and push changes to the repository.</li><li>Familiarity with Git commands and basic branching strategies.</li></ul><h3>Steps to Resolve Merge Conflicts</h3><h3>1. Identify the Conflicted Branches</h3><p>In this scenario, we are dealing with conflicts between the UAT and main branches.</p><h3>2. Create a New Branch from UAT</h3><p>To resolve the conflicts, first, create a new branch from either the UAT or main branch. For this example, we will create a branch from release_dbc_uat.</p><pre>git checkout -b resolve-conflicts-from-uat</pre><h3>3. Pull the Latest Changes</h3><p>Next, pull the latest changes from the release_dbc_uat branch:</p><pre>git pull origin release_dbc_uat</pre><h3>4. Create a New Branch from Main</h3><p>Now, create another branch from the main branch to merge changes into:</p><pre>git checkout -b resolve-conflicts-from-main</pre><h3>5. Pull the Latest Changes from Main</h3><p>Pull the latest changes from the main branch:</p><pre>git pull origin main</pre><h3>6. Merge UAT Branch into the New Main Branch</h3><p>Now, merge the changes from the resolve-conflicts-from-uat branch into the resolve-conflicts-from-main branch:</p><pre>git merge resolve-conflicts-from-uat</pre><h3>7. Resolve Conflicts</h3><p>During the merge, Git will notify you of any conflicts. Open the conflicting files in your preferred code editor.</p><ul><li>Review the changes and decide which modifications to keep.</li><li>Edit the files to resolve the conflicts, ensuring that the final version contains the desired changes.</li></ul><h3>8. Mark Conflicts as Resolved</h3><p>After resolving the conflicts, mark the files as resolved:</p><pre>git add &lt;file1&gt; &lt;file2&gt; ...  # Add all resolved files</pre><h3>9. Commit the Changes</h3><p>Once all conflicts are resolved and staged, commit the changes:</p><pre>git commit -m &quot;Resolved merge conflicts between UAT and main&quot;</pre><h3>10. Push the Changes</h3><p>Now, push your branch to the remote repository:</p><pre>git push -u origin resolve-conflicts-from-main</pre><h3>11. Create a Pull Request</h3><ol><li>Go to your Git repo.</li><li>Navigate to the resolve-conflicts-from-main branch.</li><li>Create a pull request (PR) to merge your changes into the main branch.</li><li>Request reviews from relevant team members to ensure that the changes are validated.</li></ol><h3>12. Merge the Pull Request</h3><p>Once the PR has been reviewed and approved, merge it into the main branch. After merging, raise a PR from main to UAT this time it will let you merge without any conflicts.</p><h3>Additional Notes and</h3><h3>Best Practice for Avoiding Merge Conflicts</h3><p>To minimize the likelihood of merge conflicts when working on important releases, it’s beneficial to regularly update your feature branch with changes from the release_uat branch or other higher environments. For example, if you create a feature branch from main, you can run the following commands to ensure your branch is up to date:</p><pre>git pull origin release_uat<br>git fetch<br>git rebase</pre><p>By incorporating the latest changes from release_uat into your feature branch, you can ensure that your work aligns with the current state of the codebase. This practice is especially important before merging back into main or UAT, as it helps maintain consistency between branches and reduces the chances of encountering conflicts later on. Keeping your branches synchronized with higher environments will make the final integration smoother and more efficient.</p><ul><li><strong>Branch Naming Conventions</strong>: Use descriptive branch names that indicate the purpose of the branch (e.g., resolve-conflicts-from-uat and resolve-conflicts-from-main).</li><li><strong>Communication</strong>: Communicate with your team about any significant changes made during conflict resolution to ensure everyone is aligned.</li><li><strong>Testing</strong>: After resolving conflicts and merging, conduct thorough testing to ensure that the application behaves as expected and no important code file has been removed.</li></ul><h3>Conclusion</h3><p>By following these steps, team members can effectively resolve merge conflicts in protected branches while maintaining the integrity of both the main and UAT branches.</p><h3>Note on Merge Conflicts</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*7QuRG9Zut52YzTuf" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/0*pw72qdA98OHcxZMR.png" /></figure><p>Git tracks changes based on commits, and the history of these commits can affect how merges are handled. For instance, if a feature branch was previously merged into the release_uat branch using a squash commit, the original commits from the feature branch would not exist in the history of the release_uat branch. When attempting to merge changes from the main branch to the UAT branch later, Git may perceive the absence of these original commits as a conflict, even if the changes themselves are already present in the codebase. This is because Git relies on commit history to determine whether changes are new or have already been integrated. As a result, manual review may be required to resolve these conflicts and ensure that the intended changes are correctly merged.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af0778ebd69d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Resource Dependencies with Terraform: A Comprehensive Guide]]></title>
            <link>https://medium.com/@aneeqr25/creating-resource-dependencies-with-terraform-a-comprehensive-guide-3336d00626f2?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3336d00626f2</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Mon, 28 Oct 2024 17:55:16 GMT</pubDate>
            <atom:updated>2024-10-28T17:55:16.179Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>In this lab, we will explore how to create resource dependencies using Terraform by setting up two virtual machines (VMs) in the default network. We will leverage variables to define the attributes of these VMs at runtime and utilize output values to display key resource attributes. Furthermore, we will examine how Terraform handles both implicit and explicit dependencies by assigning a static IP address to the first VM and creating a Google Cloud Storage (GCS) bucket that explicitly depends on the VM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*YfsgH0MO7Exp7ifZ.png" /></figure><h3>Objectives</h3><p>By the end of this lab, you will be able to:</p><ul><li>Use variables and output values effectively in Terraform.</li><li>Observe and understand implicit dependencies.</li><li>Create explicit resource dependencies using the depends_on attribute.</li></ul><h3>Task 1: Sign in to the Cloud Console</h3><ol><li>Open Google Console: Click on the link to open the Google Cloud Console.</li><li>Use Lab Credentials: Select “Use another account” and copy/paste the credentials provided for this lab. Using any other credentials may lead to errors or unexpected charges.</li><li>Accept Terms: Accept the terms and conditions, and skip the recovery resource page.</li><li>Important Note: Do not click “End Lab” unless you have completed your tasks or wish to restart. Ending the lab will clear your progress and remove the project.</li></ol><h3>Task 2: Initialize Terraform</h3><ol><li>Open Cloud Shell: Activate Cloud Shell.</li><li>Verify Terraform Installation: Run the following command to check if Terraform is installed:</li></ol><p>terraform -version</p><ol><li>The output should confirm the installation, similar to:</li></ol><pre>Terraform v1.5.7</pre><p>Create a Directory: Create a new directory for your Terraform configuration and navigate to it:</p><ul><li>mkdir tfinfra &amp;&amp; cd tfinfra</li></ul><p>Open Cloud Shell Editor: Click on “Open Editor” to access the Cloud Shell Editor.</p><ol><li>Create Provider File: Right-click on the tfinfra folder, select &quot;New File,&quot; and name it provider.tf. Add the following code:</li></ol><pre>provider &quot;google&quot; {<br>  project = &quot;Project ID&quot;<br>  region  = &quot;REGION&quot;<br>  zone    = &quot;ZONE&quot;<br>}</pre><ol><li>Save the File: Click on “File &gt; Save” to save provider.tf.</li><li>Initialize Terraform: Run the command:</li></ol><pre>terraform init</pre><ol><li>This command will initialize Terraform and install the necessary provider plugins.</li></ol><h3>Task 3: View Implicit Resource Dependency</h3><h3>Create a VM Instance</h3><ol><li>Create Instance File: Create a new file named instance.tf and add the following code:</li></ol><pre>resource &quot;google_compute_instance&quot; &quot;vm_instance&quot; {<br>  name         = &quot;${var.instance_name}&quot;<br>  zone         = &quot;${var.instance_zone}&quot;<br>  machine_type = &quot;${var.instance_type}&quot;<br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-11&quot;<br>    }<br>  }<br>  network_interface {<br>    network = &quot;default&quot;<br>    access_config {<br>      # Allocate a one-to-one NAT IP to the instance<br>    }<br>  }<br>}</pre><p>Save the File: Click on “File &gt; Save.”</p><h3>Create Variables</h3><ol><li>Create Variables File: Create a new file named variables.tf and add the following properties:</li></ol><pre>variable &quot;instance_name&quot; {<br>  type        = string<br>  description = &quot;Name for the Google Compute instance&quot;<br>}<br>variable &quot;instance_zone&quot; {<br>  type        = string<br>  description = &quot;Zone for the Google Compute instance&quot;<br>}<br>variable &quot;instance_type&quot; {<br>  type        = string<br>  description = &quot;Disk type of the Google Compute instance&quot;<br>  default     = &quot;e2-medium&quot;<br>}</pre><p>Save the File: Click on “File &gt; Save.”</p><h3>Create Output Values</h3><ol><li>Create Outputs File: Create a new file named outputs.tf and add the following properties:</li></ol><pre>output &quot;network_IP&quot; {<br>  value       = google_compute_instance.vm_instance.network_interface[0].network_ip<br>  description = &quot;The internal IP address of the instance&quot;<br>}<br>output &quot;instance_link&quot; {<br>  value       = google_compute_instance.vm_instance.self_link<br>  description = &quot;The URI of the created resource.&quot;<br>}</pre><ol><li>Save the File: Click on “File &gt; Save.”</li></ol><h3>Assign a Static IP</h3><ol><li>Add Static IP Configuration: In instance.tf, add the following code to allocate a static IP address:</li></ol><pre>resource &quot;google_compute_address&quot; &quot;vm_static_ip&quot; {<br>  name = &quot;terraform-static-ip&quot;<br>}</pre><p>Update Network Interface: Modify the network_interface block in instance.tfto include the static IP:</p><pre>network_interface {<br>  network = &quot;default&quot;<br>  access_config {<br>    nat_ip = google_compute_address.vm_static_ip.address<br>  }<br>}</pre><h3>Initialize and Apply Terraform</h3><ol><li>Initialize Terraform: Run:</li></ol><pre>terraform init</pre><ol><li>Preview Resources: Run:</li></ol><pre>terraform plan</pre><ol><li>If prompted, enter the required details for instance creation.</li><li>Apply Terraform: Run:</li></ol><pre>terraform apply</pre><ol><li>If prompted, enter the required details for instance creation and confirm the planned actions by typing yes.</li></ol><h3>Task 4: Create Explicit Dependency</h3><h3>Create a Cloud Storage Bucket and VM Instance</h3><ol><li>Create a New File: Create a new file named exp.tf and add the following code:</li></ol><pre># Create a new instance that uses the bucket<br>resource &quot;google_compute_instance&quot; &quot;another_instance&quot; {<br>  name         = &quot;terraform-instance-2&quot;<br>  machine_type = &quot;e2-micro&quot;<br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-11&quot;<br>    }<br>  }<br>  network_interface {<br>    network = &quot;default&quot;<br>    access_config {<br>    }<br>  }<br>  # Tells Terraform that this VM instance must be created only after the<br>  # storage bucket has been created.<br>  depends_on = [google_storage_bucket.example_bucket]<br>}<br><br># New resource for the storage bucket our application will use.<br>resource &quot;google_storage_bucket&quot; &quot;example_bucket&quot; {<br>  name     = &quot;&lt;UNIQUE-BUCKET-NAME&gt;&quot;<br>  location = &quot;US&quot;<br>  website {<br>    main_page_suffix = &quot;index.html&quot;<br>    not_found_page   = &quot;404.html&quot;<br>  }<br>}</pre><ol><li>Save the File: Click on “File &gt; Save.”</li></ol><h3>Key Concept</h3><p>Notice that the order of resource definitions in the Terraform configuration file does not affect how Terraform applies changes.</p><h3>Initialize and Apply Terraform</h3><ol><li>Preview Resources: Run:</li></ol><pre>terraform plan</pre><ol><li>If prompted, enter the required details for instance creation.</li><li>Apply Terraform: Run:</li></ol><pre>terraform apply</pre><ol><li>If prompted, enter the required details for instance creation and confirm the planned actions by typing yes.</li></ol><h3>Key Concept</h3><p>Observe that due to the explicit dependency, the compute instance is created after the creation of the Cloud Storage Bucket.</p><h3>Task 5: View Dependency Graph</h3><ol><li>Generate Dependency Graph: Run the following command to generate a dependency graph:</li></ol><pre>terraform graph | dot -Tpng &gt; graph.png</pre><p>View the Graph: Switch to the editor and click on the graph.png file to view the dependency graph.</p><p>By completing these tasks, you have successfully created resource dependencies using Terraform and explored both implicit and explicit dependencies. You have also visualized the dependency graph of your resources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3336d00626f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Web Hosting: Deploying a Website on Cloud Run]]></title>
            <link>https://medium.com/@aneeqr25/deploy-your-website-on-google-cloud-run-708d7402f5a4?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/708d7402f5a4</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[google-cloud-run]]></category>
            <category><![CDATA[gke]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[sre]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Thu, 25 Jan 2024 11:49:31 GMT</pubDate>
            <atom:updated>2024-01-25T11:53:28.020Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6LU_Wi7NRBUS_1na" /></figure><p>Running and managing websites can be a complex endeavour, often requiring significant infrastructure overhead. Creating and configuring virtual machines, Kubernetes clusters, pods, services and more is necessary for large, multi-tiered web applications, but this can be overkill for simple website hosting. If your goal is just getting a basic website deployed and accessible with minimal management, there are easier options.</p><blockquote>With Cloud Run, Google Cloud’s serverless compute platform built on Knative, you can deploy and run websites without the infrastructure burden of VMs or pure Kubernetes deployments. Cloud Run removes the need to provision infrastructure or manage servers at all. It allows “scale to zero”, meaning no compute resources are consumed when no requests are coming in. This makes it a simpler, more cost-effective approach for basic website hosting use cases.</blockquote><p>Cloud Run offers a fully managed serverless environment, but can also run on your own Google Kubernetes Engine (GKE) clusters. You get the benefits of containers and portability combined with auto-scaling serverless infrastructure. In this tutorial, we’ll use the fully managed version of Cloud Run to quickly get a website deployed.</p><p>The tutorial will cover:</p><ol><li>Containerizing the website with Docker</li><li>Deploying the container to Cloud Run</li><li>Modifying the site</li><li>Rolling out updates with zero downtime</li></ol><h3>Architecture diagram</h3><p>Below you can see the flow of the deployment and Cloud Run hosting.</p><p>Begin with a Docker image created via Cloud Build, which gets triggered from Cloud Shell, then deploy the image out to Cloud Run from a command in Cloud Shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vBr8ZReZDef9OXDq" /></figure><h4>Learning outcomes</h4><ul><li>How to build a Docker image using Cloud Build and upload it to Artifact Registry</li><li>How to deploy Docker images to Cloud Run</li><li>How to manage Cloud Run deployments</li><li>How to setup an endpoint for an application on Cloud Run</li></ul><h4>To start the Lab we need a GCP account and once we have accessed the platform we need to activate the cloudshell</h4><p>Click <strong>Activate Cloud Shell </strong>at the top of the Google Cloud console.</p><h3>Task 1. Clone the source repository</h3><p>Since we are working on an existing application we’d be cloning the repo in cloudshell Open a new Cloud Shell window and run the following commands to clone the git repository and change to the appropriate directory:</p><pre>git clone https://github.com/googlecodelabs/monolith-to-microservices.git<br>cd ~/monolith-to-microservices</pre><p>Run the following command to install the NodeJS dependencies so you can test the application before deploying:</p><pre>./setup.sh</pre><p>This will take a few minutes to run. You will see a success message when it finishes.</p><p>Test your application by running the following command to start the web server:</p><pre>cd ~/monolith-to-microservices/monolith<br>npm start</pre><p>Preview your application by clicking the web preview icon and selecting <strong>Preview on port 8080</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FCOAsegnlzTXB6qM" /></figure><p>This should open a new window where you can see your Fancy Store web page in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tm92HE7wvWK_-AE9" /></figure><p>Close this window after viewing the website, and stop the web server process by pressing <strong>CTRL+C</strong> in Cloud Shell.</p><h3>Task 2. Create a Docker container with Cloud Build</h3><p>Now that you have the source files ready to go, it is time to Dockerize your application!</p><p>Normally, containerizing a web app involves manually building a Dockerfile, constructing the image, and pushing it to a registry. Cloud Build streamlines this by handling the container build and registry push in one command.</p><p>First, a Cloud Storage bucket stores the app code. Cloud Build takes these files and uses the Dockerfile to build the container image. The image is then pushed to Artifact Registry, Google Cloud’s container registry.</p><ol><li>From the <strong>Navigation Menu</strong>, under CI/CD navigate to <strong>Artifact Registry</strong> &gt; <strong>Repositories</strong>.</li><li>Click <strong>Create Repository</strong>.</li><li>Specify monolith-demo as the repository name.</li><li>Choose <strong>Docker</strong> as the format.</li><li>Under Location Type, select Region and then choose the location Region.</li><li>Click <strong>Create</strong>.</li></ol><p>With the repository ready, Cloud Build can construct the container image and push it to the registry once configured. This automates the typical two-step process of separate image build and push.</p><h3>Configure authentication</h3><p>Before you can push or pull images, configure Docker to use the Google Cloud CLI to authenticate requests to Artifact Registry.</p><ul><li>To set up authentication to Docker repositories in the region Region, run the following command in Cloud Shell:</li></ul><pre>gcloud auth configure-docker</pre><p>The command updates your Docker configuration. You can now connect with Artifact Registry in your Google Cloud project to push and pull images.</p><h3>Deploy the image</h3><p>To deploy the image that was built earlier.</p><p>Enable the Cloud Build, Artifact Registry, and Cloud Run APIs. Run the following command to enable them:</p><pre>gcloud services enable artifactregistry.googleapis.com \<br>    cloudbuild.googleapis.com \<br>    run.googleapis.com</pre><p>After the APIs are enabled, run the following command to start the build process:</p><pre>gcloud builds submit --tag Region-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:1.0.0</pre><p><strong>Note:</strong> This process will take a few minutes.</p><p>To view your build history, or watch the process in real time, in the Console, from the <strong>Navigation menu</strong> click <strong>Cloud Build</strong> &gt; <strong>History</strong>. Here you can see a list of all your builds; there should only be 1 that you just created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0eCa369VWXrZKT5w" /></figure><ul><li>If you click on the Build ID, you can see all the details for that build including the log output.</li><li>From the Build Details page you can view the container image that was created by clicking the <strong>Execution Details</strong> tab, then clicking on on the image link.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u4U_8nGOSHqU3bby" /></figure><h3>Task 3. Deploy the container to Cloud Run</h3><p>Now that you have containerized your website and pushed the container to Artifact Registry, it is time to deploy to Cloud Run!</p><p>Run the following command to deploy the image to Cloud Run:</p><pre>gcloud run deploy monolith --image Region-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:1.0.0 --region Region</pre><p>When asked to allow unauthenticated invocations to [monolith] type <strong>Y</strong>.</p><p>Verify the deployment</p><pre>gcloud run services list</pre><p>once this is done on output if you Click on the URL provided in the list of services. You should see the same website you previewed locally in Task 1.</p><h3>Task 4. Make changes to the website to deploy v2.0</h3><p><strong>Scenario:</strong> Your marketing team has asked you to change the homepage for your site. They think it should be more informative of who your company is and what you actually sell.</p><p><strong>Task:</strong> You will add some text to the homepage to make the marketing team happy! It looks like one of our developers already created the changes with the file name index.js.new. You can just copy this file to index.js and your changes should be reflected. Follow the instructions below to make the appropriate changes.</p><p>Run the following commands to copy the updated file to the correct file name:</p><pre>cd ~/monolith-to-microservices/react-app/src/pages/Home<br>mv index.js.new index.js</pre><p>Print its contents to verify the changes:</p><pre>cat ~/monolith-to-microservices/react-app/src/pages/Home/index.js</pre><p>Run the following command to build the React app and copy it into the monolith public directory:</p><pre>cd ~/monolith-to-microservices/react-app<br>npm run build:monolith</pre><p>Now that the code is updated, rebuild the Docker container and publish it to Artifact Registry. You can use the same command as before, except this time you will update the version label.</p><p>Run the following command to trigger a new Cloud Build with an updated image version of 2.0.0:</p><pre>cd ~/monolith-to-microservices/monolith<br>gcloud builds submit --tag Region-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:2.0.0</pre><h3>Task 5. Update website with zero downtime</h3><p>Cloud Run allows zero-downtime deployments by treating each deployment as a new revision. The latest revision runs separately, then traffic is gradually shifted over.</p><p>By default, 100% of traffic goes to the latest revision. Routes can be used to split traffic between revisions.</p><p>To deploy an update:</p><ul><li>Re-deploy the service with a new image version using the same cloud run deploy command.</li><li>The new revision will come online before traffic is routed over, preventing downtime.</li><li>Users experience no interruption as the update rolls out.</li></ul><p>This demonstrates a key benefit of Cloud Run — continuous delivery of updates without impacting users. Revisions and traffic splitting allow new versions to release seamlessly.</p><p>Run the following command to re-deploy the service to update the image to a new version</p><pre>gcloud run deploy monolith --image Region-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:2.0.0 --region Region</pre><h3>Verify deployment</h3><pre>gcloud run services describe monolith --platform managed --region Region</pre><p>Run the following command to list the services and view the IP address:</p><pre>gcloud beta run services list</pre><p>Click on the URL of the service. Your web site should now be displaying the text you just added to the homepage component!</p><h3>Congratulations!</h3><p>You successfully deployed, de-scaled, re-scaled, and updated your website on Cloud Run.</p><p>In this tutorial, we saw how Cloud Run provides a simple way to deploy and run a website without complex infrastructure management. By leveraging Cloud Build to automate container creation and using Cloud Run to host the application serverless, we achieved a full workflow from source code to production deployment. Key highlights included building the container image without a standalone Docker environment, effortlessly scaling to zero to minimize costs, and releasing updates with zero downtime using Cloud Run revision tracking. This walkthrough demonstrated the power of a serverless container platform like Cloud Run for hosting web applications. With just a few commands, we can build, deploy, and update a website while avoiding the overhead of servers and clusters. For basic website hosting use cases, Cloud Run offers speed, simplicity, and seamless delivery of new features.</p><ul><li>Additional Note you can also Run the following command to update the current revision, using a concurrency value of 80 to do the testing</li></ul><pre>gcloud run deploy monolith --image Region-docker.pkg.dev/${GOOGLE_CLOUD_PROJECT}/monolith-demo/monolith:1.0.0 --region Region --concurrency 80</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=708d7402f5a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Infrastructure on Google Cloud with Terraform: Challenge Lab]]></title>
            <link>https://medium.com/@aneeqr25/automating-infrastructure-on-google-cloud-with-terraform-challenge-lab-7832a4e200d6?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/7832a4e200d6</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devops-practice]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Fri, 27 Oct 2023 14:29:10 GMT</pubDate>
            <atom:updated>2023-10-27T14:29:10.706Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*DWQTYSJyufeT3-pT" /></figure><h3>Introduction</h3><p>This hands-on lab walks through using Terraform to manage infrastructure on Google Cloud Platform. We will build out configuration files, modify resources, import existing infrastructure, and use other Terraform features for a complete experience.</p><h3>Overview</h3><ul><li><a href="https://www.courseintern.com/post/qwiklabs/challenge-labs/gsp345-automating-infrastructure-on-google-cloud-with-terraform/#setup--create-the-configuration-files">Setup : Create the configuration files</a></li><li><a href="https://www.courseintern.com/post/qwiklabs/challenge-labs/gsp345-automating-infrastructure-on-google-cloud-with-terraform/#task---1--import-infrastructure">Task — 1 : Import infrastructure</a></li><li><a href="https://www.courseintern.com/post/qwiklabs/challenge-labs/gsp345-automating-infrastructure-on-google-cloud-with-terraform/#task---2--configure-a-remote-backend">Task — 2 : Configure a remote backend</a></li><li><a href="https://www.courseintern.com/post/qwiklabs/challenge-labs/gsp345-automating-infrastructure-on-google-cloud-with-terraform/#task---3--modify-and-update-infrastructure">Task — 3 : Modify and update infrastructure</a></li><li><a href="https://www.courseintern.com/post/qwiklabs/challenge-labs/gsp345-automating-infrastructure-on-google-cloud-with-terraform/#task---4--taint-and-destroy-resources">Task — 4 : Taint and destroy resources</a></li><li><a href="https://www.courseintern.com/post/qwiklabs/challenge-labs/gsp345-automating-infrastructure-on-google-cloud-with-terraform/#task---5--use-a-module-from-the-registry">Task — 5 : Use a module from the Registry</a></li><li><a href="https://www.courseintern.com/post/qwiklabs/challenge-labs/gsp345-automating-infrastructure-on-google-cloud-with-terraform/#task---6--configure-a-firewall">Task — 6 : Configure a firewall</a></li></ul><h3>Setup : Create the configuration files</h3><p>We start by creating the main Terraform configuration files — main.tf, variables.tf, and outputs.tf. main.tf defines the Google Cloud provider and any top level resources. variables.tf declares input variables so values can be reused. outputs.tf will later define output values to expose after applying.</p><p>We also create module directories for organizing resources into logical groups — like compute instances and storage. The module files instances.tf, outputs.tf, and variables.tf scaffold out the configuration.</p><p>Make the empty files and directories in Cloud Shell or the Cloud Shell Editor.</p><pre>touch main.tf<br> touch variables.tf<br> mkdir modules<br> cd modules<br> mkdir instances<br> cd instances<br> touch instances.tf<br> touch outputs.tf<br> touch variables.tf<br>cd ..<br>mkdir storage<br>cd storage<br>touch storage.tf<br>touch outputs.tf<br>touch variables.tf<br>cd</pre><p>Add the following to the each <strong>variables.tf</strong> file, and fill in the GCP Project ID:</p><pre>variable &quot;region&quot; {<br> default = &quot;us-central1&quot;<br>}<br><br>variable &quot;zone&quot; {<br> default = &quot;us-central1-a&quot;<br>}<br><br>variable &quot;project_id&quot; {<br> default = &quot;&lt;FILL IN PROJECT ID&gt;&quot;<br>}</pre><p>Add the following to the <strong>main.tf</strong> file :</p><pre>terraform {<br>  required_providers {<br>    google = {<br>      source = &quot;hashicorp/google&quot;<br>      version = &quot;3.55.0&quot;<br>    }<br>  }<br>}<br><br>provider &quot;google&quot; {<br>  project     = var.project_id<br>  region      = var.region<br><br>  zone        = var.zone<br>}<br><br>module &quot;instances&quot; {<br><br>  source     = &quot;./modules/instances&quot;<br><br>}</pre><p>Run terraform init in Cloud Shell in the root directory to initialize terraform.</p><h3>Task — 1 : Import infrastructure</h3><p>We begin by navigating to Compute Engine in the Google Cloud Console and locating the two existing virtual machine instances named tf-instance-1 and tf-instance-2.</p><p>For each instance, we click on the instance name to view details and copy down the unique Instance ID value. This ID will be used to import each instance into Terraform.</p><p>We then open the Terraform configuration file at modules/instances/instances.tf and define google_compute_instance resources matching our existing VMs, including their names and specifications.</p><p>Defining these resources in Terraform allows us to import the instances and bring them under management by referencing the resource blocks.</p><p>By importing existing infrastructure into Terraform, we can integrate previous work and avoid restructuring our environment from scratch. The import command bridges the gap between our current state and desired state defined in code.</p><pre>resource &quot;google_compute_instance&quot; &quot;tf-instance-1&quot; {<br>  name         = &quot;tf-instance-1&quot;<br>  machine_type = &quot;n1-standard-1&quot;<br>  zone         = var.zone<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;default&quot;<br>  }<br>  metadata_startup_script = &lt;&lt;-EOT<br>    #!/bin/bash<br>  EOT<br>  <br>  allow_stopping_for_update = true<br>}<br><br>resource &quot;google_compute_instance&quot; &quot;tf-instance-2&quot; {<br>  name         = &quot;tf-instance-2&quot;<br>  machine_type = &quot;n1-standard-1&quot;<br>  zone         = var.zone<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;default&quot;<br>  }<br>metadata_startup_script = &lt;&lt;-EOT<br>    #!/bin/bash<br>  EOT<br>  <br>  allow_stopping_for_update = true<br>}</pre><p>Next, we use the terraform import command and provide the Instance ID copied earlier to import each instance into the state. Terraform takes over management of the VMs without needing to re-create them.</p><p>To import the <strong>first</strong> instance, use the following command, using the Instance ID for <strong>tf-instance-1</strong> you copied down earlier.</p><pre>terraform import module.instances.google_compute_instance.tf-instance-1 &lt;Instance ID - 1&gt;</pre><p>To import the second instance, use the following command, using the Instance ID for <strong>tf-instance-2</strong> you copied down earlier.</p><pre>terraform import module.instances.google_compute_instance.tf-instance-2 &lt;Instance ID - 2&gt;</pre><p>With the terraform import commands completed, our two compute instances are now incorporated into the Terraform state and recognized as managed resources.</p><p>At this point, we can optionally run terraform plan followed by terraform apply to sync up the infrastructure state with our configuration.</p><p>The plan command will show what changes need to happen to match our defined resources. Then apply will execute those changes and update the state.</p><p>Since no changes are actually needed in this case, running apply will simply save the existing instances into the state file.</p><p>When prompted, we type yes at the confirmation dialogue to approve saving the current infrastructure state into the Terraform state file. This persists knowledge of our instances going forward.</p><p>By importing resources and syncing the state, we inform Terraform about our existing infrastructure. Now Terraform has visibility and control over the instances, allowing us to leverage its full capabilities for management.</p><pre>terraform plan<br>terraform apply</pre><h3>Task — 2 : Configure a remote backend</h3><p>We create a Google Cloud Storage bucket to use for storing Terraform state remotely. This allows collaboration by centralizing the state. We define the GCS backend and re-initialize Terraform to migrate state storage.</p><p>Add the following code to the <strong>modules/storage/storage.tf</strong> file:</p><pre>resource &quot;google_storage_bucket&quot; &quot;storage-bucket&quot; {<br>  name          = var.project_id<br>  location      = &quot;US&quot;<br>  force_destroy = true<br>  uniform_bucket_level_access = true<br>}</pre><p>To add an output value for the google_storage_bucket resource in the outputs.tf file, you can do:</p><pre>output &quot;storage_bucket_name&quot; {<br>  value = google_storage_bucket.storage-bucket.name<br>}</pre><p>Next, add the following to the main.tf file:</p><pre>module &quot;storage&quot; {<br> source     = &quot;./storage&quot;</pre><p>Run the following commands to initialize the module and create the storage bucket resource. Type <strong>yes</strong> at the dialogue after you run the apply command to accept the state changes.</p><pre>terraform init<br>terraform apply</pre><p>Next, update the <strong>main.tf</strong> file terraform block so it will look like the following. Fill in your bucket name that we have created for the bucket argument definition.</p><pre>terraform {<br>  backend &quot;gcs&quot; {<br>    bucket  = &quot;&lt;Bucket-name&gt;&quot;<br> prefix  = &quot;terraform/state&quot;<br>  }<br>  required_providers {<br>    google = {<br>      source = &quot;hashicorp/google&quot;<br>      version = &quot;3.55.0&quot;<br>    }<br>  }<br>}</pre><p>Run the following to initialize the remote backend. Type <strong>yes</strong> at the prompt.</p><pre>terraform init</pre><h3>Task — 3 : Modify and update infrastructure</h3><p>With the backend configured, we modify the instances by increasing machine type and adding a new instance. Terraform plans to apply these changes incrementally, minimizing disruption. We initialize and apply the changes, and Terraform updates our infrastructure.</p><p>Navigate to modules/instances/instance.tf. Replace the entire contents of the file with the following:</p><pre>resource &quot;google_compute_instance&quot; &quot;tf-instance-1&quot; {<br>  name         = &quot;tf-instance-1&quot;<br>  machine_type = &quot;n1-standard-1&quot;<br>  zone         = var.zone<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;default&quot;<br>  }<br>  metadata_startup_script = &lt;&lt;-EOT<br>    #!/bin/bash<br>  EOT<br>  <br>  allow_stopping_for_update = true<br>}<br><br>resource &quot;google_compute_instance&quot; &quot;tf-instance-2&quot; {<br>  name         = &quot;tf-instance-2&quot;<br>  machine_type = &quot;n1-standard-1&quot;<br>  zone         = var.zone<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;default&quot;<br>  }<br>metadata_startup_script = &lt;&lt;-EOT<br>    #!/bin/bash<br>  EOT<br>  <br>  allow_stopping_for_update = true<br>}<br><br>resource &quot;google_compute_instance&quot; &quot;tf-instance-3&quot; {<br>  name         = &quot;tf-instance-3&quot;<br>  machine_type = &quot;n1-standard-2&quot;<br>  zone         = var.zone<br>  allow_stopping_for_update = true<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;default&quot;<br>  }<br>metadata_startup_script = &lt;&lt;-EOT<br>    #!/bin/bash<br>  EOT<br>  <br>  allow_stopping_for_update = true<br>}</pre><p>Run the following commands to initialize the module and create/update the instance resources. Type <strong>yes</strong> at the dialogue after you run the apply command to accept the state changes.</p><pre>terraform init<br>terraform apply</pre><h3>Task — 4 : Taint and destroy resources</h3><p>To demonstrate destroying resources, we taint an instance to trigger re-creation. This forces an instance to be destroyed and recreated on the next apply. We then permanently remove it from the config and apply the changes.</p><p>Taint the <strong>tf-instance-3</strong> resource by running the following command:</p><pre>terraform taint module.instances.google_compute_instance.tf-instance-3</pre><p>Run the following commands to apply the changes:</p><pre>terraform init<br>terraform apply</pre><p>Remove the <strong>tf-instance-3</strong> resource from the <strong>instances.tf</strong> file. Delete the following code chunk from the file.</p><pre>resource &quot;google_compute_instance&quot; &quot;tf-instance-3&quot; {<br>  name         = &quot;tf-instance-3&quot;<br>  machine_type = &quot;n1-standard-2&quot;<br>  zone         = var.zone<br>  allow_stopping_for_update = true<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;default&quot;<br>  }<br>}</pre><p>Run the following commands to apply the changes. Type <strong>yes</strong> at the prompt.</p><pre>terraform apply</pre><h3>Task — 5 : Use a module from the Registry</h3><p>We introduce a networking module from the public Terraform Registry to build a VPC and subnets. Modules allow reusable abstractions by encapsulating infrastructure into packages. We reference the module, initialize, and apply to build out the networking resources.</p><p>Copy and paste the following at the end of main.tf file:</p><pre>module &quot;vpc&quot; {<br>    source  = &quot;terraform-google-modules/network/google&quot;<br>    version = &quot;~&gt; 3.2.2&quot;<br><br>    project_id   = var.project_id<br>    network_name = &quot;terraform-vpc&quot;<br>    routing_mode = &quot;GLOBAL&quot;<br><br>    subnets = [<br>        {<br>            subnet_name           = &quot;subnet-01&quot;<br>            subnet_ip             = &quot;10.10.10.0/24&quot;<br>            subnet_region         = &quot;us-central1&quot;<br>        },<br>        {<br>            subnet_name           = &quot;subnet-02&quot;<br>            subnet_ip             = &quot;10.10.20.0/24&quot;<br>            subnet_region         = &quot;us-central1&quot;<br>            subnet_private_access = &quot;true&quot;<br>            subnet_flow_logs      = &quot;true&quot;<br>            description           = &quot;This subnet has a description&quot;<br>        }<br>    ]<br>}</pre><p>Run the following commands to initialize the module and create the VPC. Type <strong>yes</strong> at the prompt.</p><pre>terraform init<br>terraform apply</pre><p>Navigate to modules/instances/instances.tf. Replace the entire contents of the file with the following:</p><pre>resource &quot;google_compute_instance&quot; &quot;tf-instance-1&quot; {<br>  name         = &quot;tf-instance-1&quot;<br>  machine_type = &quot;n1-standard-2&quot;<br>  zone         = var.zone<br>  allow_stopping_for_update = true<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;terraform-vpc&quot;<br>    subnetwork = &quot;subnet-01&quot;<br>  }<br>}<br><br>resource &quot;google_compute_instance&quot; &quot;tf-instance-2&quot; {<br>  name         = &quot;tf-instance-2&quot;<br>  machine_type = &quot;n1-standard-2&quot;<br>  zone         = var.zone<br>  allow_stopping_for_update = true<br><br>  boot_disk {<br>    initialize_params {<br>      image = &quot;debian-cloud/debian-10&quot;<br>    }<br>  }<br><br>  network_interface {<br> network = &quot;terraform-vpc&quot;<br>    subnetwork = &quot;subnet-02&quot;<br>  }<br>}</pre><p>Run the following commands to initialize the module and update the instances. Type <strong>yes</strong> at the prompt.</p><pre>terraform init<br>terraform apply</pre><h3>Task — 6 : Configure a firewall</h3><p>Lastly, we configure a firewall rule on the VPC to limit traffic. We reference the VPC by name and specify allow rules. Terraform makes infrastructure changes quick and repeatable.</p><p>Add the following resource to the <strong>main.tf</strong> file and fill in the GCP Project ID:</p><pre>resource &quot;google_compute_firewall&quot; &quot;tf-firewall&quot; {<br>  name    = &quot;tf-firewall&quot;<br> network = &quot;projects/&lt;PROJECT_ID&gt;/global/networks/terraform-vpc&quot;<br><br>  allow {<br>    protocol = &quot;tcp&quot;<br>    ports    = [&quot;80&quot;]<br>  }<br><br>  source_tags = [&quot;web&quot;]<br>  source_ranges = [&quot;0.0.0.0/0&quot;]<br>}</pre><p>Run the following commands to configure the firewall. Type <strong>yes</strong> at the prompt.</p><pre>terraform init<br>terraform apply</pre><p>Congratulations, you’re all done with the lab</p><h3>Conclusion</h3><p>This lab provided hands-on Terraform experience for core features like state management, editing infrastructure, abstraction via modules, and access control. With these foundations, you can start using Terraform to automate your own infrastructure workflows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7832a4e200d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Applications on Google Cloud with Kubernetes]]></title>
            <link>https://medium.com/@aneeqr25/deploying-applications-on-google-cloud-with-kubernetes-737568d0b1a3?source=rss-aa0b967c6fd0------2</link>
            <guid isPermaLink="false">https://medium.com/p/737568d0b1a3</guid>
            <category><![CDATA[gke]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Aneeq Rana]]></dc:creator>
            <pubDate>Tue, 17 Oct 2023 22:21:42 GMT</pubDate>
            <atom:updated>2023-10-17T22:21:42.279Z</atom:updated>
            <content:encoded><![CDATA[<p>Containers and Kubernetes have revolutionized application development and deployment. This article walks through a hands-on example of containerizing an application using Docker, storing the image in Google Cloud’s Artifact Registry, and deploying the application to a Kubernetes cluster on Google Kubernetes Engine (GKE)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*zfjcfpNb3TxuLjmD.png" /></figure><h3>Introduction</h3><p>Containers and Kubernetes simplify the deployment process, making it efficient and scalable. Imagine you’ve just completed your training on these technologies, and now your supervisor at Jooli Inc. wants you to demonstrate your newfound skills by containerizing one of their applications and deploying it on a Kubernetes cluster.</p><h3>Challenge Scenario</h3><p>Here’s what you’ll be doing, you just completed training on containers and Kubernetes. Your supervisor at Jooli Inc. wants you to demonstrate these new skills by containerizing one of their applications and deploying it to a Kubernetes cluster.</p><p>Specifically, you need to:</p><ul><li>Create a Docker image and store the Dockerfile</li><li>Test the created Docker image locally</li><li>Push the image to Jooli’s Artifact Registry</li><li>Deploy the image in a Kubernetes cluster</li></ul><h3>Step 1 — Create Docker Image and Dockerfile</h3><p>The first step is to package the application into a Docker image. Start by creating a Dockerfile that defines how to build the image:</p><p>First, authenticate with gcloud:</p><pre>gcloud auth list</pre><p>Then run</p><pre>gsutil cat gs://cloud-training/gsp318/marking/setup_marking_v2.sh | bash</pre><p>Clone the application source code:</p><pre>gcloud source repos clone valkyrie-app<br></pre><p>Navigate into the app directory and create a Dockerfile</p><pre><br>cd valkyrie-app<br># Create a Dockerfile in this directory</pre><pre>FROM golang:1.10  <br>WORKDIR /app<br>COPY source .<br>RUN go install -v<br>ENTRYPOINT [&quot;app&quot;, &quot;-single=true&quot;, &quot;-port=8080&quot;]</pre><p>Build the Docker image, tagging it with a name:</p><pre>docker build -t &lt;Docker Image&gt;:&lt;Tag Name&gt; .<br></pre><p>verify</p><pre>cd ..<br>cd marking<br>./step1_v2.sh</pre><h3>Step 2 — Test Docker Image</h3><p>Run the image locally to validate it starts up properly:</p><pre>cd ..<br>cd valkyrie-app<br>docker run -p 8080:8080 &lt;Docker Image&gt;:&lt;Tag Name&gt;</pre><pre>cd ..<br>cd marking<br>./step2_v2.sh<br>bash ~/marking/step2_v2.sh</pre><p>Check localhost:8080 to ensure the app works as expected.</p><h3>Step 3 — Push to Artifact Registry</h3><p>Create a repository in Artifact Registry to store the image:</p><pre>gcloud artifacts repositories create repo-name \<br>  --repository-format=docker \<br>  --location=us-central1 \<br>  --description=&quot;App image&quot;</pre><p>Authenticate Docker with gcloud and push the image to the repo:</p><pre>gcloud auth configure-docker<br>docker push us-central1-docker.pkg.dev/project-id/repo-name/&lt;IMAGE-NAME&gt;:&lt;VERSION&gt;</pre><pre>docker images</pre><p>tag the image</p><pre>docker tag IMAGE_ID us-central1-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$Docker_Image:Tag_Name</pre><p>push the image to the repo</p><pre>docker push us-central1-docker.pkg.dev/$PROJECT_ID/$REPOSITORY/$Docker_Image_and_Tag_Name</pre><h3>Step 4 — Deploy to Kubernetes</h3><ul><li>Now, we’ll deploy the application to the Kubernetes cluster.</li></ul><p>Get Kubernetes Cluster credentials</p><pre>gcloud container clusters get-credentials valkyrie-dev --zone us-east1-d</pre><p>Update the Kubernetes deployment.yaml with the actual image location:</p><pre>sed -i s#IMAGE_HERE#us-central1-docker.pkg.dev/project-id/repo-name/my-app:v1#g k8s/deployment.yaml</pre><p>Deploy the Kubernetes manifests:</p><pre>kubectl create -f k8s/deployment.yaml<br>kubectl create -f k8s/service.yaml</pre><pre>kubectl get services</pre><p>And voila! Your app is now running on Kubernetes.</p><h3>Conclusion</h3><p>Congratulations! You’ve successfully containerized and deployed an application using Docker and Kubernetes on Google Cloud. This process streamlines deployment and ensures scalability. Remember, practice makes perfect, so keep experimenting and exploring the world of containers and Kubernetes. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=737568d0b1a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>