I have a kubernetes deployment running on a load balancer with a external IP created to access it outside my virtual machine. The deployment points to a docker image of a flask app which runs perfectly fine on its own.
However when copy-pasting the external IP of the loadbalancer I obtain the following error:
502 Bad Gateway, the destination was unreachable
Here is my deployment file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: flask-test
spec:
selector:
matchLabels:
app: flask-test
replicas: 1
template:
metadata:
labels:
app: flask-test
spec:
containers:
- name: flask-test
image: <image uri>
ports:
- containerPort: 5000
Here is my loadbalancer file:
apiVersion: v1
kind: Service
metadata:
labels:
app: flask-lb
name: flask-lb
spec:
type: LoadBalancer
ports:
- name: flask-lb
port: 5000
protocol: TCP
targetPort: 5000
selector:
app: flask-test
I have checked the description of both deployment and service and the ports match, the pods are running and the service is healthy. What could be the reason for a 502 bad gateway?
There are no other services running on port 5000