简体   繁体   中英

can't populate volume using configMap

I am trying run a spring boot application whose application.properties file will be used as a kubernetes configMap.

While deploying the app, I am adding a volume for this config file. But somehow, it is not creating properties file at mount path.

configMap name : integration-properties Data :

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

Deployment.yaml file :

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

When I run this application, it says, "/opt/build/application.properties" does not exists.

Please let me know for any further configuration required, if any and steps to do them.

So define configMap as:

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

or you can also create directly from the application.properties file

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

Your deployment.yaml file looks good to me there isn't any problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM