1
votes

Does someone know how to solve this issue: WARN | main | o.s.c.k.c.ConfigMapPropertySource | Can't read configMap with name: [commons] in namespace:[dev]. Ignoring I have this configuration in my bootstrap-prod.yml:

spring:
  cloud:
    kubernetes:
      config:
        name: ${spring.application.name} 
        sources:
          - name: commons 
        namespace: dev
      secrets:
        name: commons-secret
      reload:
        enabled: true

But the application fails to start because of that error. Same issue as described here: https://github.com/spring-cloud/spring-cloud-kubernetes/issues/138 I bound the namespace's ServiceAccount to the cluster view role.

What's strange is in the same namespace there are 2 applications, the first one (a spring clud gateway app) can read its configMap but the second one (a simple spring boot web app) can't. What am I missing? The application is deployed on GKE.

#:::::::::::::::::DEPLOYMENT::::::::::::::::::
apiVersion: apps/v1
kind: Deployment
metadata:
  name: appservice
  namespace: dev
spec:
  ...

And the ConfigMap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: commons
  namespace: dev
data:
  application.yml: |-
    server:
      tomcat:
          basedir: ..${file.separator}tomcat-${spring.application.name}
    spring:
      profiles:
        active: prod
      cache:
        ...

Thanks for your help

1
Can you share YAML from your deployments and config maps?Amit Kumar Gupta
@AmitKumarGupta I edited the postakuma8
@AmitKumarGupta Sharing my configurations helps me to point out the problem, I guess. It finally worksakuma8
That was easy! Glad it's working. You could consider writing your answer and accepting it if you think you caught an error that might affect other people as well and would be helpful for them to see the fix.Amit Kumar Gupta
I posted the answer. I lost a day because of this issue :(!akuma8

1 Answers

2
votes

I found the issue, I guess it is. The problem came from a malformatted yaml. If you take a lookk at the ConfigMap configuration we have:

...
data:
  application.yml: |-
    server:
      tomcat:
          basedir: ..${file.separator}tomcat-${spring.application.name} # issue is here, bad indentation
    spring:
      profiles:
        active: prod
...

After changing that to:

data:
  application.yml: |-
    server:
      tomcat:
        basedir: ..${file.separator}tomcat-${spring.application.name}
    spring:
      profiles:
        active: prod

Everything seems to work fine. It's a bit strange that the error message doesn't point out that explicitly.