Spring boot consul on Kubernetes

35 Views Asked by At

Consul service check failing.

I'm not sure what i'm doing wrong.

All the pods running successfully and accessable.

I provided all my configuration below.

enter image description here

consul.yml:

apiVersion: v1
kind: Service
metadata:
  name: consul-service
spec:
  type: LoadBalancer
  selector:
    app: consul-service
  ports:
    - port: 8500 # exposed by service
      targetPort: 8500 # exposed by pod (container port)

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: consul-service
  template:
    metadata:
      labels:
        app: consul-service
    spec:
      containers:
        - name: consul-service
          image: consul:1.15.4
          ports:
            - containerPort: 8500

Spring Cloud Gateway service & deployment yml:

apiVersion: v1
kind: Service
metadata:
  name: gateway-service
spec:
  type: ClusterIP
  selector:
    app: gateway-service
  ports:
    - port: 8080 # exposed by service
      targetPort: 8080 # exposed by pod (container port)

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: gateway-service
  labels:
    app: gateway-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gateway-service
  template:
    metadata:
      labels:
        app: gateway-service
    spec:
      containers:
        - name: gateway-service
          image: harbor.medsoft.care/medsoft8/gateway-service
          ports:
            - containerPort: 8080

My Gateway application.yml:

server:
  port: 8080

spring:
  application:
    name: gateway-service
  servlet:
    multipart:
      max-file-size: 25MB
      max-request-size: 25MB
  main:
    web-application-type: reactive
  cloud:
    consul:
      config:
        fail-fast: true
        enabled: false
      host: consul-service
      port: 8500
    gateway:
      routes:
        - id: auth
          uri: lb://auth-service
          predicates:
            - Path=/api/auth/**
          filters:
            - AuthenticationFilter

And my dependency, Spring version: 3.1.6, spring-cloud.version: 2022.0.4, Java 17

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-consul-all</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-consul-config</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
0

There are 0 best solutions below