<?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 Abhijit Bildikar on Medium]]></title>
        <description><![CDATA[Stories by Abhijit Bildikar on Medium]]></description>
        <link>https://medium.com/@abildikar_gke?source=rss-f3824d1f0f50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_SOKToUQjYLTghKt.jpg</url>
            <title>Stories by Abhijit Bildikar on Medium</title>
            <link>https://medium.com/@abildikar_gke?source=rss-f3824d1f0f50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 03:34:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abildikar_gke/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[Adding GCP Managed Instance Group[MIG] as backend to GKE Ingress]]></title>
            <link>https://medium.com/@abildikar_gke/adding-gcp-managed-instance-group-mig-as-backend-to-gke-ingress-99d9a0374458?source=rss-f3824d1f0f50------2</link>
            <guid isPermaLink="false">https://medium.com/p/99d9a0374458</guid>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[mig]]></category>
            <category><![CDATA[ingress]]></category>
            <category><![CDATA[gke]]></category>
            <dc:creator><![CDATA[Abhijit Bildikar]]></dc:creator>
            <pubDate>Thu, 07 Jul 2022 06:07:23 GMT</pubDate>
            <atom:updated>2022-07-07T23:37:57.477Z</atom:updated>
            <content:encoded><![CDATA[<p>Few weeks ago I was approached by my customer asking for a solution to use a <a href="https://cloud.google.com/compute/docs/instance-groups">Managed instance group</a>[MIG] as an Backend to the <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/ingress">GKE Ingress</a> this is not doable in GKE because of the way GKE Networking works, I tried searching for a solution but found, there are bits and pieces of information all over the place, so decided to suggest a design on Google Cloud Platform. This example discussed below is not to be used as is for production systems this is just provide a <strong>proof of concept</strong> thorough hardening of the system components is required before deploying to production.</p><h3><strong>Architecture Diagram</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZbizfQKt2k2iiChTxnXC0w.png" /><figcaption>Architecture Diagram on the setup</figcaption></figure><p><strong>Setup explained</strong></p><p>I am using the following components in the sample architecture</p><ol><li>Region: us-west1</li><li>Zones: us-west1-a,us-west1-b,us-west1-c</li><li>Regional Private GKE cluster</li><li>GKE Ingress External HTTP(S) Load balancer</li><li>Internal Network Load balancer</li><li>Managed Instance Group</li></ol><h3><strong>Steps to create Managed Instance Group</strong></h3><h4>Before you begin</h4><ol><li>In the Google Cloud console, on the project selector page, select or <a href="https://cloud.google.com/resource-manager/docs/creating-managing-projects">create a Google Cloud project</a>.</li><li><strong>Note</strong>: If you don’t plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.</li><li>Make sure that billing is enabled for your Cloud project. Learn how to <a href="https://cloud.google.com/billing/docs/how-to/verify-billing-enabled">check if billing is enabled on a project</a>.</li><li>Enable the Compute Engine API.</li><li><a href="https://console.cloud.google.com/apis/api/compute.googleapis.com/overview">Enable the API</a></li></ol><h4>Create an instance template</h4><ol><li>In the Google Cloud console, go to the <strong>Instance templates</strong> page.</li><li>Click <strong>Create instance template</strong>.</li><li>To create a template that uses an Ubuntu OS, perform the following steps:</li><li>In the <strong>Boot disk</strong> section, click <strong>Change</strong>.</li><li>In the <strong>Operating system</strong> list, select <strong>Ubuntu</strong>.</li><li>Click <strong>Select</strong>.</li><li>Click on <strong>Management</strong></li><li>Under Automation add the following startup script</li></ol><pre>sudo apt update &amp;&amp; sudo apt -y install apache2<br>sudo systemctl status apache2<br>echo &#39;&lt;!doctype html&gt;&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello World! from MIG&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;&#39; | sudo tee /var/www/html/index.html</pre><p>9. To create the instance template, click <strong>Create</strong>.</p><p>Allow a few minutes for Compute Engine to create the template. When the template is ready, it’s listed on the <strong>Instance templates</strong> page.</p><p><strong>Create Firewall rule to allow http/s traffic</strong></p><ol><li>In the Google Cloud console, go to the <strong>Firewall rules</strong> page.</li><li>Look for a firewall rule that allows all IP ranges through tcp:80. Usually, this rule is named the default-allow-http rule.</li><li>If a rule does not exist, create one.</li><li>Click <strong>Create firewall rule</strong>.</li><li>Enter a name for the rule, such as default-allow-http.</li><li>Under <strong>Source IP ranges</strong>, enter 0.0.0.0/0 to allow traffic from all sources.</li><li>Under <strong>Protocols and ports</strong>, check <strong>Specified protocols and ports</strong> and enter tcp:80.</li><li>Create your firewall rule.</li></ol><h4>Create a MIG by using the instance template</h4><ol><li>Go to the <strong>Instance groups</strong> page.</li><li>Click <strong>Create instance group</strong>, and then perform the following steps:</li><li>In the <strong>Name</strong> field, accept the default name or enter webserver-instance-group-1.</li><li>In the <strong>Instance template</strong> list, select the instance template that you created earlier.</li><li>In the <strong>Location</strong> section, ensure that <strong>Single zone</strong> is selected.</li><li>In the <strong>Autoscaling</strong> section, accept the default settings unless you need to modify them.</li><li>To create the MIG, click <strong>Create</strong>.</li></ol><p>Allow a few minutes for Compute Engine to create the group and its VMs. After the group is ready, it’s listed on the <strong>Instance groups</strong> page.</p><h3><strong>Steps to create Internal Load balancer</strong></h3><p><strong>Create the load balancer and configure a backend service</strong></p><ol><li>In the Google Cloud console, go to the <strong>Load balancing</strong> page.</li><li>Click <strong>Create load balancer</strong>.</li><li>Under <strong>TCP load balancing</strong>, click <strong>Start configuration</strong>.</li><li>Under <strong>Internet facing or internal only</strong> select <strong>Only between my VMs</strong>.</li><li>Click <strong>Continue</strong>.</li><li>Set the <strong>Name</strong> to be-ilb.</li><li>Click <strong>Backend configuration</strong> and make the following changes:</li><li><strong>Region</strong>: us-west1</li><li><strong>Network</strong>: lb-network</li><li>Under <strong>Backends</strong>, in the <strong>New backends</strong> section, select the webserver-instance-group-1 instance group and click <strong>Done</strong>.</li><li>Under <strong>Health check</strong>, choose <strong>Create a health check</strong>, enter the following information, and click <strong>Save</strong>:</li></ol><ul><li><strong>Name</strong>: hc-http-80</li><li><strong>Protocol</strong>: HTTP</li><li><strong>Port</strong>: 80</li><li><strong>Proxy protocol</strong>: NONE</li><li><strong>Request path</strong>: /</li></ul><ol><li>Verify that there is a blue check mark next to <strong>Backend configuration</strong> before continuing. Review this step if not.</li><li>Click <strong>Frontend configuration</strong>. In the <strong>New Frontend IP and port</strong> section, make the following changes:</li><li><strong>Name</strong>: fr-ilb</li><li><strong>Subnetwork</strong>: Select the subnetwork where the MIG is running</li><li>From <strong>Internal IP</strong>, choose <strong>Create IP address</strong>, enter the following information, and click <strong>Reserve</strong>:</li></ol><ul><li><strong>Name</strong>: ip-ilb</li><li><strong>Static IP address</strong>: <em>Let me choose</em></li><li><strong>Custom IP address</strong>: 10.1.2.99</li></ul><p>6.<strong> Ports</strong>: Choose <strong>Multiple</strong>, and enter 80,8008,8080,8088 for the <strong>Port number</strong>.</p><p>7. Verify that there is a blue check mark next to <strong>Frontend configuration</strong> before continuing. Review this step if not.</p><p>8. Click <strong>Review and finalize</strong>. Check all your settings.</p><p>9. Click <strong>Create</strong>.</p><h3><strong>Steps for GKE</strong></h3><p>Steps for creating a regional cluster refer google cloud provided <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-regional-cluster">documentation</a>, In this cluster I have deployed a sample application steps for it are provided <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/stateless-apps#gcloud-config">here</a></p><p><strong>Creating an Ingress</strong></p><p>Here is the manifest for an ingress</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: demo-ingress<br>spec:<br>  rules:<br>        - http:<br>            paths:<br>              #path for the services<br>             - path: <strong>/v1</strong><br>               pathType: ImplementationSpecific<br>               backend:<br>                service:<br>                  name: <strong>hello-world-1</strong><br>                  port:<br>                    number: 60000<br>             - path: /v2<br>               pathType: ImplementationSpecific<br>               backend:<br>                  service:<br>                    name: <strong>nlb-service</strong><br>                    port:<br>                     number: 80</pre><p><strong>Creating a service and endpoint</strong></p><p>Here is the manifest for creating the service and its endpoint</p><pre>apiVersion: v1<br>kind: <strong>Service</strong><br>metadata:<br>  name: nlb-service<br>  #annotations is needed for legacy routes<br>  annotations:<br>    <strong>cloud.google.com/neg: &#39;{&quot;ingress&quot;: false}&#39;</strong><br>spec:<br>  #Node port is needed to route the traffic outside the cluster<br>  type: NodePort<br>  ports:<br>  - name: app<br>    port: 80<br>    protocol: TCP<br>    #Port number were the network loadbalancer is listening<br>    targetPort: 80<br>---<br>apiVersion: v1<br>kind: <strong>Endpoints</strong><br>metadata:<br>  name: nlb-service<br>subsets:<br>- addresses:<br>  #IP address of the network load balancer [ILB]<br>  - ip: <strong>10.1.2.99</strong><br>  ports:<br>  - name: app<br>  #Port number were the network load balancer is listening<br>    port: 80</pre><h3><strong>Testing the flow</strong></h3><ul><li>Validate the ingress is deployed and appropriate routes have been created</li></ul><pre>abildikar@cloudshell &gt;:<strong>kubectl describe ingress</strong></pre><pre>Name:             demo-ingress<br>Labels:           &lt;none&gt;<br>Namespace:        &lt;none&gt;<br>Ingress Class:    &lt;none&gt;<br>Default backend:  &lt;default&gt;<br><strong>Rules:<br>  Host        Path  Backends<br>  ----        ----  --------<br>  *           <br>               /v1   hello-world-1:60000 (&lt;none&gt;)              <br>               /v2   nlb-service:80 (10.1.2.99:80)<br>              </strong><br>Annotations:  ingress.kubernetes.io/backends:<br>                {&quot;k8s-be-30010--39d21311723685fb&quot;:&quot;Unknown&quot;,&quot;k8s-be-31166--39d21311723685fb&quot;:&quot;Unknown&quot;,&quot;k8s1-39d21311-default-hello-world-1-60000-de79eceb...<br>              ingress.kubernetes.io/forwarding-rule: k8s2-fr-s0sxvzj4-default-demo-ingress-efxy8a9t<br>              ingress.kubernetes.io/target-proxy: k8s2-tp-s0sxvzj4-default-demo-ingress-efxy8a9t<br>              ingress.kubernetes.io/url-map: k8s2-um-s0sxvzj4-default-demo-ingress-efxy8a9t<br>Events:<br>  Type    Reason  Age                    From                     Message<br>  ----    ------  ----                   ----                     -------<br>  Normal  Sync    3m42s (x1181 over 1d)  loadbalancer-controller  Scheduled for sync</pre><p>As you can see in the screenshot above ingress has created the routes to the nlb-service</p><ul><li>Lets now curl the service to see the it in action 😊</li></ul><pre>abildikar@cloudshell &gt;:<strong>curl &lt;ip of ingress&gt;/v1</strong><br> Hello World from pod &quot;hello-world-webapp-b6xwxs&quot;</pre><p>In this setup the the path <strong>v1</strong> is calling the deployment on gke cluster so getting the output of hello-world from the pod “hello-world-webapp-b6xwxs”</p><p>Now lets curls the <strong>v2</strong> path which will take our request out of the cluster to a MIG</p><pre>abildikar@cloudshell &gt;:curl <strong>&lt;ip of ingress&gt;/v2</strong><br>&lt;!doctype html&gt;&lt;html&gt;&lt;body&gt;&lt;h1&gt;Hello World! from MIG&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;</pre><p>As you can see the request is routed to the application running in the MIG via the internal load balancer</p><h3><strong>Reference</strong></h3><ul><li>Steps to create the components on google cloud used here have been taken from <a href="https://cloud.google.com/docs">https://cloud.google.com/docs</a></li><li>The solution on k8s have been discussed on stackoverflow using <a href="https://stackoverflow.com/questions/57764237/kubernetes-ingress-to-external-service">nginx-ingress</a></li><li>This issue has also been discussed on k8s github issue # <a href="https://github.com/kubernetes/kubernetes/issues/8631#issuecomment-104404768">8631</a></li><li>For productionising this solution refer the <a href="https://cloud.google.com/architecture/prep-kubernetes-engine-for-prod?hl=en">best practices</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99d9a0374458" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>