无法为volumeMount准备子路径

时间:2018-12-19 23:49:39

标签: kubernetes configmap

遇到此错误。

dotnet ef dbcontext scaffold "Server=(mysql)\localhost;Database=edums_development;Trusted_Connection=True;" MySql.Data.EntityFrameworkCore -c EdumsDataContext

使用kubernetes 1.10.11

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

- 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是代表ConfigMap的卷

solr-collection-config

非常感谢您的帮助。谢谢

1 个答案:

答案 0 :(得分:3)

如果您不使用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

中的键之一