k8s 新手。
我的配置图看起来像
apiVersion: v1
kind: ConfigMap
metadata:
name: example-configmap-overriding-new-01
data:
application.properties: |
globalkey = global key value
TeamName = Team Name value
#Some other key value pairs
application-qa.properties: |
globalkey = global key qa value
TeamName = Team Name qa value
#Some other key value pairs
application-prod.properties: |
globalkey = global key prod value
Company = company prod value
#Some other key value pairs
在我的 Spring Boot 应用程序中尝试使用此配置映射时,应用程序没有从配置映射中获取值。它说,
Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException:
Could not resolve placeholder 'globalkey' in value "${globalkey}"
在这里发布了这个问题。
不幸的是,看到了 configmap 在容器内注入的环境变量。共享日志以供参考。
application.properties=globalkey = global key value
TeamName = Team Name value
Purpose = Purpose value
RootFile = Root file value
Company = company value
Place = Place value
Country = Country value
application-prod.properties=globalkey = global key prod value
Company = company prod value
Place = Place prod value
Country = Country prod value
application-qa.properties=globalkey = global key qa value
TeamName = Team Name qa value
Purpose = Purpose qa value
RootFile = Root file qa value
#Some other key values pairs injected by k8s
我相信,从日志中,"application.properties=globalkey = global key value",还没有看到这样的键值对。
怀疑,注入configmap时出了点问题。是否有任何语法错误或?
PS:-我也尝试了以下语法。
apiVersion: v1
kind: ConfigMap
metadata:
name: example-configmap-overriding-new-01
data:
application.properties: |-
globalkey = global key value
application-qa.properties: |-
globalkey = global key qa value
我在 windows 10 pro 机器上使用 minikube 进行本地开发。
有人可以在这里分享见解。
PS:我在问为什么 env 变量显示为“application.properties=globalkey = global key value”,我还链接了问题的来源。在旧问题中,我问“无法从 configmap 读取”。在新问题中,我问“多配置文件配置映射未正确注入容器”