kubernetes - 无法为 volumeMount 准备 subPath
问题描述
收到此错误。
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
非常感谢您的帮助。谢谢
解决方案
如果不使用会发生什么subPath
?
configMap中的所有键都将挂载在 directory 中/tell/carbon/conf
。这意味着,每个键都将是该目录下的一个单独文件。
现在,这subPath
是做什么的?从你的例子中,
volumeMounts:
- name: solr-collection-config
mountPath: /tell/carbon/conf
subPath: conf
意味着,conf
来自configMap的密钥将作为文件挂载到目录conf
下/tell/carbon
。
但是,您没有这把钥匙。所以得到这个错误。
错误:无法为容器“upload-config-container”的volumeMount“solr-collection-config”准备子路径
现在,你可以这样做
volumeMounts:
- name: solr-collection-config
mountPath: /tell/carbon/conf
subPath: stopwords_en.txt
这意味着,stopwords_en.txt
来自您的configMap的值将作为conf
文件挂载在/tell/carbon
.
最后的话,这subPath
实际上是从数据量到数据来源的路径。在您的情况下,subPath
应该是您的configMap中的关键之一
推荐阅读
- angular - 在创建角度元素时,会生成多个块文件。如何将所有这些合并为一个
- ios - 在后台模式下使用 CoreML 对用户活动进行分类
- javascript - 如何使用 clearRect() 而不删除我拥有的其他对象?
- kotlin - Kotlin 项目创建期间缺少模板
- node.js - 带有 React 前端的 NodeJS/Express API 实时通知
- java - 有条件地记录信息的最有效方法是什么?
- assembly - 在 x86_x64 架构上组装 x86 汇编源代码
- excel - 有一个更好的方法吗?VBA 脚本
- c# - Visual Studio 如何在 Regex 构造函数中语法高亮字符串?
- javascript - 如何使我的 chrome 扩展程序正常工作?