<?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 Anvit Dave on Medium]]></title>
        <description><![CDATA[Stories by Anvit Dave on Medium]]></description>
        <link>https://medium.com/@anvit.dave?source=rss-dded9dbc2821------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*yg_pbp6I-icgLeYQ</url>
            <title>Stories by Anvit Dave on Medium</title>
            <link>https://medium.com/@anvit.dave?source=rss-dded9dbc2821------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 02:43:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anvit.dave/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[Overlapping IPs: A Seamless Solution with Private NAT on Google Cloud]]></title>
            <link>https://blog.searce.com/overlapping-ips-a-seamless-solution-with-private-nat-on-google-cloud-5f28fa3ddf5f?source=rss-dded9dbc2821------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f28fa3ddf5f</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[searce]]></category>
            <category><![CDATA[private-nat-gateway]]></category>
            <category><![CDATA[google-cloud-networking]]></category>
            <dc:creator><![CDATA[Anvit Dave]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 06:39:06 GMT</pubDate>
            <atom:updated>2024-09-23T06:39:06.098Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-GX3pjPo2uzjAkMy" /><figcaption>Photo by <a href="https://unsplash.com/@jouwdan?utm_source=medium&amp;utm_medium=referral">Jordan Harrison</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Network management is a crucial and intricate aspect of ensuring optimal application performance. One of the fundamental tasks in network management is IP address allocation. These IP addresses serve as the foundation for internal communication within a network.</p><p>When establishing a network connection, either between traditional on-premises networks or cloud platforms like Google Cloud Platform (GCP), it’s essential to avoid IP address overlap. This issue can arise when two networks share the same range of IP addresses.</p><p>IP address conflicts arise when identical IP addresses are assigned to multiple networks. This overlap causes communication disruptions.</p><p>While it’s generally recommended to avoid IP address overlap, there are specific scenarios where connecting two networks with overlapping ranges is necessary. In Google Cloud Platform (GCP), Private NAT can be utilized to facilitate communication between such networks.</p><p><strong>What is Private-VPC NAT?</strong></p><p>Private VPC NAT is a service within Google Cloud Platform (GCP) that allows for private-to-private network address translation (NAT) between Virtual Private Cloud (VPC) networks connected to a Network Connectivity Center hub. This includes NAT for traffic flowing between VPC spokes and between VPC spokes and hybrid spokes.</p><p>Direct peering between networks with overlapping IP addresses is not permitted in Google Cloud Platform (GCP). Private VPC NAT serves as a gateway, facilitating communication between such networks.</p><p>Google Cloud Platform’s Private VPC NAT is integrated with Network Connectivity Center (NCC). NCC employs a hub-and-spoke model for network connectivity. A hub serves as a central connection point for your Virtual Private Cloud (VPC) networks.</p><p><strong>Reference Architecture</strong></p><p>In the following network architecture digram, VPC A and VPC B each contain a subnet with overlapping IP address ranges. Additionally, VPC B has a separate non-overlapping subnet.</p><figure><img alt="https://cloud.google.com/static/nat/images/inter-vpc-nat-flow.png" src="https://cdn-images-1.medium.com/max/1024/1*avba5iajBJmynz0e1XGyUw.png" /><figcaption><a href="https://cloud.google.com/static/nat/images/inter-vpc-nat-flow.png">https://cloud.google.com/static/nat/images/inter-vpc-nat-flow.png</a></figcaption></figure><p>A Private VPC NAT gateway will be deployed in VPC A, enabling instances within the overlapping subnet to connect to the VMs in the non-overlapping subnet of VPC B.</p><h3><strong>Network and Infrastructure setup</strong></h3><p>Step 1: Environment variable setup.</p><pre>export PROJECT_ID=&quot;project-id&quot;<br>export REGION=&quot;asia-south1&quot;</pre><p>Step 2: Create VPC networks and subnets.</p><pre>#vpc-a network<br>gcloud compute networks create vpc-a \<br>    --subnet-mode=custom <br>#subnet in vpc-a (overlapping subnet in vpc-a)<br>gcloud compute networks subnets create subnet-a \<br>    --network=&quot;vpc-a&quot; \<br>    --purpose=&quot;PRIVATE&quot; \<br>    --role=&quot;ACTIVE&quot; \<br>    --range=&quot;192.168.1.0/24&quot; \<br>    --region=$REGION<br><br>#vpc-b network<br>gcloud compute networks create vpc-b \<br>    --subnet-mode=custom<br>#subnet in vpc-b (non-overlapping subnet-b in vpc-b)<br>gcloud compute networks subnets create subnet-b \<br>    --network=&quot;vpc-b&quot; \<br>    --purpose=&quot;PRIVATE&quot; \<br>    --role=&quot;ACTIVE&quot; \<br>    --range=&quot;192.168.2.0/24&quot; \<br>    --region=$REGION<br>#subnet in vpc-b (non-overlapping subnet-c in vpc-b)<br>gcloud compute networks subnets create subnet-c \<br>    --network=&quot;vpc-b&quot; \<br>    --purpose=&quot;PRIVATE&quot; \<br>    --role=&quot;ACTIVE&quot; \<br>    --range=&quot;192.168.1.0/24&quot; \<br>    --region=$REGION</pre><p>Step 3: Create Compute Engine instances.</p><pre>#VM in vpc-a and subnet-a<br>gcloud compute instances create vpc-a-vm-a \<br>  --project=$PROJECT_ID \<br>  --zone=&quot;asia-south1-a&quot; \<br>  --machine-type=e2-medium \<br>  --network-interface=stack-type=IPV4_ONLY,subnet=subnet-a,no-address \<br>  --create-disk=auto-delete=yes,boot=yes,device-name=vpc-a-vm-a,image=projects/debian-cloud/global/images/debian-11-bullseye-v20230814,mode=rw,size=10,type=projects/$PROJECT_ID/zones/asia-south1-a/diskTypes/pd-balanced<br><br>#VM in vpc-b and subnet-b<br>gcloud compute instances create vpc-b-vm-b \<br>  --project=$PROJECT_ID \<br>  --zone=&quot;asia-south1-a&quot; \<br>  --machine-type=e2-medium \<br>  --network-interface=stack-type=IPV4_ONLY,subnet=subnet-b,no-address \<br>  --create-disk=auto-delete=yes,boot=yes,device-name=vpc-b-vm-b,image=projects/debian-cloud/global/images/debian-11-bullseye-v20230814,mode=rw,size=10,type=projects/$PROJECT_ID/zones/asia-south1-a/diskTypes/pd-balanced<br><br>#VM in vpc-b and subnet-c<br>gcloud compute instances create vpc-b-vm-c \<br>  --project=$PROJECT_ID \<br>  --zone=&quot;asia-south1-a&quot; \<br>  --machine-type=e2-medium \<br>  --network-interface=stack-type=IPV4_ONLY,subnet=subnet-c,no-address \<br>  --create-disk=auto-delete=yes,boot=yes,device-name=vpc-b-vm-c,image=projects/debian-cloud/global/images/debian-11-bullseye-v20230814,mode=rw,size=10,type=projects/$PROJECT_ID/zones/asia-south1-a/diskTypes/pd-balanced</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n4C2zKWPsPb4EYqjDUSWAg.png" /></figure><p>As per current configuration, the vpc-a-vm-a instance in vpc-a cannot access the service running on the vpc-b-vm-b instance due to a lack of network connectivity. Given the overlapping subnets, VPC peering cannot be established directly between the two networks</p><p><strong>Setup Network Connectivity Center<br></strong>To establish communication between two VPC networks with overlapping subnet IP ranges, configure both networks as VPC spokes connected to a shared Network Connectivity Center hub.</p><p>Step 4: Create a network connectivity center hub.</p><pre>gcloud network-connectivity hubs create pvt-nat-vpc-hub</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9UxS4jhsJi2lFEYLwkte6w.png" /><figcaption>Hub Configuration</figcaption></figure><p>Step 5: Connect the VPC networks as spokes to the Network Connectivity Center hub. Ensure that the overlapping subnets are not included in the export configuration.</p><pre>#Add vpc-a to the hub and exclue vpc-a subnet-a from export.<br>gcloud network-connectivity spokes linked-vpc-network create vpc-a \<br>  --hub=&quot;https://www.googleapis.com/networkconnectivity/v1/projects/$PROJECT_ID/locations/global/hubs/pvt-nat-vpc-hub&quot; --global \<br>  --vpc-network=&quot;https://www.googleapis.com/compute/v1/projects/$PROJECT_ID/global/networks/vpc-a&quot; \<br>  --exclude-export-ranges=&quot;192.168.1.0/24&quot;<br><br>#Add vpc-b to the hub and exclue vpc-b and subnet-c from export vpc-b and subnet-b will be exported between the VPCs.<br>gcloud network-connectivity spokes linked-vpc-network create vpc-b \<br>  --hub=&quot;https://www.googleapis.com/networkconnectivity/v1/projects/$PROJECT_ID/locations/global/hubs/pvt-nat-vpc-hub&quot; --global \<br>  --vpc-network=&quot;https://www.googleapis.com/compute/v1/projects/$PROJECT_ID/global/networks/vpc-b&quot; \<br>  --exclude-export-ranges=&quot;192.168.1.0/24&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2i8v7k_SE6i5xljAJIWaYg.png" /><figcaption>Spokes Configuration</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8iwEvcSOFVDS-ASaITeoA.png" /><figcaption>Routes exchange</figcaption></figure><h3><strong>Setup Private-VPC NAT</strong></h3><p>A Private VPC NAT gateway requires a dedicated subnet specifically designated for private network address translation (PRIVATE_NAT). The gateway utilizes IP addresses from this subnet to perform NAT. It’s crucial that this subnet does not overlap with any existing subnet in VPC spokes attached to the same Network Connectivity Center hub. This subnet is exclusively used for Private VPC NAT purposes.</p><p>Step 6: Create a subnet for private NAT.</p><p>The Private VPC NAT gateway will be deployed in VPC A, as it needs to facilitate access to the service running in VPC B. Please note that Private VPC NAT primarily performs outbound network address translation.</p><pre><br>#subnet for private-NAT in vpc-a<br>gcloud compute networks subnets create pvt-nat-gw-subnet \<br>    --network=&quot;vpc-a&quot; \<br>    --range=&quot;10.1.2.0/29&quot; \<br>    --region=$REGION \<br>    --purpose=PRIVATE_NAT</pre><p>Step 7: Create a cloud router and private NAT gateway.</p><pre>#cloud router for private-NAT<br>gcloud compute routers create vpc-a-pvt-nat-gw-router \<br> --network=&quot;vpc-a&quot; \<br> --region=$REGION<br><br>#private-NAT<br>gcloud compute routers nats create vpc-a-pvt-nat-gw \<br>  --router=vpc-a-pvt-nat-gw-router \<br>  --type=PRIVATE \<br>  --region=$REGION \<br>  --nat-all-subnet-ip-ranges</pre><p>Step 8: Within the Private VPC NAT gateway, establish a NAT rule that will perform network address translation on outbound traffic originating from the source VPC spoke and destined for any peer VPC spokes connected to the corresponding Network Connectivity Center hub. As per the NAT rule, the Private VPC NAT gateway will assign NAT IP addresses from the dedicated Private NAT subnet to the outgoing traffic.</p><pre>gcloud beta compute routers nats rules create 1000 \<br>  --router=vpc-a-pvt-nat-gw-router \<br>  --nat=vpc-a-pvt-nat-gw \<br>  --match=&#39;nexthop.hub == &quot;//networkconnectivity.googleapis.com/projects/$PROJECT_ID/locations/global/hubs/pvt-nat-vpc-hub&quot;&#39; \<br>  --source-nat-active-ranges=pvt-nat-gw-subnet \<br>  --region=$REGION</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rW9bbxvzC0km3QqOwknAJg.png" /></figure><p>Step 9: Verify network connectivity between VPC A and VPC B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*S4j6cqSX-SlT4EbuClYEsQ.png" /></figure><p>Based on the screenshot, we can validate that the instance in VPC A is able to access the service running in the non-overlapping subnet of VPC B through the Private VPC NAT gateway.</p><blockquote><strong>Ensure firewall rules allows cross vpc communications</strong></blockquote><h3>Conclusion</h3><p>Private VPC NAT is a valuable tool in Google Cloud Platform (GCP) that simplifies communication between Virtual Private Cloud (VPC) networks with overlapping IP address ranges. By leveraging Private VPC NAT, you can ensure that resources within overlapping subnets can securely interact with those in non-overlapping subnets of other VPCs.</p><p>If you have any questions, I’ll be happy to read them in the comment section. Feel free to reach out on <a href="https://twitter.com/daveanvit">@daveanvit</a>.</p><p><em>Thanks for reading, Happy Clouding</em>☁️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f28fa3ddf5f" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/overlapping-ips-a-seamless-solution-with-private-nat-on-google-cloud-5f28fa3ddf5f">Overlapping IPs: A Seamless Solution with Private NAT on Google Cloud</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[Micro-service specific build in MonoRepo -Google Cloud Build]]></title>
            <link>https://blog.searce.com/micro-service-specific-build-in-monorepo-google-cloud-build-3c1be8edf4c?source=rss-dded9dbc2821------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c1be8edf4c</guid>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[monorepo]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[google-cloud]]></category>
            <dc:creator><![CDATA[Anvit Dave]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 05:33:34 GMT</pubDate>
            <atom:updated>2022-11-01T05:33:34.858Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qiguKm1ImjnV0U5J" /><figcaption>Photo by <a href="https://unsplash.com/@xavi_cabrera?utm_source=medium&amp;utm_medium=referral">Xavi Cabrera</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently, we came across a requirement where a customer was having 1 repository for 51 micro-services, they wanted to use cloud-build for building and deploying their micro-services to Google Kubernetes Engine. As there were 51 micro-services for each of their micro-service, they wanted to build and deploy only a specific micro-service for which the code changes are committed.</p><p>To achieve the above requirement, there are 3 solutions proposed in the following blog,</p><ol><li>Tag based builds</li><li>Commit message based builds</li><li>Include/Ignored files based builds</li></ol><p>We will walk through over Tag based builds and Commit message based builds, but we will implement Include/Ignored files based builds.</p><p><strong>Tag based builds:</strong></p><p>For tag based approach we have to create cloud build trigger which invokes build on given git-tag, for instance we will configure 2 cloud-build trigger for 2 applications on tag <strong>app1_dev_* </strong>and <strong>app2_dev_*</strong>. It will invoke build when we tag a repository, like <strong>app1_dev_v1.1</strong>.</p><p><strong>Commit message based builds:</strong></p><p>For the commit message base approach, we have to create 1 cloud-build trigger for all applications, and we have to reserve keywords for each micro-services to uniquely identify that micro-service.</p><p><strong>Drawbacks of tag and commit message based approach:</strong></p><p>Above-mentioned approaches keep room for error from the developer while tagging or passing wrong commit messages during pushing to the repository, furthermore tags and commit messages need to be communicated to each developer in the team.</p><p>Moreover, from above mentioned approaches to deploy on different stages would require an additional effort of creating tags for different branches, and re-committing same code with commit messages for other stage ex. dev/stage/prod.</p><p>The next question is, are there any alternatives by which with minimal code changes and no scope for error we can use Cloud Build? Can the build be executed only for those services for which the code changes are made?</p><p>The answer is yes, We can achieve this in cloud-build by using <strong>Included/Ignored files filters.</strong></p><p><strong>Include/Ignored files based builds:</strong></p><p>In include/ignored files based builds, we will include and ignore directories for separate micro-service.</p><p><strong>What is include and ignore files ?</strong></p><p><strong>Included files : </strong>Changes affecting at least one of these files/directories will invoke build.</p><p><strong>​​Ignored files: </strong>Changes to specific files/directories will be ignored, and it will not invoke build.</p><p>Included files and Ignored files can be specified when the trigger event is <strong>Push to a branch</strong>, <strong>Push new tag</strong> or <strong>Pull request</strong>.</p><p>Below, is the repository structure, where each micro-services are having separate cloudbuild.yaml, k8s manifest files and other application code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*bcWik-nZ102lsLUTrPVGRg.png" /><figcaption>repository structure</figcaption></figure><blockquote><em>Note:- If we want to change the repository structure, where all the manifests and cloudbuild files are in separate directory rather than in the same directory as the application code, for that we have to update cloud build configuration accordingly.</em></blockquote><p>Below is the cloudbuild file contains code for building image, pushing image to gcr and deploying to GKE.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/32f40131c52a8557f1cfb88a92a13a3b/href">https://medium.com/media/32f40131c52a8557f1cfb88a92a13a3b/href</a></iframe><p>Below is a terraform resource file for creating 3 cloud-build triggers , with <strong>ignored_files</strong> and <strong>included_files </strong>configurations<strong> .</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a862e0eed04380ad6c3e1c2f6582764/href">https://medium.com/media/4a862e0eed04380ad6c3e1c2f6582764/href</a></iframe><p>Below is the terraform.tfvars file where we have defined variables for cloud-build.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f42897ea82dcd65ab4689ac1fc1e3b3e/href">https://medium.com/media/f42897ea82dcd65ab4689ac1fc1e3b3e/href</a></iframe><p>This terraform.tfvars file contains the name of cloudbuild triggers, path of kubernetes manifest files , and included_files and ignored_files values for each of the triggers.</p><blockquote><strong>Note:- Create variable and provider terraform files/blocks in terraforrm.</strong></blockquote><p>Below is an image of cloudbuild configuration created from terraform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jHcU8hJxEmN14E8zsRcsDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWf0gPH3OV6zXRHwrf6Vmg.png" /></figure><pre><strong>Caution<br></strong><em>- If the file is specified in both included files and ignored files, changes to that file will not invoke a build.Ignored files takes precedence than included files.</em></pre><pre><em>- We can do parallel builds from above mentioned approach.</em></pre><pre><em>- If files or directory inside included files are modified only that particular trigger will get invoked, not all will be executed.</em></pre><pre><em>- This solution is best suited for legacy based code bases where there are no frequent modifications in repository structure.</em></pre><p><strong>Conclusion</strong></p><p>Google Cloudbuild is a cost effective and powerful server-less service for building, testing and deploying applications. Cloudbuild include file, ignore file provides a way to build individual micro-service from a single repository which contains set of micro-services with minimal modifications in the repository.</p><p>If you have any questions, I’ll be happy to read them in the comment section. Feel free to reach out on <a href="https://twitter.com/daveanvit">@daveanvit</a>.</p><p><em>Thanks for reading, Happy Clouding</em>☁️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c1be8edf4c" width="1" height="1" alt=""><hr><p><a href="https://blog.searce.com/micro-service-specific-build-in-monorepo-google-cloud-build-3c1be8edf4c">Micro-service specific build in MonoRepo -Google Cloud Build</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>