<?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 Jheel Patel on Medium]]></title>
        <description><![CDATA[Stories by Jheel Patel on Medium]]></description>
        <link>https://medium.com/@pateljheel?source=rss-c98777c9e049------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*R8P4aYj3icJYCiNR</url>
            <title>Stories by Jheel Patel on Medium</title>
            <link>https://medium.com/@pateljheel?source=rss-c98777c9e049------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:00:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pateljheel/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[Important Ideas Behind Machine Learning And Deep Learning]]></title>
            <link>https://medium.com/@pateljheel/important-ideas-behind-machine-learning-and-deep-learning-6864d1444428?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/6864d1444428</guid>
            <category><![CDATA[statistical-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Sun, 29 Jun 2025 16:33:58 GMT</pubDate>
            <atom:updated>2025-06-29T16:33:58.771Z</atom:updated>
            <content:encoded><![CDATA[<p>Machine Learning (ML) and Deep Learning (DL) are subfields of Artificial Intelligence (AI) focused on enabling machines to learn patterns from data. Once these patterns are learned, they can be applied to new data for making predictions or understanding underlying structures. The core concepts of ML and DL rely on fundamental mathematical disciplines such as Statistics, Probability, Linear Algebra, and Calculus. This post aims to provide a foundational understanding of ML and DL, their principles, challenges, and how DL extends ML.</p><h3>Data: The Fuel That Powers AI</h3><p>Data is the foundation of any ML or DL model. In ML, data is often referred to as a dataset, which is a collection of examples that share a common structure. Each example consists of one or more attributes that describe real-world entities.</p><p>For instance, a dataset might contain tuples of temperature differences and corresponding heat transfer measurements. Another example could be a set of images paired with labels identifying the objects within them. The structure and type of data determine how ML models learn and make predictions.</p><h3>Learning Comes Into Play</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOnx3Y3qv5jhngJScNsvLg.png" /><figcaption>Figure 1. High-level ML process</figcaption></figure><p>At a high level, a machine learning problem consists of four key components:</p><ol><li><strong>Dataset</strong>: A collection of data points used for training and testing.</li><li><strong>Model Class</strong>: A set of potential models that can represent patterns in the data.</li><li><strong>Learning Algorithm</strong>: A procedure that selects the best model from the model class using the dataset.</li><li><strong>Output Model</strong>: The trained model that can make predictions on new data.</li></ol><p>A model is a simplified mathematical representation of real-world relationships. The learning algorithm searches for an optimal model that best captures the distribution of the dataset. This process is known as model training or optimization.</p><h3>The Usual Suspects: Common ML Problems</h3><p>As mentioned above, the overall ML process and the model class depend on the problem we are trying to solve. However, many ML and DL problems can be categorized into:</p><ul><li><strong>Supervised Learning</strong>: Involves training a model using labeled data, where each input has a corresponding output. The model learns to map inputs to outputs, enabling it to make predictions on unseen data.</li><li><strong>Unsupervised Learning</strong>: Works with unlabeled data, where the model tries to identify patterns, groupings, or structures in the dataset without explicit guidance.</li><li><strong>Reinforcement Learning</strong>: A different paradigm where an agent learns by interacting with an environment and receiving rewards or penalties based on its actions.</li></ul><p>The distinction is not strict, and some problems may belong to multiple categories. While this post does not cover reinforcement learning in detail, similar principles apply.</p><h3>ML’s Best Friends: Probability and Statistics</h3><p>From probability and statistics, a dataset can be thought of as a collection of examples generated by some data-generating distribution over the random variables corresponding to the attributes of an example.</p><p>In supervised learning, these random variables consist of distinct sets of input (attribute) variables and output variables. The goal is to model the conditional probability distribution of the output variables given the input variables. In unsupervised learning, we aim to model the joint probability distribution of all random variables.</p><p>A supervised learning model typically learns the conditional probability distribution, which can then be used to predict the distribution over the output variables for unseen examples. To make predictions deterministic, we can consider statistical measures like the mean (e.g., linear regression as Maximum Likelihood Estimation).</p><h3>No Free Lunch: Why One Model Won’t Rule Them All</h3><p>The “No Free Lunch” theorem (Wolpert, 1996) states that, averaged over all possible data-generating distributions, every classification algorithm has the same error rate when classifying previously unobserved points. While this was initially stated for classification problems in supervised learning, it applies to unsupervised learning as well.</p><p>The key takeaway from this theorem is that there is no universally superior ML strategy. Instead, one must choose a model and learning algorithm suited to the specific problem and dataset.</p><h3>Finding the Sweet Spot: Generalization vs. Overfitting</h3><p>The effectiveness of an ML model depends not only on how well it fits the training data but also on how well it generalizes to new data sampled from the same distribution. A model that performs well on training data but poorly on unseen data is said to overfit.</p><p>If the model is too simple, it may <strong>underfit</strong> and fail to capture important patterns. Conversely, if the model is too complex, it may <strong>overfit</strong>, capturing noise instead of meaningful patterns. A well-generalized model balances these extremes.</p><h4>Example:</h4><p>Consider a dataset of (x, y) tuples where the underlying distribution suggests that the expected value of y given x follows a quadratic function. If we select a model class that assumes a linear relationship, it will <strong>underfit</strong>, leading to poor performance on both training and new data. If we choose an overly complex model, such as an eighth-degree polynomial, it may <strong>overfit</strong>, capturing noise rather than meaningful patterns. The ideal choice in this case is a quadratic polynomial, which aligns with the true relationship while avoiding underfitting and overfitting.</p><h3>Regularization: The Art of Keeping It Simple</h3><p>Regularization techniques prevent overfitting by discouraging complex models. This is done by introducing a penalty function that assigns higher penalties to models that are too complex. By doing so, the learning algorithm favors simpler models that generalize better.</p><h3>Why Deep Learning? Because Regular ML Wasn’t Enough!</h3><p>Deep Learning is a subset of ML designed to handle high-dimensional datasets, where complex nonlinear relationships exist among attributes. High-dimensional data introduces the following challenges:</p><ul><li><strong>Curse of Dimensionality</strong>: As the number of attributes grows, the number of possible data configurations increases exponentially, making it difficult to learn meaningful relationships without a vast amount of training data.</li><li><strong>Local Constancy Assumption</strong>: Traditional ML models assume that small changes in input lead to small changes in output. However, in high-dimensional spaces, data points are sparsely distributed, making this assumption less valid.</li></ul><h3>Deep Learning: Shrinking the Problem Space</h3><p>Observations from high-dimensional datasets suggest that data points of interest often lie on a lower-dimensional manifold within the high-dimensional space. This means we can transform the data into a lower-dimensional <strong>feature space</strong> where learning becomes more feasible.</p><p>Deep Learning leverages this concept by automatically learning hierarchical representations that extract relevant features, enabling models to capture complex patterns in data.</p><h3>Levels of Learning: From Rigid Rules to Brainy Machines</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tNYRuRtSvi7H_tRP3r8AVA.png" /><figcaption>Figure 2. Levels of learning</figcaption></figure><p>ML and DL differ in how they process data:</p><ul><li><strong>Deep Learning</strong>: Learns both feature extraction and model structure, allowing it to work effectively on raw data.</li><li><strong>Rule-Based Systems</strong>: Require explicitly defined rules for decision-making.</li><li><strong>Machine Learning</strong>: Relies on manually selected features and model training.</li></ul><h3>Wrapping It Up</h3><p>Machine Learning and Deep Learning have revolutionized AI by enabling computers to learn from data instead of being explicitly programmed. While ML is effective for many tasks, DL is particularly suited for high-dimensional data and complex pattern recognition. As technology advances, ML and DL continue to push the boundaries of what machines can learn and accomplish.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6864d1444428" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Self-Healing ETL Pipelines with LLM-Driven Transformation Repair]]></title>
            <link>https://medium.com/@pateljheel/self-healing-etl-pipelines-with-llm-driven-transformation-repair-f02ee089b89c?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/f02ee089b89c</guid>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 02:26:45 GMT</pubDate>
            <atom:updated>2025-06-25T18:47:41.105Z</atom:updated>
            <content:encoded><![CDATA[<h3>Background: The Need for Evolving Data Pipelines</h3><p>In one of my previous projects, I built a Cloud Wellness Automation tool that scanned Google Cloud projects, transformed the data, and loaded it into BigQuery tables for dashboarding and insights.<br> The heart of this project was the data transformation pipeline, which I designed and implemented in Python to be cloud-native and scalable.</p><p>However, cloud platforms evolve rapidly. New services, new fields, and schema changes (schema drifts) were frequentcausing transformation failures that relied on static assumptions about schemas.</p><p>Traditional solutions like:</p><ul><li>Exception handling</li><li>Schema-on-read patterns (not ideal for downstream analytics)</li><li>Conditional transformations</li><li>Config-driven transformations (externalized in YAML/JSON)</li></ul><p>all help, but still assume some prior knowledge of future schema changes, which is rarely realistic.</p><h3>The Idea: Agentic AI for Data Transformation Repair</h3><p>The fast progress in Agentic AI (e.g., LLM-driven agents) inspired me: Why not leverage AI agents to fix transformation failures automatically?</p><p>Initially, I thought of using the agent only during exceptions, i.e., if transformation fails on a message, delegate that one message to the agent for repair.</p><p>However:</p><ul><li>This is not scalable.</li><li>It is expensive to make a separate call to the agent for each failed message.</li><li>It doesn’t provide a long-term fix for the root cause.</li></ul><p>So I thought: Instead of fixing data, fix the transformation code itself, and deploy the fix automatically.</p><p>But with caution:</p><ul><li>Fix only the transformation module (not the entire system) to avoid ripple effects.</li></ul><p>This led me to the idea of agentic bug-fixing in ETL pipelines, one realization of which is illustrated in the following diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KdD3U4JUASxzx0NWXOEA8g.png" /><figcaption>Fig. 1. ETL and bug-fixing process</figcaption></figure><h3>Architecture and Implementation</h3><h3><strong>1. How It Works</strong></h3><p><strong>ETL Pipeline</strong>:</p><ul><li>Deployed on a GKE (Google Kubernetes Engine) cluster.</li><li>Subscribed to a Pub/Sub topic.</li><li>Loads a transformation function from a ConfigMap mounted as a volume at startup.</li></ul><p><strong>Agent Process</strong>:</p><ul><li>Also deployed on the same GKE cluster.</li><li>Listens for agent hook invocations.</li><li>It uses the following MCP-based tools:<br>1. get_transformation_function– Fetches the current transformation function from the ConfigMap.<br>2. test_transformation_function– Tests the updated transformation function on a sample message to validate correctness.<br>3. deploy_change– Updates the ConfigMap with the new transformation function and triggers a rolling restart of the ETL deployment to apply the changes.</li></ul><h3>2. Workflow</h3><ol><li>ETL receives a message → attempts transformation.</li><li>If transformation throws an exception agent hook is called with the message on which it failed, the exception traceback and the exception message</li><li>Agent fetches the transformation function from the ConfigMap.</li><li>Agent updates the function using LLM.</li><li>Agent tests the updated function on the message.</li><li>Agent updates the ConfigMap and triggers a rolling restart of ETL pods.</li></ol><p>This way, new pods load the updated transformation function.</p><p><strong>Demo video:</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F85mZxwbuAWk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D85mZxwbuAWk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F85mZxwbuAWk%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba75ff4872dd8635401eaef2c5ad6a5e/href">https://medium.com/media/ba75ff4872dd8635401eaef2c5ad6a5e/href</a></iframe><h3>Critical Challenges and Design Considerations</h3><ol><li>Prevent Agent Overload (Singleton Pattern): If multiple pods fail at once, multiple agent invocations can overwhelm the system, causing redundant ConfigMap updates and repeated rolling restarts. Implement a locking mechanism to allow only one active bug-fix operation at a time.</li><li>Post-Exception Behavior: After an exception is raised, the ETL system must decide how to proceed. Either sleep indefinitely and wait for the rolling restart, or push the failed message back into the queue and move on to the next message.</li><li>Prompt Engineering for Backward Compatibility: The LLM must fix the transformation logic while preserving support for older schemas to avoid breaking downstream systems. Careful and precise prompt design is essential.</li><li>Security Risks and Attack Surface Expansion: Allowing agents to autonomously update code increases vulnerability to prompt injection attacks and unauthorized modifications. Mitigate by applying Human-in-the-Loop validation and enforcing the Principle of Least Privileges for agent permissions and for the ETL job permissions.</li><li>Scope of Agentic Fixes: Broad agentic interventions across large system areas can cause ripple effects and destabilize the system. Scope agents to operate only on small, modular components, especially parts that fail frequently and have simple fixes.</li><li>Version Control Changes: It’s a good practice to add an additional step in the agentic bug-fixing process to commit code changes to a version control system, ensuring a complete history of all modifications.</li></ol><p><strong>Best Practices for Agentic Bug-Fixing</strong></p><ol><li>Start small: Use agents on narrow, isolated modules (like transformation logic) first.</li><li>Follow SOLID principles in software design: Modular design allows safer, more manageable agentic interventions.</li><li>Set clear operational boundaries: Prevent ripple effects across the system.</li></ol><h3>Future directions</h3><ol><li>Extending to Apache Airflow: Can we use a similar agentic bug-fixing approach for Apache Airflow DAGs?</li><li>What if Kubernetes itself became more intelligent? A cluster-wide agent monitors logs, events, and application behaviors. When it detects errors in hosted apps (e.g., ETL, microservices), it triggers automated fixes.</li></ol><p>The complete code, including the Terraform scripts for setting up the GKE cluster and configuring IAM permissions, is available <a href="https://github.com/scienceto/mcp-etl">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f02ee089b89c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Root Cause Analysis with LLMs and MCP: From Golden Signals to Intelligent Response]]></title>
            <link>https://medium.com/@pateljheel/automating-root-cause-analysis-with-llms-and-mcp-from-golden-signals-to-intelligent-response-b921e4d46829?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/b921e4d46829</guid>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 01:45:05 GMT</pubDate>
            <atom:updated>2025-06-25T18:57:10.415Z</atom:updated>
            <content:encoded><![CDATA[<p>Automation and Observability are the cornerstones of Site Reliability Engineering (SRE). SRE focuses on enabling engineers to concentrate more on development by leveraging automation and observability to reduce toil and enhance the reliability of applications and infrastructure.</p><p>SRE recommends monitoring four key metrics, latency, traffic, errors, and saturation, known as the Four Golden Signals, for user-facing applications. These signals provide direct insight into the health of your system, enabling you to focus on service quality monitoring rather than getting lost in indirect resource metrics.</p><p>When your Golden Signals indicate an anomaly, it’s a cue to drill down into detailed monitoring and logging to uncover the root cause. Although root cause analysis (RCA) has traditionally been a manual effort, the rise of automation and AI-driven observability tools is paving the way for more automated insights and faster RCA.</p><h3>Why Automating RCA Feels Like Herding Cats</h3><p>There are several challenges to automating root cause analysis (RCA). First, applications are becoming increasingly distributed, making it expensive to analyze logging and monitoring data in real time. In most cases, such real-time analysis isn’t necessary when the system is operating normally, unless this monitoring is being done for security purposes.</p><p>Secondly, because both applications and infrastructure are distributed, the associated monitoring and logging data is also dispersed. This requires either custom integrations or centralized storage for data aggregation, both of which introduce significant complexity and operational challenges [<a href="https://www.causely.ai/blog/fools-gold-or-future-fixer-can-ai-powered-causality-crack-the-rca-code-for-cloud-native-applications">1</a>, <a href="https://drdroid.io/engineering-tools/applying-automated-root-cause-analysis-with-ai-and-machine-learning">2</a>, <a href="https://betterstack.com/community/guides/logging/log-aggregation/">4</a>].</p><p>As of today, numerous solutions offer AI-driven intelligent analysis of logs and monitoring data. However, most of these require robust integrations and rely on predefined data aggregation flows, rather than dynamically adapting based on the specifics of each incident.</p><h3>How to Start Herding Those Cats</h3><p>I was reading about the Model Context Protocol (MCP), which was recently open-sourced by Anthropic. I like to think of it as giving hands and eyes to large language models (LLMs). One of our greatest abilities as humans is working efficiently with unstructured data and navigating complex interfaces. MCP enables LLMs to do something similar — providing them with the context and tools to interact more effectively with their environment, making AI agents more capable than ever.</p><p>So, I was thinking, why not combine this with proactive monitoring of the Golden Signals? The idea is to set up alerts based solely on the Four Golden Signals and configure a webhook to receive those alerts. Once an alert or incident is triggered, an LLM agent can process the alert payload and, using the appropriate MCP-based tools from a predefined list, fetch the necessary monitoring and logging data from various sources. Based on this data, the agent can then evaluate the root cause and even provide suggestions to resolve the issue.</p><p>Before proceeding, I recommend reviewing the MCP Quickstart documentation [<a href="https://modelcontextprotocol.io/introduction">3</a>].</p><h3>Benefits of Using LLMs with MCP for Automated RCA</h3><ul><li>No need for complex data parsers, unlike traditional rule-based systems, LLMs can work directly with unstructured data from various sources.</li><li>Better handling of edge cases, both in interpreting input, invoking tools and processing results.</li><li>Efficient use of monitoring and logging data — only the necessary data is retrieved, and only when it’s needed.</li><li>Eliminates the need for manual interaction with complex interfaces.</li><li>Easily incorporates business logic and operational practices using customizable prompt templates.</li><li>Shifts RCA automation from an imperative approach (step-by-step logic) to a more declarative one, focused on outcomes, not instructions.</li><li>Allows dynamic execution of data aggregators or collectors based on the specifics of an incident, rather than relying on prebuilt, static logic.</li></ul><h3>A Simple Example</h3><p>To test my idea, I created a very simple web application hosted on Google Cloud. It consists of a Regional External HTTP/S Load Balancer, a VM instance hosting a simple REST API in an Unmanaged Instance Group, and a Cloud SQL MySQL database. The API is straightforward: it accepts a file, uploads it to a GCS bucket, and performs a dummy operation on the Cloud SQL instance. By default, the VM’s stderr and stdout streams are sent to Cloud Logging.</p><p>To monitor application health, I selected two Golden Signals on the external Load Balancer (LB) for demonstration purposes: total latency and 5XX errors. I created two alert policies that trigger when either high latency is detected or the rate of 5XX errors exceeds a defined threshold. When an alert is triggered, the payload is sent to a webhook that invokes my MCP Client, powered by Claude LLM, which has access to my MCP server.</p><p>I implemented one MCP server with two tools:</p><ol><li><strong>Prometheus Query Tool</strong>: This tool accepts a list of PromQL queries along with their intended purposes. It retrieves the required monitoring data from Google Cloud Monitoring.</li><li><strong>Logging Query Tool</strong>: This tool accepts a Cloud Logging query to retrieve relevant error logs from Google Cloud Logging.</li></ol><p>The LLM prompt was carefully crafted to guide the agent to use these tools judiciously, only when necessary, to optimize token usage and minimize API calls to Google Cloud services. Once it has enough data the LLM agent generates the analysis, possible root cause and suggestions to resolve it.</p><p>Overall, the setup looks like this in the following diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ML7wWSXAho0DsZewRMqEAw.png" /><figcaption>Fig. 1. Application and Automated RCA System</figcaption></figure><p>This is a very simple example that might not necessarily require an automated RCA system, but that’s not the point of this demonstration.</p><p>Here’s a video demonstrating the PoC.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F--7Hjx-kas0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D--7Hjx-kas0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F--7Hjx-kas0%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d89c91f9884b638e53db2fa1afc52b5/href">https://medium.com/media/4d89c91f9884b638e53db2fa1afc52b5/href</a></iframe><h3>Key Considerations When Implementing Your Own MCP Tools</h3><ul><li><strong>Implement Robust Exception Handling: </strong>Include clear and descriptive error messages in your tools. This allows the MCP Client to retry intelligently by modifying its arguments based on the specific errors encountered.</li><li><strong>Balance Prompt vs. Tool Complexity: </strong>There’s a tradeoff between the complexity of your prompt and that of your tools. A more expressive prompt can allow for simpler tool implementations, but it may significantly increase LLM usage and associated costs.</li><li><strong>Filter Data Before Sending to the LLM: </strong>Apply filtering or pre-processing to the data collected by MCP tools. Reducing the volume of unnecessary or irrelevant data can help lower LLM token usage and improve performance.</li><li><strong>Use Expressive Docstrings for Tools: </strong>Provide clear, detailed, and purpose-driven docstrings for each tool. This improves the LLM agent’s understanding of how to use them effectively, reducing errors and unnecessary retries.</li></ul><h3>How Can We Extend It?</h3><p>Some interesting ways to extend this solution are:</p><ol><li>Develop tools to remediate the root cause of issues that can be resolved automatically without further risk. Automating well-understood fixes reduces downtime and increases efficiency.</li><li>Build tools to integrate with your ITSM (IT Service Management) platform to manage incidents. This improves service management by enabling automatic incident creation, updates, and resolution tracking.</li><li>Experiment with different prompt templates. Changing the structure or wording of prompts can improve the accuracy, clarity, and effectiveness of the solution and the tool use.</li></ol><p>The complete code is hosted <a href="https://github.com/scienceto/mcp-rca">here</a>. Thanks for taking the time to read my blog.</p><h3>References</h3><ol><li><a href="https://www.causely.ai/blog/fools-gold-or-future-fixer-can-ai-powered-causality-crack-the-rca-code-for-cloud-native-applications">https://www.causely.ai/blog/fools-gold-or-future-fixer-can-ai-powered-causality-crack-the-rca-code-for-cloud-native-applications</a></li><li><a href="https://drdroid.io/engineering-tools/applying-automated-root-cause-analysis-with-ai-and-machine-learning">https://drdroid.io/engineering-tools/applying-automated-root-cause-analysis-with-ai-and-machine-learning</a></li><li><a href="https://modelcontextprotocol.io/introduction">https://modelcontextprotocol.io/introduction</a></li><li><a href="https://betterstack.com/community/guides/logging/log-aggregation/">https://betterstack.com/community/guides/logging/log-aggregation/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b921e4d46829" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part III/IV]]></title>
            <link>https://blog.searce.com/setting-up-landing-zone-project-on-google-cloud-using-pfsense-firewall-part-iii-iv-79e58a5ade42?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/79e58a5ade42</guid>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Mon, 12 Jun 2023 11:23:41 GMT</pubDate>
            <atom:updated>2025-02-16T21:38:01.135Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part III</h3><h3>Introduction</h3><p>In the previous part of this tutorial we had configured OpenVPN access server along with external TCP LB on Google cloud. In this blog (Part III) we’ll be configuring a sample Nginx server behind the pfSense firewall in a spoke network (jp-service-01-vpc) peered to one of the hub networks (jp-lz-int-01-vpc) created in part I of the tutorial. The internet traffic will reach the application via a global HTTP/S LB in front of the PFW instances.</p><p>In order to achieve our requirement we’ll be going through the following steps:</p><ol><li><strong>Configure VPC Peering &amp; Routes</strong></li><li><strong>Configure OPT1 Interface in PFW &amp; Configure the Spoke Network Connectivity</strong></li><li><strong>Launch Test Server &amp; Configure Nginx</strong></li><li><strong>Configure Internal HTTP/S LB for Test Server</strong></li><li><strong>Configure PFW Port Forwarding for Test Server</strong></li><li><strong>Configure Global External HTTP/S LB</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YrLpiYDTU2P9a8lzkYxUhQ.png" /><figcaption>Network diagram</figcaption></figure><p>As shown the network diagram;</p><ol><li>The test server is deployed behind the PFW in jp-service-01 project.</li><li>jp-service-01-vpc is the spoke network peered with the jp-lz-int-01-vpc hub network.</li><li>The traffic meant for the test server will be received on the Global External HTTP/S LB. Which will send the request to the WAN interface of PFW.</li><li>Based on PFW rules and policies it will forward the traffic to the test server deployed in the service project.</li></ol><h3><strong>1. Configure VPC Peering &amp; Routes</strong></h3><p>In part I of the tutorial we had already configured all the VPC networks including a spoke network (jp-service-01-vpc). Now we need to peer the spoke network with the respective hub network (jp-lz-int-01-vpc) so that the PFW can reach to the spoke network. We can configure a peering between jp-service-01-vpc and jp-lz-int-01-vpc as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atEMxHC6HgONZdNsppqNyg.png" /><figcaption>VPC network peering between hub and spoke network</figcaption></figure><p><strong>Please keep in mind to enable </strong><strong>Import &amp; Export custom routes in the peering so that the service network (</strong><strong>jp-service-01-vpc) can import the route to the PFW.</strong></p><p>Next we’ll need to configure a route in the hub network jp-lz-int-01-vpc to route all the traffic to 0.0.0.0/0 to the PFW instance. This route must have a priority higher (lower number) than the default internet gateway route. Alternatively you can delete the default internet route. We need this route because we want all the traffic, including outbound internet traffic, from our workloads in the private network to be routed through the PFW instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PMw55QZJeclwDbgpv6OZVA.png" /><figcaption>VPC route to PFW instance in the hub network</figcaption></figure><p>As you can see below, the route have been imported to the spoke network as Import &amp; Export custom routes is enabled on the peering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qeV3awqzIS9P9BKseKs1xA.png" /><figcaption>Same VPC route imported in the spoke network</figcaption></figure><h3><strong>2. Configure OPT1 Interface in PFW &amp; Configure the Spoke Network Connectivity</strong></h3><p>In the first part of the tutorial, we had added all 4 interfaces in the 4 VPC networks from the serial console. And if you check in PFW web console, by default the WAN and LAN interfaces are enabled. The other 2 interfaces (NIC) are labeled as OPT1 &amp; OPT2 and are disabled by default.</p><p>We need to enable the OPT1 NIC which is in the jp-lz-int-01-vpc (which is peered to our spoke network). OPT2 is kept as future NIC and no need to enable now (the process to enable it will be the same). Go to Interface Assignments and select OPT1 from the assignments list as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P3VzXOEFGM6PVlRbFoMinQ.png" /><figcaption>Interface assignments in PFW console</figcaption></figure><p>Once inside OPT1 configuration, enable the interface by selecting Enable interface checkbox. For IPv4 Configuration Type select Static IPv4. And for MTU you can keep it empty or set it 1460 which must be equal to the jp-lz-int-01-vpc MTU.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2G6e2BFx1AJSaxmFnMCTew.png" /><figcaption>OPT1 interface configuration</figcaption></figure><p>For IPv4 Address use the OPT1 interface IP (10.2.0.2 in my case). And set prefix of the network of the interface (jp-lz-int-01-vpc). Once done click on save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MM1xfNAGk7EDq0BehTFUVw.png" /><figcaption>OPT1 interface IP configuration</figcaption></figure><p>Once our interface is configured, we need to create a gateway for routing spoke network traffic to the right interface instead of the default gateway. Go to the Routing section on the PFW console and create a gateway (OPTGW1) for the OPT1 interface as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XyzglD6o6YVfjtX2PPYlJQ.png" /><figcaption>OPT1 interface gateway configuration</figcaption></figure><p>For Gateway IP put the IP of the NIC subnet gateway IP (i.e. 10.2.0.1).</p><p>Now, before we configure the Static Routes for the spoke network ranges, we need to create Virtual IPs for it. While enabling the OPT1 interface we had configured the IP range of the jp-lz-int-01-vpc only and the interface doesn’t know anything of the spoke network (jp-service-01-vpc) ranges (10.4.0.0/16). In order to assign the spoke network ranges to the OPT1 interface we need to create Virtual IPs belonging to the OPT1 interface. To do so, go to the Virtual IPs section in Firewall dropdown in PFW console. And create a Virtual IP range of the type IP Alias as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1VuQtatz-0ocU0Ggli_bvA.png" /><figcaption>Virtual IP range of the spoke network</figcaption></figure><p>Now we can configure a static route for the spoke network range (10.4.0.0/16).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hk_9hMz_ekmGFYPoVEODUg.png" /><figcaption>Static route for the spoke network</figcaption></figure><p>By default pfSense firewall settings won’t allow any traffic on the OPT1 interface. We need to open traffic for atleast our OpenVPN assigned internal IP and the internal IP of the server we want to access. In my case to make it less confusing, I’ve allowed all the ranges which we have chosen for our internal networks, i.e. 10.0.0.0/8. As you can see in below screenshot I’ve allowed all IPv4 protocols (including UDP).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gRhF5-h0ohdR0tv7TZmamg.png" /><figcaption>Firewall rule on OPT1 interface</figcaption></figure><p>Now before we move ahead and create a test server in the spoke network, make sure the following things are in place.</p><p>For outbound NAT settings make sure it is either set to Automatic outbound NAT or Hybrid Outbound NAT. This will allow workloads deployed on the internal/private VPC networks to access the internet using the WAN interface of the PFW instance (as you can see the created Automatic Rules). Actually it is not recommended to use Automatic outbound NAT or Hybrid Outbound NAT, instead configure manual outbound NAT rules for better security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CugkPOLvQLHUxkbrl3X56Q.png" /><figcaption>Outbound NAT configuration</figcaption></figure><h3><strong>3. Launch Test Server &amp; Configure Nginx</strong></h3><p>Now we can launch a test server in the spoke network (jp-service-01-vpc) in the service project (to which the host network is sharing the spoke network subnet). I’ve launched an e2-micro instance in the spoke network as shown below. Note, I’ve not given public IP to the instance as we don’t want to give direct internet access to the instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iDNsm4CZIpVV1n1fS8g48Q.png" /><figcaption>Test Nginx server instance</figcaption></figure><p>Now we can do SSH to the instance on its internal IP through OpenVPN which we had setup in the previous part of the tutorial. Connect to the OpenVPN access server using the OpenVPN client and use the following gcloud command to SSH into the test server (your command might change according to the instance name, zone, project, etc.).</p><pre>gcloud compute ssh --zone &quot;us-central1-c&quot; &quot;jp-nginx-server&quot; --internal-ip --project &quot;jp-service-01&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avaBxGLwh8JgRFy2iPbwvw.png" /><figcaption>SSH to the test server</figcaption></figure><p>Now we can go ahead and install Nginx on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mVVXfLElwch8HfUk05b0Rg.png" /><figcaption>Installing Nginx on the test server</figcaption></figure><p>We were able to install Nginx which tests that the instance can access the internet. We can further test internet performance using speedtest-cli tool. Install speedtest-cli on the instance using the following command. And then run the speedtest command.</p><pre>apt install speedtest-cli</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gx0bQ-5F5Kyqi2x-9q28qg.png" /><figcaption>Internet speed test on the test server</figcaption></figure><p>From the performance result we can observe that the throughput performance is similar to what you get when the instance have direct internet access. Also you can see that the NAT IP used for internet access is same as the public IP of the WAN interface of the PFW instance.</p><h3>4. Configure Internal HTTP/S LB for Test Server</h3><p>Now, we’ll configure an internal HTTP/S LB in the service project for our test Nginx server. Actually you can even access the test server IP directly and no need to configure the LB but for completeness I’ve configured an internal LB which could later be used for scalability, multiple applications and host and path based routing. I’ve also configured SSL on the internal LB so the traffic is encrypted even after the PFW till the internal LB. Please note that before configuring the LB I have configured an instance group containing the test server just like we did in the previous part of the tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMjeOHIT2ExrrAe7hXNl_A.png" /><figcaption>Test server internal HTTP/S LB configuration</figcaption></figure><p>Don’t forget to allow Google health check IP ranges in the spoke network VPC (jp-service-01-vpc) firewall (GCP firewall).</p><p>Now you can access the test server Nginx page over the internal IP of the server and the internal LB also through the VPN as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8I_nbIA9-8B-9oMkg0UcVw.png" /><figcaption>Accessing Nginx page directly on the instance IP through VPN</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chy5TZ0jpfzQcL5ANHMzkg.png" /><figcaption>Accessing Nginx page on internal LB IP through VPN</figcaption></figure><h3><strong>5. Configure PFW Port Forwarding for Test Server</strong></h3><p>Now, we’ll configure port forwarding on PFW to forward traffic, meant for our test server, from the external HTTP/S LB (to be configured next) to the test server. The process is outlined below,</p><ol><li>We’ll choose some non-standard port number which will be mapped to the test server internal LB. I’ve chosen port 8002.</li><li>Then we’ll configure port forwarding on PFW so that the traffic coming on the WAN interface on port 8002 is mapped to the internal LB IP (10.4.0.3) on port 443.</li></ol><p>Go to Port Forward section in Firewall — NAT in PFW console and configure a port forwarding as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F2dz7F3deBAsqMPKGnbLqA.png" /><figcaption>Port forward configuration for the test server</figcaption></figure><p>Here Service_01_Mapped_Port is port alias for 8002 and Service_01_ILB_IP is IP alias for 10.4.0.3.</p><p>Please note that while configuring the port forwarding, choose Pure NAT in the NAT reflection option just like we did earlier.</p><h3><strong>6. Configure Global External HTTP/S LB</strong></h3><p>Now we can configure global HTTP/S LB to access our application from the internet via PFW.</p><p>First step in configuring the LB is creating a health check for the test server with the mapped port (8002).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BzFtQZHju2C75X9ZzYX5xw.png" /><figcaption>Health check configuration</figcaption></figure><p>Please note, in order for health check probes to work, you’ll need to allow Google health check IP ranges on TCP port 8002 in GCP firewall on the jp-lz-ext-vpc network.</p><p>If you remember, in part II of the tutorial we had configured an instance group (IG) for our PFW instance. Same IG can be used for our external HTTP/S LB. Before we do that we need to add another named port in the IG as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WZBbB2TIdqsrzsiyv2fmww.png" /><figcaption>Mapped port for test server in the PFW IG</figcaption></figure><p>Now we can configure the external LB using the PFW IG and the health check configured above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQYnUdR7AIpy978TSvekrg.png" /><figcaption>Global external HTTP/S LB configuration</figcaption></figure><p>Finally, all setup is done and now we can test our sample Nginx server using the external HTTP/S endpoint IP (34.36.18.75 in my case). And you can configure your DNS as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9xcuEgVhes8t5tipHwcnNg.png" /><figcaption>Accessig Nginx page on the external LB IP</figcaption></figure><p>Congratulations!! Our sample Nginx application is ready and working as expected. You can similarly configure any other application you want behind your Landing Zone project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79e58a5ade42" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/setting-up-landing-zone-project-on-google-cloud-using-pfsense-firewall-part-iii-iv-79e58a5ade42">Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part III/IV</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part II]]></title>
            <link>https://blog.searce.com/setting-up-landing-zone-project-on-google-cloud-using-pfsense-firewall-part-ii-937e8546fe37?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/937e8546fe37</guid>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Thu, 08 Jun 2023 11:53:52 GMT</pubDate>
            <atom:updated>2025-02-16T21:38:59.639Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part II</h3><h3>Introduction</h3><p>In the previous part of this tutorial we had done basic pfSense firewall setup on Google cloud. In this blog (Part II) we’ll be configuring OpenVPN access server on the PFW along with an external TCP load balancer. The TCP LB is an experiment (not production tested) to connect clients to the OpenVPN access server through the LB for all active HA setup (HA will be configured in the Part IV of the tutorial).</p><p>In this blog we’ll be going through the following steps:</p><ol><li><strong>Configure Health Check Port Forwarding</strong></li><li><strong>Configure OpenVPN Access Server</strong></li><li><strong>Configure External TCP Load Balancing</strong></li><li><strong>Configure Port Forwarding for OpenVPN</strong></li></ol><h3><strong>1. Configure Health Check Port Forwarding</strong></h3><p>In order to use Google cloud load balancing we’ll need to configure health check. In our case we’ll use the web configurator login page (console) for health check (please note, it is not a good practice to use login page as health check instead you should configure a separate path for the health check to avoid long waiting connections and blocking). Currently the web configurator is accessible on port 443 (HTTPS) on LAN interface. But in order to configure health check we want the web console to be accessible on WAN interface on some non-standard port (8001 in my case, you can choose any permissible port number). For this we’ll configure port forwarding on the WAN interface.</p><p>Before we do that, we need to reserve regional external IP (jp-lz-tcp-elb-ip) for the TCP LB. Why we need to configure it first is because for TCP LB, the destination IP of packets passing through the LB is the IP (jp-lz-tcp-elb-ip) of the TCP LB itself. And we need this IP to configure the port forwarding for the health check. Once the IP is reserved we can configure the port forwarding as shown below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_UC7MY94Kf7I2v2YQMKE2g.png" /><figcaption>Port forwarding for console port mapping</figcaption></figure><p>Here the Console_Mapped_Port is port alias for 8001 and TCP_Ext_LB_IP is alias for IP reserved for the external TCP LB (34.136.3.0).</p><p>Note, while configuring the port forwarding use Pure NAT in the NAT reflection configuration as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zebu5px1eOgkb_-_cAUaXg.png" /><figcaption>NAT reflection configuration in port forwarding</figcaption></figure><p>After creating the Port forwarding, the corresponding firewall rule is also automatically created in the pfSense as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYikRdIn8O4-pnQPxjpLiw.png" /><figcaption>Port forwarding for the health check port</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hy4p9PDZ2Ca1yT_OczGerg.png" /><figcaption>Firewall rule associated with the above port forwarding</figcaption></figure><h3>2. Configure OpenVPN Access Server</h3><p>We’ll be using Wizard/OpenVPN Remote Access Server Setup wizard to configure an OpenVPN Access Server which makes our work easier by providing step by step configurations. But before that we’ll need to create a CA in Cert. Manager in pfSense console as shown below. You can create a self-signed (internal CA) if you don’t have one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7eFb4dblHD468xcF2wbiFg.png" /><figcaption>OpenVPN Access Server CA</figcaption></figure><p>Next, you need to create a server certificate, as shown below, using the above created CA for OpenVPN server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YbR2-o_DXpWQMUO39Ph8Xg.png" /><figcaption>Server certificate for the OpenVPN Access Server</figcaption></figure><p>Now we can open the OpenVPN wizard and proceed with the access server setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t27SWzyWMm0sVbpT07IzAQ.png" /><figcaption>OpenVPN setup wizard (authentication backend type)</figcaption></figure><p>Select the OpenVPN Access CA created above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EarA01_bByZoNoYDHQ4_Rg.png" /><figcaption>OpenVPN setup wizard (CA configuration)</figcaption></figure><p>Select the server certificate created above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5nIuASgMPO-uoPQEH9IM8Q.png" /><figcaption>OpenVPN setup wizard (server certificate configuration)</figcaption></figure><p>As we are planning to use VPN through a TCP LB we can choose TCP protocol for VPN which can be more reliable while using an LB. Local port can be kept as default (1194).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3nJqt1ofslkBes-Q5c8Hg.png" /><figcaption>OpenVPN setup wizard (server configuration)</figcaption></figure><p>Configure the range for the tunnel network. VPN clients will be given address from this range while connecting to the access server.</p><p>Local network is the network range accessible through the VPN. In our case it is 10.0.0.0/8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5FjQOOkZWvhltmSJJt0IQ.png" /><figcaption>OpenVPN setup wizard (tunnel network range configuration)</figcaption></figure><p>Check Firewall Rule and OpenVPN rule checkboxes. This will configure the relevant firewall rules on the pfSense to allow OpenVPN traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0AXtRSvaLX3xFcMO4qOJig.png" /><figcaption>OpenVPN setup wizard (OpenVPN firewall configuration)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqVFS-o6g8tiWHfZMelEVA.png" /><figcaption>Automatically created firewall rule for OpenVPN connections</figcaption></figure><p>Now our OpenVPN Access Server is setup and we can start using it on the WAN interface external IP. In order to do that you’ll need to allow TCP 1194 on the jp-lz-ext-vpc VPC GCP firewall from your IP address. Also you’ll need the OpenVPN client configuration to connect using OpenVPN connect client. One easy way to get the configuration is using <a href="https://docs.netgate.com/pfsense/en/latest/packages/openvpn-client-export.html">OpenVPN client export plugin</a> available on pfSense. Once the plugin is installed, you can export the client configuration from OpenVPN/Client Export Utility. Please note before exporting the OpenVPN client configuration, you’ll need to create a user certificate from User Manager in pfSense web console as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ELktghhZQrlPtyzsPtTlw.png" /><figcaption>User certificate for admin</figcaption></figure><p>Now we can access the OpenVPN but on WAN interface directly. What we want is to connect to the OpenVPN access server through the TCP LB so later we can use it to load balance between couple of PFW instances. In the next section we’ll be configuring an external pass-through TCP LB to use for OpenVPN connections.</p><h3><strong>3. Configure External TCP Load Balancing</strong></h3><p>Now we can configure the instance group, health check and the TCP LB for the OpenVPN access server in the Landing Zone project.</p><p>First we need to configure the instance group (IG) containing the primary PFW instance as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WiE1RQzipJdeL5Cyo5_3Vg.png" /><figcaption>Instance group containing the primary PFW instance</figcaption></figure><p>Next, we need to configure TCP health check using the mapped port (8001) as shown below. I’ve used the following configurations for health check interval and threshold due to the fact that smaller interval can overwhelm the web configurator and it might start blocking the health check requests (that is why I mentioned earlier that it is a good practice to have dedicated health check path).</p><ul><li>Interval — 270 seconds</li><li>Timeout — 3 seconds</li><li>Healthy threshold — 1 success</li><li>Unhealthy threshold — 3 consecutive failures</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iGvprmA4l4I3C-6WIP5Zag.png" /><figcaption>Health check configuration</figcaption></figure><p>Now we can configure the external TCP LB for the PFW. Configure a pass-through TCP LB using the above created instance group as a backend service. For LB frontend use the regional IP address reserved earlier in section 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgd8N7xWD5OqI1Pbr7vqhQ.png" /><figcaption>External TCP pass through load balancer</figcaption></figure><h3><strong>4. Configure Port Forwarding for OpenVPN</strong></h3><p>Once LB is configured we need to configure port forwarding on the WAN interface due to the following reason.</p><p>The traffic passing through the TCP LB, have the destination IP as the IP of the LB endpoint (34.136.3.0 in my case). This IP must be mapped to the internal IP of the WAN interface (10.0.0.2) so the OpenVPN traffic is properly routed to WAN interface. The configuration is shown below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_LbcsYzSpjsXnUeGpTS0w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gfYed9iAIxQE9KWE_ispqA.png" /><figcaption>Port forwarding configuration for OpenVPN</figcaption></figure><p>As you can see, I’ve kept the Filter rule association as None. The reason is that the required firewall rule was already created by the OpenVPN wizard as shown in the section 2.</p><p>Finally you can connect to the OpenVPN access server using OpenVPN clients using the TCP LB endpoint IP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*hV_lTChUFr1oRsLv6CpQXA.png" /><figcaption>OpenVPN client connecting to the OpenVPN server via TCP LB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GznrhklxLI-nSJoDtmchnw.png" /><figcaption>pfSense web console accessible on LAN internal IP using VPN</figcaption></figure><p>Congratulations!! Our OpenVPN setup is done and now you can access the internal endpoints behind the Landing Zone according to the configured pfSense firewall rules and policies. In the next part (part III) of the tutorial we’ll configure a sample Nginx server in spoke network along with an external L7 load balancer as an internet ingress to the pfSense firewall.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=937e8546fe37" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/setting-up-landing-zone-project-on-google-cloud-using-pfsense-firewall-part-ii-937e8546fe37">Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part II</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part I]]></title>
            <link>https://blog.searce.com/setting-up-landing-zone-project-on-google-cloud-using-pfsense-firewall-part-i-565f013548b0?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/565f013548b0</guid>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Sun, 04 Jun 2023 08:44:08 GMT</pubDate>
            <atom:updated>2025-02-16T21:38:46.382Z</atom:updated>
            <content:encoded><![CDATA[<h3>Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part I</h3><h3>Introduction</h3><p>In this 4 part series of tutorial we’ll be configuring a landing zone project using Hub &amp; Spoke network topology on Google cloud. In the first part (this blog) we’ll do basic configuration of VPCs and pfSense firewall VM on Google cloud. Then in the subsequent blogs we will be covering the following topics:</p><ol><li>Part II — Configuring OpenVPN remote access and L4 load balancing</li><li>Part III — Configuring sample Nginx server in spoke network and L7 load balancing</li><li>Part IV — Configuring secondary firewall instance and HA</li></ol><p>In this blog we’ll be covering the following steps:</p><ol><li><strong>Configuring Google Cloud Projects</strong> — Configure Landing Zone (LZ) host project and a Service project, VPC Networks and pfSense installer image Bucket in the LZ project.</li><li><strong>Create pfSense Installer</strong> — Download pfSense firewall (PFW) community edition installer, upload it to the bucket and create Google cloud bootable installer image.</li><li><strong>pfSense Installation</strong> — Use the above installer image to install pfSense on an additional disk using Google cloud VM instance. Then create snapshot of the additional disk to use it later for primary and secondary PFW instances.</li><li><strong>pfSense FW Instance Configuration</strong> — Create a primary PFW instance and use serial console to do startup and basic interface configuration.</li><li><strong>Upgradation and further Configuration </strong>— Use pfSense web interface for further upgradation and configuration of firewall.</li></ol><p><strong>Please note</strong>, deploying a firewall involves a lot of configurations. So I’ll detail out the important configurations and other minor configurations which are understandable and must be configured according to your use case. If in case your are stuck somewhere, please feel free to comment or reach out to me.</p><h3>1. Configuring Google Cloud Projects</h3><p>I’ll be deploying a widely used LZ model which employs Hub &amp; Spoke network topology as shown in the below architecture diagram. We’ll create 2 Google cloud project; jp-landing-zone &amp; jp-service-01 . jp-landing-zone will host the LZ and the VPC networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pLMvrHAgBfTlktLw4-XQQ.png" /><figcaption>Landing Zone architecture diagram</figcaption></figure><p>The description and use of each VPC network is outlined below:</p><ol><li>jp-lz-ext-vpc: This VPC will serve as external/untrust VPC where WAN interface of the PFW is present. All untrusted traffic from internet/VPN will be received on the interface present in this network.</li><li>jp-lz-mgmt-vpc: For management and tooling of PFW. Will host the first LAN interface of the PFW. Generally, the first LAN interface of PFW is used as internal/trust network, but in our case we’ll use it as management interface and use optional interfaces for our internal or service networks. The reason is the first LAN interface have some default settings which are more open. So by using the optional interfaces we can use more hardened configurations for our internal networks as well.</li><li>jp-lz-int-01-vpc: Network having the first optional interface of PFW and will serve as hub for service networks.</li><li>jp-lz-int-02-vpc: Network having second optional interface of PFW. May serve as a hub for future service networks.</li><li>jp-service-01-vpc: Shared network peered with the jp-lz-int-01-vpc for hosting our applications behind the firewall. Subnets in this network are shared with the jp-service-01 project.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QfYGI9kX9HTj5OZ5Rmk3DA.png" /><figcaption>VPC network setup in the LZ project</figcaption></figure><p>Note, jp-server-01-proxy-subnet is a proxy only subnet created for purpose of internal LB creation only in the service project.</p><p>We can create a firewall policy to allow internal traffic (from range 10.0.0.0/8) from all ports and protocols and associate it to all the VPC networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v8DGZtkKRpHWcAHHuKIrMw.png" /><figcaption>Firewall policy associate to all the VPC networks</figcaption></figure><p>Next, create a storage bucket (jp-lz-objects) in the LZ project for storing raw pfSense installer image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*Ei543E4dBSK50Qy6miBENA.png" /><figcaption>Cloud storage bucket to store pfSense installer image</figcaption></figure><h3><strong>2. Create pfSense Installer</strong></h3><p>Next, we’ll create bootable installer image of pfSense memstick installer. You can download the memstick installer image from the <a href="https://www.pfsense.org/download/">pfsense.org</a> download page. Choose the following download options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1M8RWmEKPHBDGUyX4L-DWQ.png" /><figcaption>pfSense installer download options</figcaption></figure><p>Note, you can choose the mirror nearest to you.</p><p>Once downloaded you can verify the checksum and then we need to convert it into image archive which the Google cloud supports.</p><pre># unzip using gunzip<br>gunzip pfSense-CE-memstick-serial-2.6.0-RELEASE-amd64.img.gz<br><br># convert to raw image<br>mv pfSense-CE-memstick-serial-2.6.0-RELEASE-amd64.img disk.raw<br><br># compress to Google cloud supported format<br>tar -Sczf pfSense-CE-memstick-serial-2.6.0-RELEASE-amd64.img.tar.gz disk.raw</pre><p>Now upload the final archive pfSense-CE-memstick-serial-2.6.0-RELEASE-amd64.img.tar.gz to jp-lz-objects bucket.</p><pre>gsutil -m cp pfSense-CE-memstick-serial-2.6.0-RELEASE-amd64.img.tar.gz gs://jp-lz-objects/images/</pre><p>Once uploaded to the bucket create a disk image from the uploaded archive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4xHimqOja0NvsiqXCTNy3w.png" /><figcaption>Installer image created from the uploaded disk image</figcaption></figure><h3><strong>3. pfSense Installation</strong></h3><p>Now we can create an installer VM instance to install the pfSense firewall from boot disk to an additional disk. Boot disk will use the installer image which we have created in the previous step. Machine type you can choose any as this instance is just for creating installation image and not the actual PFW instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0K5pZgtTjnlzz0_sxWkyQ.png" /><figcaption>Boot disk configuration of the pfSense installer instance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIv3AOiI-tfeGvyo7YQ9NA.png" /><figcaption>Additional disk configuration of the pfSense installer instance</figcaption></figure><p>Once instance is created, you can enable the serial console on the installer VM and login to the serial console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xv6GO-Txm1StkHZ5Xapcjg.png" /><figcaption>Enable connecting to the serial port</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eDJQ7GbeiYCBivCcW5gYdg.png" /><figcaption>Connect to serial port of the pfSense installer instance</figcaption></figure><p>Once serial console is opened we can proceed with the pfSense installation. You can choose default options on the serial console except for the following:</p><p>For Partitioning choose Auto (UFS) BIOS which is well supported by Google cloud VMs. I had tried UEFI but it was not able to boot on E2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCzGSbN7lUKDCbKPuKyxNw.png" /><figcaption>Partitioning option in pfSense installation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EWNBVDxJfGbmPkmxFjtYPg.png" /><figcaption>Partition scheme option in pfSense installation</figcaption></figure><p>Once the installation is complete, you can reboot the installer instance and then stop it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQAaSm_IyNc6f52mW2PoAw.png" /><figcaption>Reboot installer instance</figcaption></figure><p>Now your additional disk contains the bootable pfSense firewall. We can create snapshot of the additional disk and use it to create as many PFW instances as we want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9PjlyX9Rj62UrNP2nqaoBA.png" /><figcaption>Snapshot of the pfSense installation disk (snapshot of the additional disk)</figcaption></figure><h3><strong>4. pfSense FW Instance Configuration</strong></h3><p>Next, we’ll create primary PFW instance using the above created snapshot to configure its boot disk.</p><p>For machine type, I’ve used e2-highcpu-4 (having 4 cores). We need 4 or more core machine in order to configure 4 interfaces on the machine. For more details on the relation between core count and interface count, you can refer to the <a href="https://cloud.google.com/vpc/docs/create-use-multiple-interfaces#max-interfaces">official Google cloud document</a>.</p><p>For PFW instances, we’ve attached 4 NICs (network interface) to the instance, one in each of the following VPCs:</p><ol><li>nic0 (primary nic) — In jp-lz-ext-vpc. This will serve as WAN interface. It is important to keep it as primary NIC so we can later configure external HTTP/S LB on it.</li><li>nic1 — In jp-lz-mgmt-vpc. This will serve as management interface. Actually it’ll be the first/default LAN interface in PFW.</li><li>nic3 and nic4 in jp-lz-int-01-vpc and jp-lz-int-02-vpc respectively. These will serve as optional interfaces for 2 hub networks for the current and future service network spokes.</li></ol><p>Please note, it is very import to maintain this order otherwise you might end up with lot of manual configurations later or you might need to recreate PFW instances all together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0twMbXcOFogamTluDuqgsw.png" /><figcaption>Boot disk configuration of the primary PFW instance</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vatdk5AZFLdd5Q4ossm6KA.png" /><figcaption>Primary PFW instance</figcaption></figure><p>As you can see, for PFW instance, nic0 and nic1 are having external IP addresses configured. For nic0 we need external IP (can be removed later if you plan to use load balancers only for ingress) for internet traffic to reach the PFW. nic1 (management NIC) is given the external IP so we can whitelist our IP to access the web management console of pfSense (can be be removed later once we configure the OpenVPN access).</p><p>Now, we can enable the serial console on the primary PFW instance and access the serial console for basic interface configuration as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vIIWEkTHcBOQM43-se62w.png" /><figcaption>PFW instance basic interface configuration from serial console</figcaption></figure><p>As can be seen in above screenshot, I’ve selected the interfaces in the same order mentioned above.</p><p>It might be possible that the LAN interface doesn’t get correct interface IP automatically using DHCP, in that case you will need to temporarily assign a static IP to the interface which will be equal to the internal IP of the PFW instance of the jp-lz-mgmt-vpc NIC as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T7hhjrH___rC_bZ9g5jeMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xIAAWoZbBPq4T1pyPQaxJQ.png" /><figcaption>Static IP configuration for the LAN interface</figcaption></figure><p>Once that is done, the LAN (mgmt) interface will be assigned the right IP. Now you can access the web console using the external IP of the mgmt interface, provided Google cloud firewall rules allow TCP 443/80 port access from your IP.</p><p>Note, you might need to disable HTTP referer check to allow proper web console access. You can use the shell from serial console only and use the following command to disable the HTTP referer check.</p><pre>pfSsh.php playback disablereferercheck</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*36bQNxTsVs0Sn938LmeMEA.png" /><figcaption>Disable HTTP referer check on the webConfigurator</figcaption></figure><p>Now, you can access the web console on the mgmt external IP as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_-eHUXtWB0WGr7iYq_yYjQ.png" /><figcaption>pfSense web login console</figcaption></figure><p>The default username is admin and the default password is pfsense. Once logged in you can go through the setup wizard to configure a new password and hostname. Also you can upload your own SSL certificate if you have one and configure your DNS to use a domain name to access the console instead of the external IP.</p><h3><strong>5. Upgradation and further Configuration</strong></h3><p>Now, once you are logged in to the web console and have gone through the setup wizard we can upgrade the pfSense firewall from community edition to plus evaluation edition for <strong>non-commercial</strong> use only.</p><p>You can go to the <a href="https://shop.netgate.com/products/pfsense-software-subscription">pfSense+ subscription page</a> and subscribe for non-commercial evaluation edition of pfSense+. Once subscribed you’ll receive activation token on your email. Now, you can follow the simple upgradation steps detailed on the <a href="https://docs.netgate.com/pfsense/en/latest/install/migrate-to-plus.html">migration page</a>. Once upgraded we can proceed with further configuration.</p><p>If you remember we had configured static IP for the LAN interface. We can now change the configuration to DHCP from the web console and check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ES68Kpo2nMDsgD2j_Td9nw.png" /><figcaption>LAN interface reconfiguration through the web console</figcaption></figure><p>If you lose access to the web console after changing to DHCP, you can access the serial console and reconfigure the static IP for LAN interface just like we did in the previous step.</p><p>Congratulations!! Our basic configuration of primary PFW is completed. In the next part (Part II) of this tutorial we’ll configure OpenVPN access server and L4 (TCP load balancing).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=565f013548b0" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/setting-up-landing-zone-project-on-google-cloud-using-pfsense-firewall-part-i-565f013548b0">Setting up Landing Zone Project on Google Cloud using pfSense Firewall — Part I</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we migrated over a Petabyte of objects storage from AWS S3 to GCS within a few weeks]]></title>
            <link>https://blog.searce.com/how-we-migrated-over-a-petabyte-of-objects-storage-from-aws-s3-to-gcs-within-a-few-weeks-dff97a2d74b1?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/dff97a2d74b1</guid>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[google-cloud-storage]]></category>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 09:44:28 GMT</pubDate>
            <atom:updated>2023-04-19T10:55:26.395Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>We recently needed to migrate over a Petabyte of object storage from AWS S3 to GCS for one of our customers. Also, we had to keep the source and destination buckets in sync for the newly added objects on an hourly basis. While there are some native services offered by AWS and Google Cloud for object storage transfer, due to some specific requirements we had to design and build our own solution to migrate the data efficiently and in a cost-effective way. The use case looked something like this:</p><ol><li>Source S3 bucket having nearly a Petabyte of objects in STANDARD storage class.</li><li>There were nearly 2B objects in the source bucket, each with a size of 300 KB to 600 KB.</li><li>These objects were transcoded chunks of video files, and the source bucket was exposed to the public through Cloudfront CDN.</li><li>Objects were organized in folders, each folder containing transcoded chunks of a single video file. There were nearly 2M such folders for all the objects in STANDARD storage.</li><li>Folders for new transcoded videos were being added every couple of minutes.</li></ol><p>Based on the above use case, our solution had to fulfill the following requirements:</p><ol><li>Use Cloudfront CDN URL to download objects while transferring to the destination bucket to save egress costs on the AWS end and increase download speed.</li><li>The solutions should be horizontally scalable to accommodate such a large count of objects.</li><li>Keep the source and destination buckets in sync, in an efficient and cost-effective way, for new folders uploaded in the source bucket.</li><li>Once the migration is completed, it should be validated to ensure matching source and destination object sizes.</li></ol><h3>Solution</h3><p>The complete solution was hosted on Google Cloud and had three main parts or phases:</p><ol><li>Source bucket folders listing and state management.</li><li>Publisher group.</li><li>Worker group.</li></ol><p>Each part was handled by a separate program and we decided to go for VM instances (MIG) to run our programs. We had the option to go for serverless options such as Cloud functions/Cloud run but these solutions are more efficient for event-based processing, which was not the case here. We eliminated the option of GKE due to the fact that our programs were basically running Python scripts and containerization and orchestration were not needed here and were also not very efficient. The following diagrams show the three parts/phases of our solution.</p><p><strong>Folders listing program:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yZkXMxK8jlmzZwX3UPGjPA.png" /><figcaption>Folders listing program</figcaption></figure><ol><li>This program runs in a single VM instance and it fetches the folders list from the source S3 bucket using aws s3 CLI (using CLI instead of a Python script is more efficient, as CLI uses the least possible API calls for listing). You can also explore S3 analytics API to make this process even more efficient.</li><li>Once the folders list is ready, a Python script uploads the new folders into a MySQL DB hosted on CloudSQL. This process is performed at regular intervals. The DB maintains the state of folders which are transferred, or yet to be transferred and other flags required for transfer process. It also maintains size of folders in source and destination bucket for later validation process. We maintained folder details instead of individual object details in DB due to the fact that maintaining 2B object details in a DB would be inefficient, complex and not required.</li><li>Another Python script running in the VM instance query the newly added folders from the DB, then pushes it to a Pub/Sub queue (folder queue) and updates relevant flag fields in the DB.</li></ol><p><strong>Publisher program:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wosxFtm3iTC_2fP8FxSh9g.png" /><figcaption>Publisher program</figcaption></figure><ol><li>The publisher program runs in a managed instance group to take advantage of horizontal scalability, which was possible because of Pub/Sub and the use of DB.</li><li>The program pulls folder details from the folder Pub/Sub queue, then lists all the objects in the folder and pushes the objects list to another Pub/Sub queue (object queue). Once all the objects for the folder are published, respective flag fields for the folder are updated in the DB. Note, here the script pushes a list of 50–100 objects in a single Pub/Sub message and batch multiple messages in a single request because in Pub/Sub, independent of the message sizes in the request, a minimum of 1 KB is assessed for each request. As a result, it is cheaper to batch multiple messages in a single request for messages smaller than 1 KB.</li><li>There were multiple processes of Python scripts running in a single VM instance in the MIG. In our case we used e2-standard-4 instances with 10–16 processes running in each VM.</li></ol><p><strong>Worker program:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_F1feFnDIVZYtgRSUB9JQ.png" /><figcaption>Worker program</figcaption></figure><p>The worker program also runs in a managed instance group to take advantage of horizontal scalability, which was possible because of Pub/Sub.</p><p>This program runs in two modes:</p><ol><li><strong>Transfer mode:</strong> <br>- In this mode, the program pulls the objects list from the object Pub/Sub queue, then downloads the objects through its Cloudfront URL (Cloudfront URL was obtained by appending the object key to the Cloudfront host URL). <br>- Once the object is downloaded, it is uploaded to the destination bucket along with object metadata obtained from the download response headers. <br>- The object was downloaded and uploaded from memory without writing to disk (which was possible due to lower object size) reducing transfer time significantly.</li><li><strong>Validation mode:</strong> <br>In this mode, the program pulls folders list from the folder Pub/Sub queue, validates size and etag for each object in the folder in source and destination buckets (used list method to save API requests cost). Once validated, respective fields for the folder are updated in the DB, such as source and destination folder size, etc. Note, in our case all the objects in source bucket were below 16MB in size and the objects were not multipart uploaded in the source bucket. Also the encryption used on source bucket ensured that the object ETag was equivalent to the MD5 digest of the object.</li></ol><p>In both of the modes, there were multiple processes of Python scripts running in a single VM instance in the MIG. In our case we used e2-standard-4 instances with 10–16 processes running in each VM.</p><h3>Results</h3><p>The results were surprising and we were able to achieve more than we expected.</p><ul><li>We were able to migrate nearly a Petabyte of data within 4 weeks, which could’ve been further reduced by scaling out the MIG.</li><li>We observed a transfer speed of nearly 700–800 MB/s for the small-sized objects. We observed 2–3 GB/s transfer speed for larger objects during test runs.</li><li>We could keep the source and destination buckets in sync for newly added objects at 1–2 hourly.</li><li>We were able to carry out the migration at significantly lower costs than the estimates calculated for the conventional transfer service/method.</li><li>We carried out another migration activity using a similar method but hosted on AWS (using RDS, SQS, and ASG) as both the source and destination buckets were in AWS, and we were able to obtain a transfer rate of more than 3TB per hour (using ASG of 5 m5.xlarge instances for the worker program).</li></ul><p>Thanks for reading and feel free to contact us; for the code as well :)</p><p><strong>Thank you note: I would like to thank Mukesh Panigrahi for his valuable insights and guidance on this project.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dff97a2d74b1" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/how-we-migrated-over-a-petabyte-of-objects-storage-from-aws-s3-to-gcs-within-a-few-weeks-dff97a2d74b1">How we migrated over a Petabyte of objects storage from AWS S3 to GCS within a few weeks</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Google Cloud Global HTTP/S Load Balancer with Istio Ingress for HTTP/S traffic]]></title>
            <link>https://towardsdev.com/using-google-cloud-global-http-s-load-balancer-with-istio-ingress-for-http-s-traffic-a46321c4302d?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/a46321c4302d</guid>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Sat, 11 Feb 2023 14:32:29 GMT</pubDate>
            <atom:updated>2024-04-20T00:36:26.089Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In my previous blog on <a href="https://medium.com/@pateljheel/multi-cluster-multi-primary-istio-setup-on-gke-clusters-deployed-in-separate-regions-in-a-shared-d7793ca31d0b">Multi-cluster Multi-primary Istio setup on GKE Clusters deployed in separate Regions in a Shared VPC</a> we used the default Google cloud TCP load balancing for the Istio ingress. TCP LB allows you to use non-standard ports for TCP traffic, but you can’t use certain managed L7 services such as <strong>Cloud Armor</strong> WAF, etc. <strong>Cloud Armor</strong> provides protection against L7 attacks (SQLi, XSS, DDoS, etc.) and needs global HTTP/S load balancer.</p><p>In this blog, we’ll modify existing Istio installation in the multi-cluster setup to deploy a new Istio ingress controller, for HTTPS traffic, along with the default one. The new ingress will be configured as ClusterIP service with NEG (network endpoint group) annotations to create a standalone NEG for the ClusterIP service. Then we’ll create a regional backend service for the NEG of each GKE cluster Istio ingress for HTTPS (alpha-cluster and beta-cluster), which will be later used for configuring load balancers.</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0teIiYrLcJPUdpMHx3XC-Q.png" /><figcaption>Solution architecture</figcaption></figure><p>As shown in the architecture diagram, we’ll configure another Istio ingress controller only for HTTP/S traffic. This controller will have ClusterIP type service and a standalone NEG in each zone of the cluster deployment. These NEGs will serve as backend for internal HTTP/S load balancers in istio-host-project using cross-project backend service feature available in regional HTTP/S load balancing in Google cloud. Then a global external HTTP/S load balancer, in istio-host-project, will serve as a primary entrypoint for HTTP/S traffic for the internal HTTP/S load balancers.</p><h3>Setup</h3><p><strong>Configure network and firewall rules</strong></p><p>If you remember, we allowed 443 (HTTPS) traffic on all the GKE nodes to allow traffic on nodes coming through Istio ingress TCP LB. We need to disable that firewall rule to allow traffic from only the HTTP/S LB which we’ll configure later.</p><pre># disable firewall rule allowing any origin on 443<br>gcloud compute firewall-rules update istio-allow-443 \<br>   --project=istio-host-project \<br>   --disabled</pre><p>We are going to create few health checks for backend services and load balancers, for which we’ll need to allow Google cloud health check source IP ranges.</p><p>In addition to GKE nodes subnets, we’ll need to configure proxy-only subnet in each region where we need to configure internal HTTP/S load balancer.</p><pre># create proxy-only subnet in us-central1 region<br>gcloud compute networks subnets create us-central1-proxy \<br>    --network=host-vpc --project=istio-host-project \<br>    --purpose=REGIONAL_MANAGED_PROXY --role=ACTIVE \<br>    --range=&quot;10.144.0.0/24&quot; \<br>    --region=us-central1 <br><br># create proxy-only subnet in us-east1 region<br>gcloud compute networks subnets create us-east1-proxy \<br>    --network=host-vpc --project=istio-host-project \<br>    --purpose=REGIONAL_MANAGED_PROXY --role=ACTIVE \<br>    --range=&quot;10.146.0.0/24&quot; \<br>    --region=us-east1</pre><pre># configure health-check ip ranges and proxy subnet ip ranges on the GKE nodes<br>ALL_CLUSTER_NETTAGS=&quot;$(gcloud compute instances list --project istio-alpha-project --format=&#39;value(tags.items.[0])&#39; | sort | uniq),$(gcloud compute instances list --project istio-beta-project --format=&#39;value(tags.items.[0])&#39; | sort | uniq)&quot;<br>gcloud compute firewall-rules create fw-allow-health-check-and-proxy \<br>   --network=host-vpc \<br>   --action=allow \<br>   --direction=ingress \<br>   --target-tags=$ALL_CLUSTER_NETTAGS \<br>   --source-ranges=130.211.0.0/22,35.191.0.0/16,10.144.0.0/24,10.146.0.0/24 \<br>   --rules=tcp:15021,tcp:443 \<br>   --project=istio-host-project</pre><p><strong>Upgrade Istio</strong></p><p>Next, we’ll upgrade Istio setup on both the clusters with updated configuration values. The new configuration will create two ingress controllers — one will be the same TCP LB type service ingress controller and the second will have ClusterIP type service serving 443 only and with annotations to create standalone NEG.</p><pre># from main directory switch to alpha_cluster directory<br>cd alpha_cluster<br><br># create new istio operator values override manifest<br>cat &lt;&lt;EOF &gt; istio_operator_values.yaml<br>apiVersion: install.istio.io/v1alpha1<br>kind: IstioOperator<br>spec:<br>  components:<br>    ingressGateways:<br>    - enabled: true<br>      name: istio-ingressgateway<br>      namespace: istio-ingress<br>    - enabled: true<br>      name: istio-ingressgateway-https<br>      namespace: istio-ingress<br>      label:<br>        istio: ingressgateway-https<br>      k8s:<br>        service:<br>          type: ClusterIP<br>          ports:<br>          - name: status-port<br>            port: 15021<br>            protocol: TCP<br>            targetPort: 15021<br>          - name: https<br>            port: 443<br>            protocol: TCP<br>            targetPort: 443<br>        serviceAnnotations: <br>          cloud.google.com/neg: &#39;{&quot;exposed_ports&quot;: {&quot;443&quot;:{&quot;name&quot;: &quot;alpha-istio-https&quot;}}}&#39;<br>          cloud.google.com/app-protocols: &#39;{&quot;https&quot;:&quot;HTTP/2&quot;}&#39;<br>  values:<br>    global:<br>      meshID: mesh1<br>      multiCluster:<br>        enabled: true<br>        clusterName: alpha-cluster<br>      network: host-vpc<br>    gateways:<br>      istio-ingressgateway:<br>        runAsRoot: true<br>EOF<br><br># upgrade istio on alpha-cluster with the new configurations<br>./istio-1.15.0/bin/istioctl upgrade -f istio_operator_values.yaml --context=$CTX_CLUSTER1<br><br># go back to the main directory<br>cd ..<br><br># from main directory switch to beta_cluster directory<br>cd beta_cluster<br><br># create new istio operator values override manifest<br>cat &lt;&lt;EOF &gt; istio_operator_values.yaml<br>apiVersion: install.istio.io/v1alpha1<br>kind: IstioOperator<br>spec:<br>  components:<br>    ingressGateways:<br>    - enabled: true<br>      name: istio-ingressgateway<br>      namespace: istio-ingress<br>    - enabled: true<br>      name: istio-ingressgateway-https<br>      namespace: istio-ingress<br>      label:<br>        istio: ingressgateway-https<br>      k8s:<br>        service:<br>          type: ClusterIP<br>          ports:<br>          - name: status-port<br>            port: 15021<br>            protocol: TCP<br>            targetPort: 15021<br>          - name: https<br>            port: 443<br>            protocol: TCP<br>            targetPort: 443<br>        serviceAnnotations: <br>          cloud.google.com/neg: &#39;{&quot;exposed_ports&quot;: {&quot;443&quot;:{&quot;name&quot;: &quot;beta-istio-https&quot;}}}&#39;<br>          cloud.google.com/app-protocols: &#39;{&quot;https&quot;:&quot;HTTP/2&quot;}&#39;<br>  values:<br>    global:<br>      meshID: mesh1<br>      multiCluster:<br>        enabled: true<br>        clusterName: beta-cluster<br>      network: host-vpc<br>    gateways:<br>      istio-ingressgateway:<br>        runAsRoot: true<br>EOF<br><br># upgrade istio on beta-cluster with the new configurations<br>./istio-1.16.1/bin/istioctl upgrade -f istio_operator_values.yaml --context=$CTX_CLUSTER2<br><br># go back to the main directory<br>cd ..</pre><p><strong>Note</strong> — in above configuration we are running the ingress controller containers as root, reason being we are using the restricted port of the nodes in the new ingress controller for HTTPS.</p><p>Once the Istio is successfully upgraded you can see zonal NEGs created for the ClusterIP service in each zone (for regional clusters).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Onsn6ZdIoXONEW8tV84tQ.png" /><figcaption>alpha-cluster Istio HTTPS ingress service NEG</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XUBjSrWYxMh4kLvK8VtAyQ.png" /><figcaption>beta-cluster Istio HTTPS ingress service NEG</figcaption></figure><p><strong>Configure test application</strong></p><p>In the previous tutorial we had deployed alpha_helloworld application in alpha-cluster and beta_helloworld application in beta-cluster. Now, we’ll need to deploy another gateway in each cluster and modify the virtual service of both the applications to use the other gateway also. You can use the provided <a href="https://github.com/scienceto/blog-content/blob/main/istio-multi-cluster/sample_armor/alpha_helloworld.yaml">alpha_helloworld.yaml</a> and <a href="https://github.com/scienceto/blog-content/blob/main/istio-multi-cluster/sample_armor/beta_helloworld.yaml">beta_helloworld.yaml</a> manifests.</p><pre># deploy alpha_helloworld.yaml on the alpha-cluster in default namespace<br>kubectl apply -f https://raw.githubusercontent.com/scienceto/blog-content/main/istio-multi-cluster/sample_armor/alpha_helloworld.yaml -n default --context=$CTX_CLUSTER1<br><br># deploy beta_helloworld.yaml on the beta-cluster in default namespace<br>kubectl apply -f https://raw.githubusercontent.com/scienceto/blog-content/main/istio-multi-cluster/sample_armor/beta_helloworld.yaml -n default --context=$CTX_CLUSTER2</pre><p><strong>Configure load balancing</strong></p><p>Before configuring load balancers, we first need to create health checks for Istio ingress controller services.</p><pre># configure health check for alpha-cluster services<br>gcloud beta compute health-checks create http alpha-istio-hc \<br>    --project=istio-alpha-project \<br>    --port=15021 --request-path=/healthz/ready --proxy-header=NONE \<br>    --region=us-central1 \<br>    --no-enable-logging \<br>    --check-interval=5 --timeout=5 --unhealthy-threshold=2 --healthy-threshold=2</pre><pre># configure health check for beta-cluster services<br>gcloud beta compute health-checks create http beta-istio-hc \<br>    --project=istio-beta-project \<br>    --port=15021 --request-path=/healthz/ready --proxy-header=NONE \<br>    --region=us-east1 \<br>    --no-enable-logging \<br>    --check-interval=5 --timeout=5 --unhealthy-threshold=2 --healthy-threshold=2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UMMrAyu1of8zPs8xKd6LtA.png" /><figcaption>alpha-cluster Istio service health check</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hRSbKb_OnrY5iCGLhNhCJw.png" /><figcaption>beta-cluster Istio service health check</figcaption></figure><p>Next we’ll configure regional backend services and add Istio ingress controller service NEGs to the respective backend services.</p><pre># create alpha-cluster istio ingress backend-service and add the respective NEGs<br>gcloud compute backend-services create alpha-https-neg \<br>    --project=istio-alpha-project \<br>    --health-checks=alpha-istio-hc \<br>    --health-checks-region=us-central1 \<br>    --load-balancing-scheme=INTERNAL_MANAGED \<br>    --port-name=https \<br>    --protocol=HTTPS \<br>    --region=us-central1<br><br># you&#39;ll need to repeat the following command for all the zonal negs created for the istio ingress (for regional gke cluster)<br>gcloud compute backend-services add-backend alpha-https-neg \<br>    --network-endpoint-group=alpha-istio-https \<br>    --network-endpoint-group-zone=us-central1-a \<br>    --region=us-central1 \<br>    --balancing-mode=RATE \<br>    --capacity-scaler=1.0 \<br>    --max-rate-per-endpoint=10.0 \<br>    --project=istio-alpha-project</pre><pre># create beta-cluster istio ingress backend-service and add the respective NEGs<br>gcloud compute backend-services create beta-https-neg \<br>    --project=istio-beta-project \<br>    --health-checks=beta-istio-hc \<br>    --health-checks-region=us-east1 \<br>    --load-balancing-scheme=INTERNAL_MANAGED \<br>    --port-name=https \<br>    --protocol=HTTPS \<br>    --region=us-east1<br><br># you&#39;ll need to repeat the following command for all the zonal negs created for the istio ingress (for regional gke cluster)<br>gcloud compute backend-services add-backend beta-https-neg \<br>    --network-endpoint-group=beta-istio-https \<br>    --network-endpoint-group-zone=us-east1-b \<br>    --region=us-east1 \<br>    --balancing-mode=RATE \<br>    --capacity-scaler=1.0 \<br>    --max-rate-per-endpoint=10.0 \<br>    --project=istio-beta-project</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTLIEngD2hALYjVLjZO9lA.png" /><figcaption>alpha-cluster Istio NEG backend service</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xedAWXZWuzSOoZlNBR6niA.png" /><figcaption>beta-cluster Istio NEG backend service</figcaption></figure><p><strong>From now onwards, all the steps will be performed in the </strong><strong>istio-host-project.</strong></p><p>Before configuring any proxies or LBs we’ll need to create global and regional self-managed SSL certificates. We can upload our self-signed certificate here.</p><pre># create global ssl certificate<br>gcloud compute ssl-certificates create wildcard-cert \<br>    --certificate=fullchain.pem \<br>    --private-key=privkey.pem \<br>    --global \<br>    --project=istio-host-project</pre><pre># create ssl certificate in us-central1 region<br>gcloud compute ssl-certificates create wildcard-cert \<br>    --certificate=fullchain.pem \<br>    --private-key=privkey.pem \<br>    --region=us-central1 \<br>    --project=istio-host-project</pre><pre># create ssl certificate in us-east1 region<br>gcloud compute ssl-certificates create wildcard-cert \<br>    --certificate=fullchain.pem \<br>    --private-key=privkey.pem \<br>    --region=us-east1 \<br>    --project=istio-host-project</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WhINTHfpknKfMXn853s5ZA.png" /><figcaption>Self-managed SSL certificates</figcaption></figure><p>Next, we’ll create regional internal HTTP/S LB for each backend service (alpha and beta) in istio-host-project.</p><pre><br># create alpha-istio url map using cross project backend service<br>gcloud compute url-maps create alpha-istio-ilb \<br>    --project=istio-host-project \<br>    --default-service=projects/istio-alpha-project/regions/us-central1/backendServices/alpha-https-neg \<br>    --region=us-central1<br><br># create alpha-istio https proxy using the url map<br>gcloud compute target-https-proxies create alpha-istio-https-proxy \<br>    --url-map alpha-istio-ilb \<br>    --project=istio-host-project \<br>    --region=us-central1 \<br>    --ssl-certificates=wildcard-cert<br><br># create alpha-istio forwarding rule using the https proxy<br>gcloud compute forwarding-rules create alpha-istio-ilb \<br>    --project=istio-host-project \<br>    --region=us-central1 \<br>    --target-https-proxy=alpha-istio-https-proxy \<br>    --target-https-proxy-region=us-central1 \<br>    --load-balancing-scheme=INTERNAL_MANAGED \<br>    --network=host-vpc \<br>    --subnet=us-central1 \<br>    --address=10.140.0.10 \<br>    --allow-global-access \<br>    --ports=443</pre><pre># create beta-istio url map using cross project backend service<br>gcloud compute url-maps create beta-istio-ilb \<br>    --project=istio-host-project \<br>    --default-service=projects/istio-beta-project/regions/us-east1/backendServices/beta-https-neg \<br>    --region=us-east1<br><br># create beta-istio https proxy using the url map<br>gcloud compute target-https-proxies create beta-istio-https-proxy \<br>    --url-map beta-istio-ilb \<br>    --project=istio-host-project \<br>    --region=us-east1 \<br>    --ssl-certificates=wildcard-cert<br><br># create beta-istio forwarding rule using the https proxy<br>gcloud compute forwarding-rules create beta-istio-ilb \<br>    --project=istio-host-project \<br>    --region=us-east1 \<br>    --target-https-proxy=beta-istio-https-proxy \<br>    --target-https-proxy-region=us-east1 \<br>    --load-balancing-scheme=INTERNAL_MANAGED \<br>    --network=host-vpc \<br>    --subnet=us-east1 \<br>    --address=10.142.0.10 \<br>    --allow-global-access \<br>    --ports=443</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9J5rX1EJ8INqtNGnLvT71g.png" /><figcaption>alpha and beta cluster Istio HTTPS ingress service internal LB</figcaption></figure><p>If you observe, we’ve used cross project backend services for configuring the url maps. Currently, only the internal and regional external HTTP/S LB supports cross project backend services and this feature will soon be introduced for global HTTP/S LB which will allow us to directly configure global HTTP/S LB with the cross project NEG backend services instead for creating intermediate internal HTTP/S LB.</p><p>Next, we’ll create hybrid NEGs, each pointing to alpha and beta internal LB IP. We’ll first create hybrid NEG in each cluster location (in my case it is a zonal cluster so I’ll create single hybrid NEG for each cluster).</p><pre># create hybrid neg in alpha-cluster zone<br>gcloud compute network-endpoint-groups create alpha-istio-ilb-neg \<br>    --network-endpoint-type=NON_GCP_PRIVATE_IP_PORT \<br>    --zone=us-central1-a \<br>    --network=host-vpc \<br>    --project=istio-host-project<br><br># create hybrid neg in beta-cluster zone<br>gcloud compute network-endpoint-groups create beta-istio-ilb-neg \<br>    --network-endpoint-type=NON_GCP_PRIVATE_IP_PORT \<br>    --zone=us-east1-b \<br>    --network=host-vpc \<br>    --project=istio-host-project</pre><p>Once, hybrid NEGs are created, we’ll need to add IP:Port of the regional internal LBs in the respective NEGs.</p><pre># add us-central1 internal lb endpoint in negs in us-central1 region zones<br>gcloud compute network-endpoint-groups update alpha-istio-ilb-neg \<br>    --zone=us-central1-a \<br>    --add-endpoint=&quot;ip=10.140.0.10,port=443&quot; \<br>    --project=istio-host-project<br><br># add us-east1 internal lb endpoint in negs in us-east1 region zones<br>gcloud compute network-endpoint-groups update beta-istio-ilb-neg \<br>    --zone=us-east1-b \<br>    --add-endpoint=&quot;ip=10.142.0.10,port=443&quot; \<br>    --project=istio-host-project</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5djgltqIjIQTMwnpvmmmw.png" /><figcaption>Hybrid NEGs pointing to alpha and beta Istio ingress internal LB</figcaption></figure><p>Now, we’ll configure health-check for the global HTTP/S LB.</p><pre># create global health-check<br>gcloud beta compute health-checks create https istio-global-hc \<br>    --project=istio-host-project \<br>    --port=443 --request-path=/hello \<br>    --proxy-header=NONE --no-enable-logging \<br>    --check-interval=10 --timeout=10 --unhealthy-threshold=2 --healthy-threshold=2</pre><p>Configure backend services for alpha and beta hybrid NEGs. And add the hybrid NEGs in the respective backend services.</p><pre># create alpha-https-bs for alpha istio negs<br>gcloud compute backend-services create alpha-https-bs \<br>      --health-checks=istio-global-hc \<br>      --load-balancing-scheme=EXTERNAL_MANAGED \<br>      --protocol=https \<br>      --global --project=istio-host-project<br><br># add all alpha istio negs in the backend service<br>gcloud compute backend-services add-backend alpha-https-bs \<br>      --global --project=istio-host-project \<br>      --balancing-mode=RATE \<br>      --max-rate-per-endpoint=10 \<br>      --network-endpoint-group=alpha-istio-ilb-neg \<br>      --network-endpoint-group-zone=us-central1-a</pre><pre># create beta-https-bs for beta istio negs<br>gcloud compute backend-services create beta-https-bs \<br>      --health-checks=istio-global-hc \<br>      --load-balancing-scheme=EXTERNAL_MANAGED \<br>      --protocol=https \<br>      --global --project=istio-host-project<br><br># add all beta istio negs in the backend service<br>gcloud compute backend-services add-backend beta-https-bs \<br>      --global --project=istio-host-project \<br>      --balancing-mode=RATE \<br>      --max-rate-per-endpoint=10 \<br>      --network-endpoint-group=beta-istio-ilb-neg \<br>      --network-endpoint-group-zone=us-east1-b</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCsUzghhaAejEX6PhDRPUQ.png" /><figcaption>alpha HTTPS backend service associated with alpha hybrid NEG</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zp4qTXWKkgh0B2QIsYleyg.png" /><figcaption>beta HTTPS backend service associated with beta hybrid NEG</figcaption></figure><p>Next, we’ll configure the global external HTTP/S LB which will serve as main ingress.</p><pre># reserve global external ip address<br>gcloud compute addresses create istio-main-elb-ip \<br>      --network-tier=PREMIUM \<br>      --global --project=istio-host-project<br><br># create url map<br>gcloud compute url-maps create istio-main-elb \<br>      --default-service alpha-https-bs \<br>      --project=istio-host-project <br><br># create https proxy<br>gcloud compute target-https-proxies create istio-main-elb-https-proxy \<br>    --url-map istio-main-elb \<br>    --project=istio-host-project \<br>    --global \<br>    --ssl-certificates=wildcard-cert<br><br># create the forwarding rule<br>gcloud compute forwarding-rules create istio-main-elb \<br>    --load-balancing-scheme=EXTERNAL_MANAGED \<br>    --network-tier=PREMIUM \<br>    --address=istio-main-elb-ip \<br>    --target-https-proxy=istio-main-elb-https-proxy \<br>    --global --project=istio-host-project \<br>    --ports=443</pre><p>Our global load balancer is now configured with a single backend service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZj8Li1bo3S96z0pLo0zZQ.png" /><figcaption>Global external HTTPS load balancer</figcaption></figure><p>We can now configure the global LB from GUI and add the other backend service as well with weighted routing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6oUmJHsJIXqBuMwK4WgqQ.png" /><figcaption>Add both the backend services to the global HTTPS LB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OjcTLi2b7Mb382VqIk3MlQ.png" /><figcaption>Add routing rule to the global HTTPS LB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYi_JQ3MfbG64UCitlHnQg.png" /><figcaption>Global external HTTPS LB pointing to both the backend services</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*TJsDhRKDv-_0VXVl_zejew.png" /><figcaption>Response coming from alpha helloworld via global HTTPS LB</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*FlcfJSDv0WEvhW1buGHNsg.png" /><figcaption>Response coming from beta helloworld via global HTTPS LB</figcaption></figure><p>Congratulations!! Our global HTTP/S LB endpoint is working as expected. Now you can configure Cloud Armor and other advanced features available on Google cloud global HTTP/S LB.</p><h4>References</h4><ol><li><a href="https://cloud.google.com/load-balancing/docs/https/setting-up-ext-global-https-hybrid">Set up a global external HTTP(S) load balancer with hybrid connectivity | Load Balancing | Google Cloud</a></li><li><a href="https://cloud.google.com/load-balancing/docs/https/setting-up-https#gcloud-and-using-curl">Request routing to a multi-region external HTTPS load balancer | Load Balancing | Google Cloud</a></li><li><a href="https://cloud.google.com/load-balancing/docs/health-checks">Creating health checks | Load Balancing | Google Cloud</a></li><li><a href="https://cloud.google.com/blog/products/networking/cloud-load-balancing-gets-cross-project-service-referencing">Cloud Load Balancing gets cross-project service referencing | Google Cloud Blog</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a46321c4302d" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/using-google-cloud-global-http-s-load-balancer-with-istio-ingress-for-http-s-traffic-a46321c4302d">Using Google Cloud Global HTTP/S Load Balancer with Istio Ingress for HTTP/S traffic</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-cluster Multi-primary Istio setup on GKE Clusters deployed in separate Regions in a Shared…]]></title>
            <link>https://towardsdev.com/multi-cluster-multi-primary-istio-setup-on-gke-clusters-deployed-in-separate-regions-in-a-shared-d7793ca31d0b?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7793ca31d0b</guid>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Sun, 05 Feb 2023 07:14:49 GMT</pubDate>
            <atom:updated>2024-04-20T00:38:46.626Z</atom:updated>
            <content:encoded><![CDATA[<h3>Multi-cluster Multi-primary Istio setup on GKE Clusters deployed in separate Regions in a Shared VPC</h3><h3>Introduction</h3><p>Since past couple of years, Kubernetes have become one of the most popular technologies for workload deployment due to it’s capabilities of advanced container orchestration, micro-service level networking, load-balancing, faster deployments, etc. Istio helps you extend Kubernetes capabilities by providing a service mesh with some advanced capabilities. In this blog we’ll deploy multi-primary Istio on two Google Kubernetes Engine (GKE) clusters each deployed in a separate region in a shared VPC.</p><h3>Multi-primary Istio</h3><p>First, what is multi-primary Istio configuration? In multi-primary Istio configuration, we deploy Istio on multiple clusters in a distributed fashion where each cluster have it’s own Istio control plane but whole setup works as a single service mesh distributed over multiple clusters. This provides following advantages over single cluster or multi-cluster with primary remote model:</p><ol><li>Fault tolerance: If one cluster/primary Istio goes down, another can serve the traffic.</li><li>Multi-regional: Increased availability and location-aware routing and fail over.</li><li>Isolation of teams: Each team can work on separate cluster, allowing separation of duties.</li><li>GKE Cluster/Istio can be upgraded reliably: One cluster can be upgraded at a time, so that if the upgrade fails and one cluster goes down, the other cluster can still serve the traffic.</li></ol><h3>Architecture</h3><p>In this tutorial, we’ll use three Google cloud projects each with the purpose mentioned below:</p><ol><li>istio-host-project: Project hosting the shared VPC.</li><li>istio-alpha-project: Project hosting alpha-cluster GKE cluster in us-central1 region subnet shared by the istio-host-project.</li><li>istio-beta-project: Project hosting beta-cluster GKE in us-east1 region subnet shared by the istio-host-project.</li></ol><p>The main advantage of using a shared VPC with separate projects for each cluster is separation of duties and IAM roles at project level and better network management in a single host project.</p><p>Both the clusters will be private GKE clusters and we’ll setup Istio in multi-primary configuration on both GKE clusters with Kubernetes control plane visibility on the control plane internal IP.</p><p>For alpha-cluster I’ll use Kubernetes version 1.21.14 with Istio 1.15.0 and for beta-cluster Kubernetes version 1.24.9 with Istio 1.16.1. This will help us test a wide case scenerio with different Kubernetes and Istio versions in multi-primary setup. (Please note, at the time of writing this blog, Kubernetes version 1.21 have reached its end of life and Istio no longer supports Kubernetes version 1.21, but for testing purpose I tried to setup 1.21 and it worked, which means other latest versions should work fine).</p><p>The overall architecture along with test application is shown below,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V2GeeJ9ks934sAIrR1w5VQ.png" /><figcaption>Architecture diagram</figcaption></figure><p><strong>Note — in this tutorial, I’ve used shared VPC model, but this will work for simple VPC setup as well.</strong></p><h3>Infrastructure Setup</h3><p><strong>Configure Google cloud projects and shared VPC</strong></p><p>First, we’ll need to configure three projects and and a shared VPC. In order to use shared VPC your projects must belong to a Google cloud organization. You’ll also need Compute Shared VPC Admin role on the organization or the folder under which your projects will reside. To keep it short, this blog will focus on configuring multi-primary Istio setup. You can follow this <a href="https://cloud.google.com/vpc/docs/provisioning-shared-vpc">Google cloud document to configure a shared VPC</a>.</p><p>My shared VPC setup is shown in the below screenshots,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*y0q7x-6ewvrDV9qKjxIsfQ.png" /><figcaption>Projects resource hierarchy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*STvmP-E1BKTWw9C4zr6Mdg.png" /><figcaption>Shared VPC subnets in the istio-host-project</figcaption></figure><p>As you can see in the above screenshot, I’ve also configured the secondary IP ranges to use for Kubernetes pods and services in both the subnets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tfv7CwxM0jQ1C60JGaDGyw.png" /><figcaption>Shared VPC configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e1xCov6I9K5j5gZvdZSSEQ.png" /><figcaption>Projects to which the VPC subnets are shared</figcaption></figure><p>As our cluster nodes will be private, we’ll need a NAT gateway in each region for outbound connectivity and to pull our test application images. (Istio deployment uses container images stored in Google container registry, hence if private Google access is enabled on the subnets, Istio will be deployed without the need of a NAT gateway).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAHXeYAZQbmR3uobIqtT8w.png" /><figcaption>NAT gateways in us-central1 and us-east1</figcaption></figure><p><strong>Configure GKE clusters</strong></p><p>Once we have project and shared VPC subnets ready, we can configure GKE clusters (alpha-cluster in istio-alpha-project and beta-cluster in istio-beta-project). You can use the following gcloud commands, after replacing the project ID and resource names corresponding to your setup, to configure GKE clusters.</p><pre># alpha-cluster<br>gcloud beta container --project &quot;istio-alpha-project&quot; clusters create &quot;alpha-cluster&quot; --zone &quot;us-central1-a&quot; --no-enable-basic-auth --cluster-version &quot;1.21.14-gke.14600&quot; --release-channel &quot;None&quot; --machine-type &quot;e2-custom-4-8192&quot; --image-type &quot;COS_CONTAINERD&quot; --disk-type &quot;pd-standard&quot; --disk-size &quot;10&quot; --metadata disable-legacy-endpoints=true --scopes &quot;https://www.googleapis.com/auth/devstorage.read_only&quot;,&quot;https://www.googleapis.com/auth/logging.write&quot;,&quot;https://www.googleapis.com/auth/monitoring&quot;,&quot;https://www.googleapis.com/auth/servicecontrol&quot;,&quot;https://www.googleapis.com/auth/service.management.readonly&quot;,&quot;https://www.googleapis.com/auth/trace.append&quot; --max-pods-per-node &quot;64&quot; --num-nodes &quot;1&quot; --logging=SYSTEM,WORKLOAD --monitoring=SYSTEM --enable-private-nodes --master-ipv4-cidr &quot;172.16.0.0/28&quot; --enable-master-global-access --enable-ip-alias --network &quot;projects/istio-host-project/global/networks/host-vpc&quot; --subnetwork &quot;projects/istio-host-project/regions/us-central1/subnetworks/us-central1&quot; --cluster-secondary-range-name &quot;alpha-cluster-pods-range&quot; --services-secondary-range-name &quot;alpha-cluster-services-range&quot; --no-enable-intra-node-visibility --default-max-pods-per-node &quot;64&quot; --no-enable-master-authorized-networks --addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver --no-enable-autoupgrade --enable-autorepair --max-surge-upgrade 1 --max-unavailable-upgrade 0 --autoscaling-profile optimize-utilization --enable-shielded-nodes --shielded-secure-boot --node-locations &quot;us-central1-a&quot;<br><br># beta-cluster<br>gcloud beta container --project &quot;istio-beta-project&quot; clusters create &quot;beta-cluster&quot; --zone &quot;us-east1-b&quot; --no-enable-basic-auth --cluster-version &quot;1.24.9-gke.2000&quot; --release-channel &quot;None&quot; --machine-type &quot;e2-custom-4-8192&quot; --image-type &quot;COS_CONTAINERD&quot; --disk-type &quot;pd-balanced&quot; --disk-size &quot;10&quot; --metadata disable-legacy-endpoints=true --scopes &quot;https://www.googleapis.com/auth/devstorage.read_only&quot;,&quot;https://www.googleapis.com/auth/logging.write&quot;,&quot;https://www.googleapis.com/auth/monitoring&quot;,&quot;https://www.googleapis.com/auth/servicecontrol&quot;,&quot;https://www.googleapis.com/auth/service.management.readonly&quot;,&quot;https://www.googleapis.com/auth/trace.append&quot; --max-pods-per-node &quot;64&quot; --num-nodes &quot;1&quot; --logging=SYSTEM,WORKLOAD --monitoring=SYSTEM --enable-private-nodes --master-ipv4-cidr &quot;172.16.2.0/28&quot; --enable-master-global-access --enable-ip-alias --network &quot;projects/istio-host-project/global/networks/host-vpc&quot; --subnetwork &quot;projects/istio-host-project/regions/us-east1/subnetworks/us-east1&quot; --cluster-secondary-range-name &quot;beta-cluster-pods-range&quot; --services-secondary-range-name &quot;beta-cluster-services-range&quot; --no-enable-intra-node-visibility --default-max-pods-per-node &quot;64&quot; --no-enable-master-authorized-networks --addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver --no-enable-autoupgrade --enable-autorepair --max-surge-upgrade 1 --max-unavailable-upgrade 0 --autoscaling-profile optimize-utilization --enable-shielded-nodes --shielded-secure-boot --node-locations &quot;us-east1-b&quot;</pre><p>Note — I am configuring zonal clusters, but you can configure regional clusters as well.</p><p>Once, GKE clusters are created, configure kubectl contexts and export to env variables.</p><pre># alpha cluster<br>gcloud container clusters get-credentials alpha-cluster --zone us-central1-a --project istio-alpha-project<br>export CTX_CLUSTER1=$(kubectl config current-context)<br><br># beta cluster<br>gcloud container clusters get-credentials beta-cluster --zone us-east1-b --project istio-beta-project<br>export CTX_CLUSTER2=$(kubectl config current-context)</pre><p>Once clusters are configured, we’ll need to configure firewall rules in the shared VPC in the istio-host-project to allow multi-cluster pods and Istio communication.</p><pre># fetch alpha-cluster master firewall rule <br>gcloud compute firewall-rules list --filter=&quot;name~gke-alpha-cluster-[0-9a-z]*-master&quot; --project istio-host-project<br><br># replace firewall rule name obtained from the above command in below command<br>gcloud compute firewall-rules update &lt;firewall-rule-name&gt; --allow tcp:10250,tcp:443,tcp:15017 --project istio-host-project<br><br># fetch beta-cluster master firewall rule <br>gcloud compute firewall-rules list --filter=&quot;name~gke-beta-cluster-[0-9a-z]*-master&quot; --project istio-host-project<br><br># replace firewall rule name obtained from the above command in below command<br>gcloud compute firewall-rules update &lt;firewall-rule-name&gt; --allow tcp:10250,tcp:443,tcp:15017 --project istio-host-project<br><br># create a firewall rule to allow inter-cluster pods communication for multi-cluster setup<br>ALL_CLUSTER_CIDRS=&quot;$(gcloud container clusters list --project istio-alpha-project --format=&#39;value(clusterIpv4Cidr)&#39; | sort | uniq),$(gcloud container clusters list --project istio-beta-project --format=&#39;value(clusterIpv4Cidr)&#39; | sort | uniq)&quot;<br>ALL_CLUSTER_NETTAGS=&quot;$(gcloud compute instances list --project istio-alpha-project --format=&#39;value(tags.items.[0])&#39; | sort | uniq),$(gcloud compute instances list --project istio-beta-project --format=&#39;value(tags.items.[0])&#39; | sort | uniq)&quot;<br><br>gcloud compute firewall-rules create istio-multicluster-pods \<br>    --allow=tcp,udp,icmp,esp,ah,sctp \<br>    --direction=INGRESS \<br>    --network=host-vpc \<br>    --priority=900 \<br>    --source-ranges=&quot;${ALL_CLUSTER_CIDRS}&quot; \<br>    --target-tags=&quot;${ALL_CLUSTER_NETTAGS}&quot; \<br>    --project istio-host-project --quiet</pre><h3><strong>Istio Configuration</strong></h3><p><strong>Configure trust between the GKE clusters</strong></p><p>In order for the multi-primary Istio setup to communicate, we must setup trust between the GKE clusters. This requires that the workload certificates of all the clusters must be signed using the same Istio root certificate. In our tutorial we’ll use self-signed Istio root certificate to sign intermediate certificates for all the clusters. For production deployment it is recommended to use a production-ready CA and manage root CA in a more secured manner.</p><p>In order to generate root CA certs, clone official Istio repository.</p><pre># clone the official repo<br>git clone https://github.com/istio/istio.git<br><br># generate root CA<br>cd istio<br>mkdir certs<br>cd certs<br>make -f ../tools/certs/Makefile.selfsigned.mk root-ca<br><br># generate intermediate certs for each cluster<br>## alpha cluster<br>make -f ../tools/certs/Makefile.selfsigned.mk alpha-cluster-cacerts<br>## beta cluster<br>make -f ../tools/certs/Makefile.selfsigned.mk beta-cluster-cacerts</pre><p>Now, you’ll have intermediate certs for all the clusters as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*W4xp4sn_ww8m1MOanw0L2Q.png" /><figcaption>Istio root and intermediate certificates</figcaption></figure><p>We’ll now upload the certs to the respective clusters as Kubernetes secrets.</p><pre># create istio-system namespace<br>kubectl create namespace istio-system --context=$CTX_CLUSTER1<br>kubectl create namespace istio-system --context=$CTX_CLUSTER2<br><br># create secrets from the certs<br>## alpha-cluster<br>kubectl create secret generic cacerts -n istio-system \<br>      --from-file=alpha-cluster/ca-cert.pem \<br>      --from-file=alpha-cluster/ca-key.pem \<br>      --from-file=alpha-cluster/root-cert.pem \<br>      --from-file=alpha-cluster/cert-chain.pem \<br>      --context=$CTX_CLUSTER1<br>## beta-cluster<br>kubectl create secret generic cacerts -n istio-system \<br>      --from-file=beta-cluster/ca-cert.pem \<br>      --from-file=beta-cluster/ca-key.pem \<br>      --from-file=beta-cluster/root-cert.pem \<br>      --from-file=beta-cluster/cert-chain.pem \<br>      --context=$CTX_CLUSTER2<br><br># go back to the main directory<br>cd ../..</pre><p><strong>Install Istio on the clusters</strong></p><p>Now, we’ll install Istio on both the clusters using istioctl. As mentioned above, we are going to install different versions of Istio on both the clusters. Hence, we’ll download two versions of istioctl (1.15.0 and 1.16.1).</p><ul><li><strong>Install Istio on alpha-cluster</strong></li></ul><pre># download istioctl 1.15.0<br>mkdir alpha_cluster<br>cd alpha_cluster<br>curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.15.0 TARGET_ARCH=x86_64 sh -<br>chmod +x istio-1.15.0/bin/istioctl</pre><p>As we need multi-primary setup, we’ll override some of the values in istioctl default profile. The new values must be specified in a yaml file which needs to be passed in istioctl install command. The two changes are — instead of istio-system we’ll install Istio ingress controller in istio-ingress namespace and enable multi-cluster setup.</p><pre># create istio operator values override manifest<br>cat &lt;&lt;EOF &gt; istio_operator_values.yaml<br>apiVersion: install.istio.io/v1alpha1<br>kind: IstioOperator<br>spec:<br>  components:<br>    ingressGateways:<br>    - enabled: true<br>      name: istio-ingressgateway<br>      namespace: istio-ingress<br>  values:<br>    global:<br>      meshID: mesh1<br>      multiCluster:<br>        enabled: true<br>        clusterName: alpha-cluster<br>      network: host-vpc<br>EOF<br><br># create istio-ingress namespace<br>kubectl create namespace istio-ingress --context=$CTX_CLUSTER1<br><br># install istio on alpha-cluster with the values override<br>istio-1.15.0/bin/istioctl install --context=$CTX_CLUSTER1 -f istio_operator_values.yaml<br><br># go back to the main directory<br>cd ..</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVP-_7RHDKSLydidPFe8iA.png" /><figcaption>Istio controller and ingress controller deployments in alpha-cluster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0C79pP81ApZlJBdJoIO7UA.png" /><figcaption>Istio services in alpha-cluster</figcaption></figure><ul><li><strong>Install Istio on beta-cluster</strong></li></ul><p>Now, in a similar way we’ll install Istio on the beta-cluster.</p><pre># download istioctl 1.16.1<br>mkdir beta_cluster<br>cd beta_cluster<br>curl -L https://istio.io/downloadIstio | ISTIO_VERSION=1.16.1 TARGET_ARCH=x86_64 sh -<br>chmod +x istio-1.16.1/bin/istioctl</pre><pre># create istio operator values override manifest<br>cat &lt;&lt;EOF &gt; istio_operator_values.yaml<br>apiVersion: install.istio.io/v1alpha1<br>kind: IstioOperator<br>spec:<br>  components:<br>    ingressGateways:<br>    - enabled: true<br>      name: istio-ingressgateway<br>      namespace: istio-ingress<br>  values:<br>    global:<br>      meshID: mesh1<br>      multiCluster:<br>        enabled: true<br>        clusterName: beta-cluster<br>      network: host-vpc<br>EOF<br><br># create istio-ingress namespace<br>kubectl create namespace istio-ingress --context=$CTX_CLUSTER2<br><br># install istio on alpha-cluster with the values override<br>istio-1.16.1/bin/istioctl install --context=$CTX_CLUSTER2 -f istio_operator_values.yaml<br><br># go back to the main directory<br>cd ..</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hUtdHCDk8_6m1mmFfo58-g.png" /><figcaption>Istio controller and ingress controller deployments in alpha-cluster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rjMrPM1aTgvf4s5EJd7OpA.png" /><figcaption>Istio services in alpha-cluster</figcaption></figure><p><strong>Configure remote secret</strong></p><p>Next step is to configure remote secret on both the clusters. The secret consist of Kubernetes control plane IP, cluster certificate and credentials/token, of all the remote clusters. This allows Istio in one cluster to communicate to the resources deployed on all other clusters in multi-primary configuration.</p><pre># create beta-cluster remote secret on the alpha-cluster<br>cd alpha_cluster<br>export CLUSTER2_IP=https://$(gcloud container clusters describe beta-cluster --zone=us-east1-b --project=istio-beta-project --format=&#39;get(privateClusterConfig.privateEndpoint)&#39;)<br>istio-1.15.0/bin/istioctl x create-remote-secret \<br>    --context=$CTX_CLUSTER2 \<br>    --server=$CLUSTER2_IP \<br>    --name=beta-cluster | \<br>    kubectl apply -f - --context=$CTX_CLUSTER1<br><br># go back to main directory<br>cd ..<br><br># create alpha-cluster remote secret on the beta-cluster<br>cd alpha_cluster<br>export CLUSTER1_IP=https://$(gcloud container clusters describe alpha-cluster --zone=us-central1-a --project=istio-alpha-project --format=&#39;get(privateClusterConfig.privateEndpoint)&#39;)<br>istio-1.16.1/bin/istioctl x create-remote-secret \<br>    --context=$CTX_CLUSTER1 \<br>    --server=$CLUSTER1_IP \<br>    --name=alpha-cluster | \<br>    kubectl apply -f - --context=$CTX_CLUSTER2</pre><p>Finally, our muli-primary Istio setup is configured and both the clusters are now sharing a common service mesh.</p><h3>Test Application</h3><p>Now, we can deploy a simple helloworld application to test inter-cluster serivce mesh traffic management. The application is simple as shown in the above architecture diagram; alpha-cluster is hosting helloword-v1 deployment and beta-cluster is hosting helloworld-v2 deployment and both the clusters are having two Kubernetes services, each pointing to one of the deployments. Each cluster is having an Istio gateway and an Istio virtual service routing traffic to both the Kubernetes services with 50–50 weight. Ideally, even though both the deployments are residing in different clusters, the traffic from Istio ingress of any cluster should be routed to both the deployments with 50–50 weight.</p><p>As we are going to test HTTPS, we’ll need to configure an SSL certificate. We can generate a self-signed certificate or you can also use already generated SSL certificate for your domain. I’ll assume that you already have/generated an SSL certificate.</p><p>Let’s create a TLS certificate secret (in the same namespace where Istio ingress controller resides).</p><pre># create certificate secret on alpha-cluster in istio-ingress namespace<br>sudo kubectl create secret tls wildcard-cert -n istio-ingress --key privkey.pem --cert fullchain.pem --context $CTX_CLUSTER1<br><br># create certificate secret on beta-cluster in istio-ingress namespace<br>sudo kubectl create secret tls wildcard-cert -n istio-ingress --key privkey.pem --cert fullchain.pem --context $CTX_CLUSTER2</pre><p>Now, we’ll deploy <a href="https://github.com/scienceto/blog-content/blob/main/istio-multi-cluster/sample/alpha_helloworld.yaml">alpha_helloworld.yaml</a> and <a href="https://github.com/scienceto/blog-content/blob/main/istio-multi-cluster/sample/beta_helloworld.yaml">beta_helloworld.yaml</a> manifests on the alpha-cluster and beta-cluster respectively. The manifests contain deployment, services, virtual services and gateway definitions.</p><pre># deploy alpha_helloworld.yaml on the alpha-cluster in default namespace<br>kubectl apply -f https://raw.githubusercontent.com/scienceto/blog-content/main/istio-multi-cluster/sample/alpha_helloworld.yaml -n default --context=$CTX_CLUSTER1<br><br># deploy beta_helloworld.yaml on the beta-cluster in default namespace<br>kubectl apply -f https://raw.githubusercontent.com/scienceto/blog-content/main/istio-multi-cluster/sample/beta_helloworld.yaml -n default --context=$CTX_CLUSTER2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u6-0-mazmpTy5KvBOZBhoQ.png" /><figcaption>helloworld-v1 deployment in alpha-cluster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xhnfWcrci-kjdW32kIlySg.png" /><figcaption>helloworld-v1 and helloworld-v2 services in alpha-cluster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvZPQmoedlbAbw0BeMnFHg.png" /><figcaption>helloworld-v2 deployment in beta-cluster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WKLlfixvPLIv-Sn0bOzN7w.png" /><figcaption>helloworld-v1 and helloworld-v2 services in beta-cluster</figcaption></figure><p>Lastly, in order to access the helloworld application on 443 (HTTPS) we’ll need to allow traffic on 443 on all the cluster worker nodes hosting the application pods.</p><pre># create a firewall rule to allow traffic on 443<br>ALL_CLUSTER_NETTAGS=&quot;$(gcloud compute instances list --project istio-alpha-project --format=&#39;value(tags.items.[0])&#39; | sort | uniq),$(gcloud compute instances list --project istio-beta-project --format=&#39;value(tags.items.[0])&#39; | sort | uniq)&quot;<br><br>gcloud compute firewall-rules create istio-allow-443 \<br>    --allow=tcp:443 \<br>    --direction=INGRESS \<br>    --network=host-vpc \<br>    --priority=2000 \<br>    --source-ranges=&quot;0.0.0.0/0&quot; \<br>    --target-tags=&quot;${ALL_CLUSTER_NETTAGS}&quot; \<br>    --project istio-host-project --quiet</pre><p>Now, let’s hit the Istio ingress TCP load balancer endpoint and test if our application is working as expected. In my case,</p><ol><li><a href="https://35.226.165.83/hello">https://35.226.165.83/hello</a> — for alpha-cluster Istio ingress.</li><li><a href="https://35.237.227.103/hello">https://35.237.227.103/hello</a> — for beta-cluster Istio ingress.</li></ol><p>If we hit any endpoint multiple times, we’ll see the response coming from either v1 or v2 helloworld pods randomly with 50–50 chances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*m-JX67zu_eXLdsldVBkmzw.png" /><figcaption>Response coming from helloworld-v1 from alpha-cluster ingress</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*iMrCfYUyiU3QPYDjQ6jCLg.png" /><figcaption>Response coming from helloworld-v2 from alpha-cluster ingress</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*vfw6Maqi-tcPsnVaezu_OQ.png" /><figcaption>Response coming from helloworld-v2 from beta-cluster ingress</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*i9EXnXtvFzbz9YTThWmaVg.png" /><figcaption>Response coming from helloworld-v1 from beta-cluster ingress</figcaption></figure><p>Congratulations!! Our multi-cluster multi-primary Istio setup is working as expected.</p><p>If you liked this tutorial, you can check my next tutorial on <a href="https://medium.com/@pateljheel/using-google-cloud-global-http-s-load-balancer-with-istio-ingress-for-http-s-traffic-a46321c4302d">Using Google Cloud Global HTTP/S Load Balancer with Istio Ingress for HTTP/S traffic</a> which will help you to configure Google cloud global HTTP/S load balancer with Istio ingress controller.</p><h3>References</h3><ol><li><a href="https://istio.io/latest/docs/ops/deployment/deployment-models/#control-plane-models">Istio / Deployment Models</a></li><li><a href="https://istio.io/latest/docs/tasks/security/cert-management/plugin-ca-cert/">Istio / Plug in CA Certificates</a></li><li><a href="https://istio.io/latest/docs/setup/install/multicluster/multi-primary/">Istio / Install Multi-Primary</a></li><li><a href="https://cloud.google.com/vpc/docs/provisioning-shared-vpc">Provision Shared VPC | Google Cloud</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7793ca31d0b" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/multi-cluster-multi-primary-istio-setup-on-gke-clusters-deployed-in-separate-regions-in-a-shared-d7793ca31d0b">Multi-cluster Multi-primary Istio setup on GKE Clusters deployed in separate Regions in a Shared…</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Manage Google Cloud Monitoring Alerts at Searce]]></title>
            <link>https://blog.searce.com/how-we-manage-google-cloud-monitoring-alerts-at-searce-b74d30908dbd?source=rss-c98777c9e049------2</link>
            <guid isPermaLink="false">https://medium.com/p/b74d30908dbd</guid>
            <dc:creator><![CDATA[Jheel Patel]]></dc:creator>
            <pubDate>Mon, 12 Dec 2022 08:26:12 GMT</pubDate>
            <atom:updated>2022-12-12T08:26:12.107Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Observability of Cloud infrastructure and applications hosted on it is very crucial when it comes to Cloud Managed Services. Observability is the underlying component of Cloud reliability engineering and without it, you can’t define your SLIs (Service Level Indicators). Though observability allows you to define the SLIs, more importantly, observability of infrastructure and application is required to find and mitigate issues, which can range from small performance related issues to the critical issues which can cripple your entire system disrupting your services and hence leading to business loss.</p><p>In this blog, I’ve outlined some of the aspects of monitoring which we practice at <a href="http://searce.com/">Searce</a> for our customers’ Google cloud infrastructure (we also monitor their infrastructure on other Public Cloud providers mainly AWS and Azure) and how we preprocess the alerts before creating incidents in our ITSM tool to reduce noise of repetitive incident tickets generated from various monitoring tools which we support. Finally, a small tutorial is given on how to configure quota alerts on Google Cloud using MQL and terraform, which is one of the many alert policies which we configure for our customers proactively.</p><h3>Monitoring Google Cloud</h3><p>Google Cloud offers a service called Operations Suite which is basically a bundle of various services to monitor and log the infrastructure and applications hosted on Google Cloud/Other Clouds/On-premises. One of the services’ called Cloud Monitoring is used for monitoring and alerting Google Cloud infrastructure and resource metrics and you can also push your own custom application metrics to Google Cloud Monitoring.</p><p>We have certain predefined alert policies which we configure on our customer projects and we also provide custom alert policies based on customer specific requirements. Currently, we monitor more than 100&#39;s Google Cloud projects and manually configuring alert policies for each and every project is not practical. So, we maintain IaC for alert policies in terraform. Also we have prepared some standard terraform templates which we deploy on our newly onboarded customers. Some of the primary components which we monitor for our customers from infrastructure perspective also include but not limited to,</p><ol><li>VM instances</li><li>CloudSQL instances</li><li>Uptime checks and SSL certificates expiration</li><li>Google Kubernetes engine clusters and nodepools</li><li>Allocation and rate quotas</li><li>Network components such as NAT gateway, VPN tunnels, Load balancers, etc.</li><li>Audit logs</li><li>Serverless and analytics components</li></ol><p>Apart from these, we also help our customers monitor application level metrics and support other monitoring tools and services as well such as Prometheus, Datadog, Dynatrace, etc.</p><p>For all the alerts, the notification is sent to a webhook served by our application which is developed for preprocessing the alerts before generating incidents in our ITSM tool. This application is designed for our custom requirement and tested for reliability. The overall flow of alert payload is shown in the below architecture diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umM5nnFfCIBsLX2nFZMTvg.png" /><figcaption>Alert and incident payload flow</figcaption></figure><p>Monitoring alerts from various sources (Google Cloud monitoring, Grafana PMM, Site24x7, AWS Cloudwatch, etc.) are received on the webhook and processed by the incident processing function, which is hosted on Google Cloud function service. The event driven Cloud function receives the alert payload and parses it as per our requirements and checks for existing incident in our ITSM tool for the same alert. Based on the current status of the incident in the ITSM tool, the alert is further processed as per our business logic. The reason for using a preprocessing function to preprocess the alerts is to reduce or eliminate noise tickets or repetitive alerts before generating incident tickets in the ITSM tool. This allows our engineers to focus on actionable items by reducing manual task of merging/closing noise tickets. Also it allows alert payload to be parsed in a standard way for all the different monitoring sources.</p><p>You might argue the reliability of this solution by saying what if alert is generated from any monitoring source but the incident processing function misbehaves/crashes due to which incident is not created/updated in the ticketing (ITSM) tool? Your concern is justified, but there are few things I would like to highlight here. Firstly, our preprocessing function has been throughly tested on live alerts, before rolling out into production. Secondly, every alert processed by our internal application is logged into Google Cloud project at multiple levels, the application itself generate alerts on our internal email and slack channels on failures. All of this allows us, during processing failures, to process and when required monitor each and every alert received by our application.</p><h3><strong>Quota Alerts in Google Cloud</strong></h3><p>One important aspect in Google Cloud Monitoring which users tend to miss or neglect is project resource allocation and rate quota based alerts. Google Cloud implements quotas on Google Cloud projects which prevents users from over provisioning resources; this is a very important feature which save customers from surprise bills in case if your project is accessed by attackers. Once you reach your quota limit (for example, N1 cores in asia-south1 region) you cannot allocate more resources belonging to that quota and you need to raise a quota increase request for that resource in your project. This is applicable to rate quotas as well. Once you raise a quota increase request, it takes a day for it to get approved and later the quota limit is increased. Until the limit is increased you cannot provision resources belonging to that quota.</p><p>Note - Google Cloud automatically increases quota limits based on the resource usage trend in your project but many times you hit the limit due to sudden increase in workloads or while deploying new applications. Therefore, it is important to monitor your project quota limits and alert if quota utilization reaches certain threshold.</p><p>Now, in order to define alert policies, you require quota percentage utilization metrics. In Google Cloud, we have quota limit metrics and quota usage metrics, which are absolute value metrics and not percentage utilization metrics. In order to get the percentage utilization you need to divide the quota usage by its quota limit to get the percentage fraction (0 to 1.00). So, basically we are doing operation on two timeseries to get a single percentage utilization timeseries. As of now it is not possible to combine two timeseries from GUI in Google Cloud monitoring console, but you can do it using Monitoring Query Language (MQL) which is a text-based interface to Cloud Monitoring time-series data. So, let us now configure quota alert policies using MQL. We’ll configure two quota alert policies, one for resource allocation based quotas and another for rate based quotas, which will trigger alert when any of the quotas reach above 80% utilization. First I’ll show you how you can configure it using Google Cloud console then I’ll show a sample terraform code for the same policies.</p><p><strong>First, we’ll create rate based quota alert.</strong></p><ul><li>Go to Google Cloud monitoring alert policies console of your Google Cloud project and click on CREATE POLICY.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VrvzEnEHoc8heASYgncfjg.png" /></figure><ul><li>Then click on MQL on top right corner. It’ll open an MQL editor. Paste the following MQL query in the editor and click on RUN QUERY button to see the resulting time-series. Note, the value 0.8 in line no. 23 in below query is the fraction of rate quota utilization you want to set as alert threshold.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c594c17e5ce91f08819191a1e56c8023/href">https://medium.com/media/c594c17e5ce91f08819191a1e56c8023/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tLJvd375D4-VaZ7fX6BNiQ.png" /></figure><ul><li>Retest window can be set as per your requirement, generally it is set to 3–5 min to avoid spike alerts.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmBNoAXq7Y3O9yanmuB3Gg.png" /></figure><ul><li>Configure the notification channel and click on create policy after providing a policy name.</li></ul><p><strong>Similarly, create a new alert policy for resource allocation based quota utilization using the following MQL query.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bcc0554c062291e52f47ce07e877a4e/href">https://medium.com/media/6bcc0554c062291e52f47ce07e877a4e/href</a></iframe><p>Note, here also the value 0.8 in line no. 14 is the fraction of allocation quota utilization you want to set as alert threshold.</p><p>Using above steps you can configure alert policies for quotas using Google Cloud console, but you can also create the same policies using terraform. Following terraform scripts configure the same alert policies for the provided Google Cloud project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bacbfbfc03011078dbe5d80ab6e0db23/href">https://medium.com/media/bacbfbfc03011078dbe5d80ab6e0db23/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19ced73fd8e635c87021129678409548/href">https://medium.com/media/19ced73fd8e635c87021129678409548/href</a></iframe><p>Final note, here to keep the tutorial short, we have configured alert policies for only one threshold i.e. 80%. But generally, we configure at least two thresholds for TROUBLE and CRITICAL utilization for all the monitored metrics in our customer infrastructure.</p><p>Finally, I would like to thank Nikhil John for his review and suggestions on this blog.</p><p><strong>References</strong></p><ol><li><a href="https://cloud.google.com/monitoring/alerts/using-quota-metrics">Chart and monitor quota metrics | Cloud Monitoring | Google Cloud</a></li><li><a href="https://cloud.google.com/products/operations">Operations: Cloud Monitoring &amp; Logging | Google Cloud</a></li><li><a href="https://cloud.google.com/docs/quota">Working with quotas | Documentation | Google Cloud</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b74d30908dbd" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/how-we-manage-google-cloud-monitoring-alerts-at-searce-b74d30908dbd">How We Manage Google Cloud Monitoring Alerts at Searce</a> was originally published in <a href="https://blog.searce.com/">Searce</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>