<p>I'm trying to setup ingress on azure. I have a pod and service running (a website).</p>

<p>Googling about Ingress setup, it seems you have to create 3 things, Ingress, service and ingress controller (pod)</p>

<p>THis is what I have so far:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: myingress  
  annotations:    
    kubernetes.io/ingress.class: nginx
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: ui.example.com
    http:
      paths:
      - backend:
        serviceName: ui
        servicePort: 80
  - host: monit.example.com
    http:
      paths:
      - path:
        backend:
          serviceName: grafana
          servicePort: 80
</code></pre>

<p>This is almost self explanatory, but what exactly does the <code>rewrite-target</code> do (I have two backends)?</p>

<p>Next the service with LoadBalancing</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: ingressservice
spec:
  ports:
  - port: 80
    name: http
  - port: 443
    name: https
  selector:
    k8s-app: nginx-ingress-controller
  type: LoadBalancer
</code></pre>

<p>And the ingress controller</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-ingress-controller
  labels:
    k8s-app: nginx-ingress-controller
spec:
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: nginx-ingress-controller
      annotations:
        prometheus.io/port: '10254'
        prometheus.io/scrape: 'true'
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.15
        name: nginx-ingress-controller        
        ports:
        - containerPort: 80
          hostPort: 80
        - containerPort: 443
          hostPort: 443
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        args:
          - /nginx-ingress-controller
          - --default-backend-service=$(POD_NAMESPACE)/default-http-backend     
</code></pre>

<p>Questions:
  * How does all this work together? 
  * Is the image for ingress-controller correct? (It should run on Azure)</p>

Jeanluca Scaljeri
<p>doesn't matter on which cloud your kubernetes runs, ingress happens inside kubernetes, so its cloud agnostic. to setup ingress you can use the <a href="https://github.com/helm/charts/tree/master/stable/nginx-ingress" rel="nofollow noreferrer">official helm chart</a> for that. After that you would need to create ingress definitions to expose your services using the ingress you've created.</p>
