2017-04-05 55 views
0

我正在尝试运行其application.properties文件将用作kubernetes configMap的弹簧引导应用程序。无法使用configMap填充音量

在部署应用程序时,我正在为此配置文件添加一个卷。但不知何故,它不是在安装路径中创建属性文件。

configMap名称:集成的属性 数据:

application.properties: 
http.stub.api.host=localhost 
http.stub.api.port=8080 
http.stub.api.path=stub-api 

Deployment.yaml文件:

volumeMounts: 
       - name: config-volume 
       mountPath: /opt/build/ 
volumes: 
     - name: config-volume 
      configMap: 
      name: integration-properties 
      items: 
       - key: application.properties 
       path: application.properties 

当我运行该应用程序,它说,“/opt/build/application.properties “不存在。

请让我知道任何进一步的配置要求,如果有的话,并采取措施来做到这一点。

回答

0

所以定义为configMap:

data: 
    application.properties: | 
    http.stub.api.host=localhost 
    http.stub.api.port=8080 
    http.stub.api.path=stub-api 

,或者您也可以直接从application.properties文件

kubectl create configmap integration-properties --from-file=application.properties=<path to file> 

deployment.yaml文件看起来不错,我创建没有任何问题。