Trying to dynamically load application.yaml properties from configmap in kubernetes but the properties not loading

6/7/2019

Simple Springboot microservice packaged with Gradle and built with docker to be deployed on kubernetes cluster. Trying to fetch application.yaml properties from kubernetes configmap. The property not loading.

Followed instructions at 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'
}

Application deploys ok on kubernetes.

actuator endpoint info does not show the proper value for kafkaname

..dot-devshell.appspot.com/actuator/info shows kafkaName = unavailable.

-- Ajar Vashisth
configmap
gradle
kubernetes
spring-boot

0 Answers