是否可以在kubernetes中将configmap与主机路径一起使用?
而不是对卷主机路径使用直接配置,如是否可以在kubernetes中将configmap与主机路径一起使用?,kubernetes,Kubernetes,而不是对卷主机路径使用直接配置,如 volumes: - name: mongo-24 hostPath: path: /my/path/to/file/or/directory type: DirectoryOrCreate 我想把它放到configmap中,所以我尝试了这个: volumes: - name: myVolume hostPath: path: valueFro
volumes:
- name: mongo-24
hostPath:
path: /my/path/to/file/or/directory
type: DirectoryOrCreate
我想把它放到configmap中,所以我尝试了这个:
volumes:
- name: myVolume
hostPath:
path:
valueFrom:
configMapKeyRef:
name: common-config
key: MY_VOLUME_PATH
type: DirectoryOrCreate
但这并不成功,因为:
验证数据时出错:字段的类型字符串应为
spec.template.spec.volumes[0].hostPath.path,已获取映射
可以将hostPath/path与配置映射一起使用吗?简单地说,不可以。问题是,为什么需要它/您想实现什么?我有不同的环境,具有不同的配置,我想在部署定义中放置公共部分,只有不同的部分是configmapI建议使用更高级别的解决方案,允许对kube中创建的资源进行模板化,这样您就可以使用helm值修改每个环境的配置。