与Gradle打包并由docker构建的简单Springboot微服务,可部署在kubernetes集群上。试图从kubernetes configmap获取application.yaml属性。该属性未加载。
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 =不可用。