尝试从kubernetes中的configmap动态加载application.yaml属性,但该属性未加载

时间:2019-06-07 22:48:28

标签: spring-boot gradle kubernetes configmap

与Gradle打包并由docker构建的简单Springboot微服务,可部署在kubernetes集群上。试图从kubernetes configmap获取application.yaml属性。该属性未加载。

遵循https://cloud.spring.io/spring-cloud-static/spring-cloud-kubernetes/1.0.0.M2/multi/multi__configmap_propertysource.html上的说明

springboot application.yaml

info:
  kafkaName: ${stream-connector-config.kafkaName:unavailable}

spring:
  application:
    name: julian
  cloud:
    kubernetes:
      config:
        name: julian
        namespace: colorado
        sources:
          - name: julian
      reload:
        enabled: true
        mode: polling
        period: 2000

configmap

apiVersion: v1
data:
  application.yaml: |
    stream-connector-config:
      errorTopic: test-01.stream.error
      kafkaName: ccloud-eu-dev-gcp
      streamSettings:
        application.id: ajar-stream
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: julian
  namespace: colorado
dependencies {
    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
    compile 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.apache.kafka:kafka-streams'
    implementation 'org.springframework.cloud:spring-cloud-gcp-starter'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

应用程序可以在kubernetes上正常部署。

执行器端点信息未显示kafkaname的正确值

.. dot-devshell.appspot.com/actuator/info显示kafkaName =不可用。

0 个答案:

没有答案