Failed to prepare subPath for volumeMount

好久不见. 提交于 2020-02-22 05:29:13

问题


Getting this error.

Error: failed to prepare subPath for volumeMount "solr-collection-config" of container "upload-config-container"

Using kubernetes 1.10.11

- name: upload-config-container image: solr:7.4.0-alpine imagePullPolicy: Always resources: requests: memory: "128Mi" cpu: "100m" limits: memory: "256Mi" cpu: "200m" volumeMounts: - name: solr-collection-config mountPath: /tell/carbon/conf subPath: conf

solr-collection-config is a volume that represents a ConfigMap

volumes: - name: solr-collection-config configMap: name: solr-collection-resources items: - key: stopwords_en.txt path: "conf/lang/stopwords_en.txt" - key: _rest_managed.json path: "conf/_rest_managed.json" - key: currency.xml path: "conf/currency.xml" - key: protwords.txt path: "conf/protwords.txt" - key: schema.xml path: "conf/schema.xml" - key: solrconfig.xml path: "conf/solrconfig.xml" - key: stopwords.txt path: "conf/stopwords.txt" - key: synonyms.txt path: "conf/synonyms.txt" restartPolicy: Never

Help is kindly appreciated. Thank you


回答1:


What happens if you do not use subPath?

All keys from configMap will be mounted in directory /tell/carbon/conf. That means, every key will be a separate file under this directory.

Now, what this subPath does? From your example,

volumeMounts:
  - name: solr-collection-config
    mountPath: /tell/carbon/conf
    subPath: conf

Means, key conf from configMap will be mounted as file conf under /tell/carbon directory.

But, you do not have this key. So getting this error.

Error: failed to prepare subPath for volumeMount "solr-collection-config" of container "upload-config-container"

Now, you can do like this

volumeMounts:
  - name: solr-collection-config
    mountPath: /tell/carbon/conf
    subPath: stopwords_en.txt

Which means, value of stopwords_en.txt from your configMap will be mounted as conf file under /tell/carbon.

Final words, this subPath is actually a path from volume, from where your data is coming. In your case, subPath should be one of the key from your configMap



来源:https://stackoverflow.com/questions/53860721/failed-to-prepare-subpath-for-volumemount

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!