Dockerfile doesn't seem to be exposing ports

3/12/2021

I'm trying to run a simple node server on port 8080, but with the following config any attempt at hitting the subdomain results in a 502 Bad Gateway error. If I go the node I can see there doesn't appear to be any ports open on the container itself. So, assuming I've checked everything correctly, is there anything else I need to do in the config to open the port for the node server?

Edit: If I ssh into the pod and curl localhost on 8080 I'm able to hit the node server.

enter image description here

Dockerfile

FROM node:12.18.1

WORKDIR /app
COPY ["package.json", "package-lock.json*", "./"]
RUN npm install 
COPY . .
RUN npm run build

EXPOSE 8080
CMD [ "node", "server.js" ]

k8s deployment

spec:
  containers:
  - name: test
    image: test_image
    ports:
    - name: http
      protocol: TCP
      containerPort: 8080

service yaml

apiVersion: v1
kind: Service
metadata:
  name: test-service
spec:
  ports:
  - name: http
    port: 80
    targetPort: 8080
    protocol: TCP
  - name: https
    port: 443
    targetPort: 8080
    protocol: TCP
  selector:
    app: test-deployment
  type: NodePort
  externalTrafficPolicy: Cluster

Ingress

spec:
  rules:
  - host: dev.test.com
    http:
      paths:
      - backend:
          serviceName: test-service
          servicePort: 80
        path: /
-- NealR
docker
kubernetes
nginx
port

1 Answer

3/12/2021

This wound up being on the application side. The server needed to be bound to 0.0.0.0 instead of 127.0.0.1.

enter image description here

-- NealR
Source: StackOverflow