I can't use my LoadBalancer service with Ingress as NodePort service - 502 Server error

1/2/2020

I have a working LoadBalancer service on Google Cloud Platform that I want to use with Ingress. I changed the type of that service to NodePort. After that service is not working anymore. I keep getting 502 error - The server encountered a temporary error and could not complete your request.

As a service api, I run Django app that is working on port 8000.

Ingress yaml file:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: api
          servicePort: 8080

Service api yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
      - image: mkozmelj/pl_microservices_api:1.0.0-39.1
        name: api
        ports:
        - containerPort: 8000
          name: server
          protocol: TCP
---

apiVersion: v1
kind: Service
metadata:
  name: api
spec:
  type: NodePort
  selector:
    app: api
  ports:
    - port: 8080
      protocol: TCP
      targetPort: 8000

I am stuck at this point and cannot find out where the problem is.

-- Martin Kozmelj
django
google-cloud-platform
kubernetes-ingress

0 Answers