<p>I am trying to configure one python flask application running in port 5000 in kubernetes. I have created the deployment, service and ingress. It is not working using the domain name which is added to hosts file, but python application is working when i have tried from port forwarding.</p>

<p>I have tried a lot changing the configurations, but no thing worked.</p>

<p>Please let me know your suggestions.</p>

<pre><code>kind: Deployment
metadata:
  name: web-app
  namespace: production
  labels:
    app: web-app
    platform: python
spec:
  replicas:
  selector:
    matchLabels:
      app: web-app
  template:
    metadata:
      labels:
        app: web-app
    spec:
      containers:
      - name: web-app
        image: XXXXXX/XXXXXX:XXXXXX
        imagePullPolicy: Always
        ports:
        - containerPort: 5000
</code></pre>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: web-app
  namespace: production
spec:
  selector:
    app: web-app
  ports:
  - protocol: TCP
    port: 5000
    targetPort: 5000
  selector:
    run: web-app
</code></pre>

<pre><code>kind: Ingress
metadata:
  name: name-virtual-host-ingress
  namespace: production
spec:
  rules:
  - host: first.bar.com
    http:
      paths:
      - backend:
          serviceName: web-app
          servicePort: 5000
</code></pre>

<p>kubectl get all -n production</p>

<pre><code>NAME                          READY   STATUS    RESTARTS   AGE
pod/web-app-559df5fc4-67nbn   1/1     Running   0          24m

NAME              TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/web-app   ClusterIP   10.100.122.15   &lt;none&gt;        5000/TCP   24m

NAME                      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/web-app   1         1         1            1           24m

NAME                                DESIRED   CURRENT   READY   AGE
replicaset.apps/web-app-559df5fc4   1         1         1       24m
</code></pre>

<p>kubectl get ing -n production</p>

<pre><code>NAME                        HOSTS           ADDRESS   PORTS   AGE
name-virtual-host-ingress   first.bar.com             80      32s
</code></pre>

<p>kubectl get ep web-app -n production</p>

<pre><code>NAME      ENDPOINTS   AGE
web-app   &lt;none&gt;      23m
</code></pre>

<p>You need to run a Ingress Controller. The Prerequisites part of <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#prerequisites" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/ingress/#prerequisites</a> says:</p>

<blockquote>
  <p>You must have an ingress controller to satisfy an Ingress. Only creating an Ingress resource has no effect.</p>
</blockquote>

<p>One example would be <a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/deploy/</a>. Be sure to run the <strong>Mandatory Command</strong> and the one that pertains to your provider. You can then get the service to see the assigned IP:</p>

<pre><code>kubectl get -n ingress-nginx svc/ingress-nginx
</code></pre>
