<p>I need to access an internal application running on GKE Nginx Ingress service riding on Internal Load Balancer, from another GCP region. </p>

<p>I am fully aware that it is not possible using direct Google networking and it is a huge limitation (<a href="https://issuetracker.google.com/issues/111021512" rel="noreferrer">GCP Feature Request</a>).</p>

<p>Internal Load Balancer can be accessed perfectly well via VPN tunnel from AWS, but I am not sure that creating such a tunnel between GCP regions under the same network is a good idea.</p>

<p>Workarounds are welcomed!</p>

Meir Tseitlin
<p>In the release notes from GCP, it is stated that:</p>
<blockquote>
<p><a href="https://cloud.google.com/load-balancing/docs/internal/setting-up-internal#ilb-global-access" rel="nofollow noreferrer">Global access</a> is an optional parameter for internal LoadBalancer Services that allows clients from any region in your VPC to access the internal TCP/UDP Load Balancer IP address.</p>
<p>Global access is enabled per-Service using the following annotation: <br>
<strong>networking.gke.io/internal-load-balancer-allow-global-access: &quot;true&quot;.</strong></p>
</blockquote>
<h2>UPDATE: Below service works for <em>GKE v1.16.x</em> &amp; newer versions:</h2>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: ilb-global
  annotations:
    # Required to assign internal IP address
    cloud.google.com/load-balancer-type: &quot;Internal&quot;
    
    # Required to enable global access
    networking.gke.io/internal-load-balancer-allow-global-access: &quot;true&quot;
  labels:
    app: hello
spec:
  type: LoadBalancer
  selector:
    app: hello
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
</code></pre>
<br>
<h3>For <em>GKE v1.15.x</em> and older versions:</h3>
<p>Accessing internal load balancer IP from a VM sitting in a different region will not work. But <a href="https://cloud.google.com/load-balancing/docs/internal/setting-up-internal#ilb-global-access" rel="nofollow noreferrer">this</a> helped me to make the internal load balancer global.</p>
<p>As we know internal load balancer is nothing but a <a href="https://cloud.google.com/load-balancing/docs/forwarding-rule-concepts" rel="nofollow noreferrer">forwarding rule</a>, we can use <a href="https://cloud.google.com/sdk/gcloud/" rel="nofollow noreferrer">gcloud</a> command to enable global access.</p>
<ol>
<li><p>Firstly get the internal IP address of the Load Balancer using <a href="https://kubernetes.io/docs/reference/kubectl/overview/" rel="nofollow noreferrer">kubectl</a> and save its IP like below:</p>
<pre><code># COMMAND:
kubectl get services/ilb-global

# OUTPUT:
NAME           TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
ilb-global     LoadBalancer   10.0.12.12   10.123.4.5    80:32400/TCP   18m
</code></pre>
<p>Note the value of &quot;EXTERNAL-IP&quot; or simply run the below command to make it even simpler:</p>
<pre><code># COMMAND:
kubectl get  service/ilb-global \
  -o jsonpath='{.status.loadBalancer.ingress[].ip}'

# OUTPUT:
10.123.4.5
</code></pre>
</li>
<li><p>GCP gives a randomly generated ID to the forwarding rule created for this Load Balancer. If you have multiple forwarding rules, use the following command to figure out which one is the internal load balancer you just created:</p>
<pre><code># COMMAND:
gcloud compute forwarding-rules list | grep 10.123.4.5

# OUTPUT
NAME                              REGION       IP_ADDRESS      IP_PROTOCOL  TARGET
a26cmodifiedb3f8252484ed9d0192    asia-south1  10.123.4.5      TCP          asia-south1/backendServices/a26cmodified44904b3f8252484ed9d019
</code></pre>
<p><em><strong>NOTE:</strong></em> If you not working on Linux or grep is not installed, simply run <code>gcloud compute forwarding-rules list</code> and manually look for the forwarding rule having the IP address we are looking for.</p>
</li>
<li><p>Note the name of the forwarding-rule and run the following command to update the forwarding rule with <em>--allow-global-access</em> (remember adding <em>beta</em>, as it is still a beta feature):</p>
<pre><code># COMMAND:
gcloud beta compute forwarding-rules update a26cmodified904b3f8252484ed9d0192 \
--region asia-south1 --allow-global-access

# OUTPUT:
Updated [https://www.googleapis.com/compute/beta/projects/PROJECT/regions/REGION/forwardingRules/a26hehemodifiedhehe490252484ed9d0192].
</code></pre>
</li>
</ol>
<p>And it's done.  Now you can access this internal IP (<strong>10.123.4.5</strong>) from any instance in any region (but the same <a href="https://cloud.google.com/vpc/" rel="nofollow noreferrer">VPC network</a>).</p>
