<p>I am trying to whitelist IPs that can access my application. I created http-balancer by following this tutorial. <a href="https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer</a></p>

<p>After creating the service with <code>NodePort</code> I created an <code>ingress.yaml</code> file that looks like the one below. I have created a global static ip and setup a domain name.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: &lt;global-static-ip&gt;
spec:
  rules:
  - host: &lt;domain_name&gt;
  - http:
      paths:
      - path: /*
        backend:
            serviceName: nginx
            servicePort: 80
</code></pre>

<p>This above yaml file works fine and I am able to access the "Welcome to Nginx" page. </p>

<p>But when I add the IPs to be whitelisted it does not seem to work and still allows other IPs that are not whitelisted.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: nginx-ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: &lt;global-static-ip&gt;
    ingress.kubernetes.io/whitelist-source-range: "xx.xx.xx.xxx/32"
spec:
  rules:
  - host: &lt;domain_name&gt;
  - http:
      paths:
      - path: /*
        backend:
            serviceName: nginx
            servicePort: 80
</code></pre>

<p>Reference: 
<a href="http://container-solutions.com/kubernetes-quick-tip/" rel="nofollow noreferrer">http://container-solutions.com/kubernetes-quick-tip/</a>
<a href="https://docs.giantswarm.io/guides/advanced-ingress-configuration/" rel="nofollow noreferrer">https://docs.giantswarm.io/guides/advanced-ingress-configuration/</a></p>

<p>I have not worked with Ingress but as per normal nginx rules you need to deny all and then allow the whitelist IPS</p>

<pre><code>          `location / {
                    proxy_pass https://xxx.xx.xx.xx:8080 
                    allow xx.xx.xx.xxx/32; 
                    deny all; 
                     allow xx.xx.xx.xxx/32; 
           }`
</code></pre>

<p>Which inturn wont allow your non-Whitelisted IP's.</p>
