<p>I have a couple of applications, which runs in Docker containers (all on the same VM).
In front of them, I have an nginx container as a reverse proxy.
Now I want to migrate that to Kubernetes. </p>

<p>When I start them by docker-composer locally it works like expected.
On Kubernetes not.</p>

<h3>nginx.conf</h3>

<pre><code>http {
        server {
                location / {
                        proxy_pass http://app0:80;
                }

                location /app1/ {
                        proxy_pass http://app1:80;
                        rewrite ^/app1(.*)$ $1 break;
                }

                location /app2/ {
                        proxy_pass http://app2:80;
                        rewrite ^/app2(.*)$ $1 break;
                }
        }
}
</code></pre>

<h3>edit: nginx.conf is not used on kubernetes. I have to use ingress-controller for that:</h3>

deployment.yaml

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: app0
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: app0
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
      - name: app0
        image: appscontainerregistry1.azurecr.io/app0:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 80
          name: nginx
---
#the other apps
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-nginx
  annotations:
    # use the shared ingress-nginx
    kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: apps-url.com
    http:
      paths:
      - path: /
        backend:
          serviceName: app0
          servicePort: 80
      - path: /app1
        backend:
          serviceName: app1
          servicePort: 80
      - path: /app2
        backend:
          serviceName: app2
          servicePort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: loadbalancer
spec:
  type: LoadBalancer
  ports:
  - port: 80
  selector:
    app: ingress-nginx
</code></pre>

<p>I get the response on / (app0). Unfortunately, the subroutes are not working. What I´m doing wrong?</p>

<h3>EDIT</h3>

<p>I figured out. Ich missed installing the ingress controller. Like on this page (<a href="https://kubernetes.io/docs/concepts/services-networking/ingress/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/ingress/</a>) described, the ingress doesn't work if no controller is installed. 
I used ingress-nginx as a controller (<a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/deploy/</a>) because it was the best-described install guide which I was able to find and I didn´t want to use HELM.
I have one more question. How I can change my ingress that subdomains are working. 
For example, k8url.com/app1/subroute shows me every time the start page of my app1. 
And if I use a domain name proxying, it rewrites every time the domain name by the IP. </p>

<p>Add this : </p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: loadbalancer
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
  selector:
    app: ingress-nginx
</code></pre>

<p>Because you didnot route for <code>Service</code> Load balancer to <code>targetPort</code> to <code>80</code></p>
