title: Giving a different public IP/URL to services on different namespaces
body: <p>I'm currently running a set of pods and services inside my <code>production</code> namespace. The services are exposed via the kubernetes nginx-ingress controller.</p>
  <p>This is working fine, all the resources can be accesed with no problems.</p>
  <p>What I want to achieve now is to have another namespace <code>staging</code> with other types of resources and services, and also be able to access them with a public IP / url. This IP should be different from the <code>production</code> public IP since we don't want to change the URL schema on out nginx ingress.</p>
  <p>Is there a way to achieve this using the nginx controller? We are running on AKS and installed the nginx ingress with the following helm commands:</p>
  <pre><code># Create a namespace for your ingress resources
  kubectl create namespace ingress-basic
  
  # Add the ingress-nginx repository
  helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
  
  # Use Helm to deploy an NGINX ingress controller
  helm install nginx-ingress ingress-nginx/ingress-nginx \
      --namespace ingress-basic \
      --set controller.replicaCount=2 \
      --set controller.nodeSelector.&quot;beta\.kubernetes\.io/os&quot;=linux \
      --set defaultBackend.nodeSelector.&quot;beta\.kubernetes\.io/os&quot;=linux \
      --set controller.admissionWebhooks.patch.nodeSelector.&quot;beta\.kubernetes\.io/os&quot;=linux
  </code></pre>
  <p>as described here: <a href="https://docs.microsoft.com/en-us/azure/aks/ingress-basic" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/aks/ingress-basic</a></p>
  <p>This is the ingress that we use on our helm chart:</p>
  <pre><code>apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: my-ingress
    namespace: {{ .Release.Namespace }}
    annotations:
      kubernetes.io/ingress.class: &quot;nginx&quot;
      nginx.ingress.kubernetes.io/use-regex: &quot;true&quot;
      nginx.ingress.kubernetes.io/enable-cors: &quot;true&quot;
      cert-manager.io/issuer: &quot;letsencrypt-prod&quot;
      watch-namespace: {{ .Release.Namespace }}
  #    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
  #    nginx.ingress.kubernetes.io/force-ssl-redirect: &quot;false&quot;
      # Limit uploads to 8TB
      nginx.ingress.kubernetes.io/proxy-body-size: 800000m
  spec:
    tls:
      - secretName: my-cert-tls
        hosts:
          - {{ .Values.myDomain }}
    rules:
    - host: {{ .Values.myDomain }}
      http:
        paths:
        # NOTE: this one should come after all other routes. To avoid hijacking requests.
        - path: /api/svc1(/|$)(.*)
          backend:
            serviceName: svc1
            servicePort: 8080
        - path: /api(/|$)(.*)
          backend:
            serviceName: svc2
            servicePort: 8080
        - path: /(.*)
          backend:
            serviceName: svc3
            servicePort: 8080
    - http:
        paths:
        # NOTE: this one should come after all other routes. To avoid hijacking requests.
        - path: /api/svc2(/|$)(.*)
          backend:
            serviceName: svc2
            servicePort: 8080
        - path: /api(/|$)(.*)
          backend:
            serviceName: svc1
            servicePort: 8080
        - path: /(.*)
          backend:
            serviceName: svc3
            servicePort: 8080
  </code></pre>
  <p>Essentially I would like to see:</p>
  <ul>
  <li>IP 1 =&gt; namespace1 resources</li>
  <li>IP 2 =&gt; namespace2 resources</li>
  </ul>
  <p>IP1 can never access namespace2 and viceversa.</p>