Spring Cloud Consul健康检查和GCP上的状态配置

问题描述 投票:1回答:1

我们正在尝试在spring-cloud-consul上使用consul注册GCP compute engine应用程序,在那里它能够向领事注册应用程序,但是我们在应用程序中遇到了两个问题。以下是bootstrap.yaml和server.yaml的应用程序,

application.yaml

server:
  port: 10003
spring:
  application:
    name: hello-service
  cloud:
    consul:
      enabled: true
    inetutils:
      useOnlySiteLocalInterfaces: true
  endpoints:
    actuator:
      sensitive: false

bootstrap.yaml

spring:
  cloud:
    consul:
      enabled: true
      host: 10.160.0.18
      port: 8500
      discovery:
        prefer-ip-address: true
  1. Consul无法在计算引擎上调用健康检查,可能是因为它已在实例的内部域名上注册。

consul服务:NewService {id ='hello-service-10003',name ='hello-service',tags = [secure = false],address ='consul-app-test.c.name-of-project.internal ',meta = null,port = 10003,enableTagOverride = null,check = Check {script ='null',interval ='10s',ttl ='null',http ='http://consul-app-test.c.name-of-project.internal:10003/actuator/health',method ='null',header = {},tcp ='null',timeout ='null',deregisterCriticalServiceAfter ='null',tlsSkipVerify = null,status ='null'},checks = null}

  1. 申请,而不是从领事处注销。我们已停止在consul UI上显示的应用程序。
spring-boot google-cloud-platform spring-cloud-consul
1个回答
1
投票

我在application.yaml和bootstrap.yaml中做了一些更改,这对我有用。

application.yaml

spring:
  application:
    name: hello-service
  cloud:
    consul:
      discovery:
        instanceId: ${spring.application.name}:${random.value}
        health-check-critical-timeout: 3m
        prefer-ip-address: true # disable if we want to use google cloud internal DNS 

bootstrap.yaml

spring:
  cloud:
    consul:
      enabled: true
      host: 10.160.0.18
      port: 8500
© www.soinside.com 2019 - 2024. All rights reserved.