<p>I have a Kubernetes cluster deployed on AWS (EKS). I deployed the cluster using the “eksctl” command line tool. I’m trying to deploy a Dash python app on the cluster without success. The default port for Dash is 8050. For the deployment I used the following resources:</p>
<ul>
<li>pod</li>
<li>service (ClusterIP type)</li>
<li>ingress</li>
</ul>
<p>You can check the resource configuration files below:</p>
<p><strong>pod-configuration-file.yml</strong></p>
<pre><code>kind: Pod
apiVersion: v1
metadata:
  name: dashboard-app
  labels:
    app: dashboard
spec:
  containers:
    - name: dashboard
      image: my_image_from_ecr
      ports:
        - containerPort: 8050
</code></pre>
<p><strong>service-configuration-file.yml</strong></p>
<pre><code>kind: Service
apiVersion: v1
metadata:
  name: dashboard-service
spec:
  selector:
    app: dashboard
  ports:
    - port: 8050 # exposed port
      targetPort: 8050
</code></pre>
<p><strong>ingress-configuration-file.yml (host based routing)</strong></p>
<pre><code>kind: Ingress
metadata:
  name: dashboard-ingress
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/force-ssl-redirect: &quot;false&quot;
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: dashboard.my_domain
    http:
      paths:
      - backend:
          serviceName: dashboard-service
          servicePort: 8050
        path: /
</code></pre>
<p>I followed the steps below:</p>
<pre><code>kubectl apply -f pod-configuration-file.yml
kubectl apply -f service-configuration-file.yml
kubectl apply -f ingress-confguration-file.yml
</code></pre>
<p>I also noticed that the pod deployment works as expected:</p>
<pre><code>kubectl logs my_pod:
</code></pre>
<p>and the output is:</p>
<pre><code>Dash is running on http://127.0.0.1:8050/

 Warning: This is a development server. Do not use app.run_server
 in production, use a production WSGI server like gunicorn instead.

 * Serving Flask app &quot;annotation_analysis&quot; (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
</code></pre>
<p>You can see from the ingress configuration file that I want to do host based routing using my domain. For this to work, I have also deployed an nginx-ingress. I have also created an “A” record set using Route53
that maps the “dashboard.my_domain” to the nginx-ingress:</p>
<pre><code>kubectl get ingress
</code></pre>
<p>and the output is:</p>
<pre><code>NAME                           HOSTS                                            ADDRESS.           PORTS.   AGE                                                            
dashboard-ingress         dashboard.my_domain                  nginx-ingress.elb.aws-region.amazonaws.com   80      93s
</code></pre>
<p>Moreover,</p>
<pre><code>kubectl describe ingress dashboard-ingress
</code></pre>
<p>and the output is:</p>
<pre><code>Name:             dashboard-ingress
Namespace:        default
Address:          nginx-ingress.elb.aws-region.amazonaws.com
Default backend:  default-http-backend:80 (&lt;error: endpoints &quot;default-http-backend&quot; not found&gt;)
Rules:
  Host                                            Path  Backends
  ----                                            ----  --------
  host.my-domain  
                                              /   dashboard-service:8050 (192.168.36.42:8050)
Annotations:                                      
nginx.ingress.kubernetes.io/force-ssl-redirect: false
                                              
nginx.ingress.kubernetes.io/rewrite-target: /
                                              
nginx.ingress.kubernetes.io/ssl-redirect: false
Events:                                           &lt;none&gt;
</code></pre>
<p>Unfortunately, when I try to access the Dash app on the browser, I get a
<strong>502 Bad Gateway</strong> error from the nginx. Could you please help me because my Kubernetes knowledge is limited.
Thanks in advance.</p>

P. Str
<p>It had nothing to do with Kubernetes or AWS settings. I had to change my python Dash code from:</p>
<pre><code>if __name__ == &quot;__main__&quot;:
    app.run_server(debug=True)
</code></pre>
<p>to:</p>
<pre><code>if __name__ == &quot;__main__&quot;:
    app.run_server(host='0.0.0.0',debug=True).
</code></pre>
<p>The addition of  <em><strong>host='0.0.0.0'</strong></em> did the trick!</p>
