【问题标题】:Failed to prepare subPath for volumeMount无法为 volumeMount 准备 subPath
【发布时间】:2018-12-19 23:49:38
【问题描述】:

收到此错误。

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

使用 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 是代表 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

非常感谢您的帮助。谢谢

【问题讨论】:

    标签: kubernetes configmap


    【解决方案1】:

    如果你不使用subPath会怎样?

    configMap 中的所有键都将安装在目录/tell/carbon/conf 中。这意味着,每个键都将是该目录下的一个单独文件。

    现在,subPath 做了什么?从你的例子中,

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

    意味着,configMap 中的密钥conf 将作为文件conf 挂载到/tell/carbon 目录下。

    但是,你没有这把钥匙。所以得到这个错误。

    错误:无法为容器“upload-config-container”的volumeMount“solr-collection-config”准备子路径

    现在,你可以这样做了

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

    这意味着,您的 configMap 中的 stopwords_en.txt 值将作为 conf 文件挂载到 /tell/carbon 下。

    最后的话,这个subPath 实际上是一条来自卷的路径,你的数据来自哪里。在您的情况下,subPath 应该是您 configMap

    中的关键之一

    【讨论】:

    • 问题。我粘贴的 yaml 适用于 kubernetes 1.9.3,但在我升级到 kube 1.10.11 时停止了 - 后来由于子路径中的安全错误而更改了规范
    • 不确定更改。如果我发现了,会通知你
    猜你喜欢
    • 2022-11-14
    • 2022-06-19
    • 2020-04-05
    • 2019-03-15
    • 1970-01-01
    • 1970-01-01
    • 2021-02-01
    • 2020-04-20
    • 2016-10-15
    相关资源
    最近更新 更多