Home > database >  Kubernetes deployment error with Java/Micronaut: ERR_CONNECTION_REFUSED
Kubernetes deployment error with Java/Micronaut: ERR_CONNECTION_REFUSED

Time:03-29

I am trying to deploy an app having 3 services - frontend (Angular), backend 1 (Java/Micronaut), and backend 2 (Java/Micronaut).

My frontend works properly but the Java apps are not working.

Sometimes, I observed it started after 20 min. of deploying a Java app, but this time it does not work even after 1 hr.

Deployment, pod service - all are in running state in Kubernetes, but when I try to hit the URL I see below error:

enter image description here

deployment.yaml for java app

apiVersion: apps/v1
kind: Deployment
metadata:
  name: authentication-deploy
  labels:
    name: authentication-deploy
    app: supply-chain-app
spec:
  replicas: 1
  selector:
    matchLabels:
      name: authentication-pod
      app: supply-chain-app

  template:
    metadata:
      name: authentication-pod
      labels:
        name: authentication-pod
        app: supply-chain-app
    spec:
      containers:
        - name: authentication
          image: cawishika/authentication-service:1.1
          ports:
            - containerPort: 80

service.yaml for java app

apiVersion: v1
kind: Service
metadata:
  name: authentication-service
  labels:
    name: authentication-service
    app: supply-chain-app
spec:
  type: NodePort
  ports:
    - port: 80
      targetPort: 80
      nodePort: 30006
  selector:
    name: authentication-pod
    app: supply-chain-app

Docker file

FROM adoptopenjdk/openjdk11:latest
EXPOSE 8002
ADD target/authentication-service-0.1.jar authentication-service-0.1.jar
ENTRYPOINT ["java", "-jar", "/authentication-service-0.1.jar"]

kubectl logs podname enter image description here

CodePudding user response:

server running

Your Dockerfile is exposing port 8002 (EXPOSE 8002), but your app is started on port 8080.

Additionally, your Kubernetes configuration is pointing to port 80 of your pod.

You should set it so that all three configurations use the same port.

  • Related