<p>I try to deploy my application on GCP. I have a frontend in Vuejs and an api with Flask and a Postgre database</p>
<p>Everything is deployed in a Kubernetes cluster on GCP.
I can accès to my frontend without any problems, but I cannot access to the api, I have a 502 bad gatteway.
I think a made a mistake in my configuration.
Here is my configuration :</p>
<pre><code>**flask-service.yml**

apiVersion: v1
kind: Service
metadata:
  name: flask
  labels:
    service: flask
spec:
  type: NodePort
  selector:
    app: flask
  ports:
  - protocol: TCP
    port: 5000
    targetPort: 5000
</code></pre>
<p>vue-service.yml file</p>
<pre><code>**vue-service.yml**

apiVersion: v1
kind: Service
metadata:
  name: vue
  labels:
    service: vue
spec:
  type: NodePort
  selector:
    app: vue
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 8080
</code></pre>
<p>ingress.yml file</p>
<pre><code>ingress.yml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: vue
          servicePort: 8080
      - path: /api/*
        backend:
          serviceName: flask
          servicePort: 5000
</code></pre>
<p>My flask app is deployed with gunicord</p>
<pre><code>gunicorn -b 0.0.0.0:5000 manage:app
</code></pre>
<p><a href="https://i.stack.imgur.com/noGDG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/noGDG.png" alt="screeshot of my GCP cluster services" /></a></p>
<p>Do you know where I've made a mistake ? I'm a beginner in kubernetes</p>
<p>Here is my Dockerfile</p>
<pre><code>FROM python:3.8.1-slim

# install netcat
RUN apt-get update &amp;&amp; \
    apt-get -y install netcat &amp;&amp; \
    apt-get clean

# set working directory
WORKDIR /usr/src/app

# add and install requirements
RUN  pip install --upgrade pip
RUN pip install -U gunicorn
COPY ./requirements.txt /usr/src/app/requirements.txt
RUN pip install -r requirements.txt

# add entrypoint.sh
COPY ./entrypoint.sh /usr/src/app/entrypoint.sh
RUN chmod +x /usr/src/app/entrypoint.sh

# add app
COPY . /usr/src/app

# run server
CMD [&quot;/usr/src/app/entrypoint.sh&quot;]
</code></pre>
<p>And my entrypoint.sh</p>
<pre><code>echo &quot;Waiting for postgres...&quot;

while ! nc -z postgres 5432; do
  sleep 0.1
done

echo &quot;PostgreSQL started&quot;

gunicorn -b 0.0.0.0:5000 manage:app
</code></pre>
<p>One more edit. In GCP, when I check backend services, there are 3 backends, and one of them doesn't work
But why do I have 3 backend ? I should have juste two no (flask and vue)?</p>
<p>When I check, I have 2 backend services with Flask, and on of them doesn't work</p>
<p><a href="https://i.stack.imgur.com/CK81L.png" rel="nofollow noreferrer">The backend services (flask) with problems</a></p>
<p><a href="https://i.stack.imgur.com/hceMM.png" rel="nofollow noreferrer">the other backend services (flask)</a></p>
<p>My Flask Image logs in GCP show an error. Do you know why ?</p>
<p><a href="https://i.stack.imgur.com/65p0W.png" rel="nofollow noreferrer">GCP log of my flask image</a></p>

Eric
<p>I founded the solution. It was a problem with my ingress, I forgot to add an Ingress Controler. (I didn't know anything about Ingress Controler...)</p>
<p>Now I've added an Nginx Ingress Controler and everything works fine !</p>
