无法使用configMap填充卷

时间:2017-04-05 11:06:30

标签: spring-boot kubernetes

我正在尝试运行一个springboot应用程序,其application.properties文件将用作kubernetes configMap。

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

configMap name:integration-properties 数据:

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”不存在。

如果需要进一步配置,请告诉我们,如果有的话,请告知我们。

1 个答案:

答案 0 :(得分: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文件看起来不错,没有任何问题。