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
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.