如何在Kubernetes中挂载单个非配置文件?

时间:2020-07-25 21:01:41

标签: kubernetes

我有一个部署,需要从主机读取许可证文件。许可证文件是文本文件(不是Yaml配置)。我知道我们可以在部署中挂载ConfigMap,但afaik ConfigMap只是Yaml格式。

将单个文件挂载到部署中的最佳方法是什么?

1 个答案:

答案 0 :(得分:3)

您可以从任何文件创建configmap:

kubectl create configmap <map-name> --from-file=file.cfg

然后,您可以将configmap挂载到您的Pod:

volumes:
  - name: config
    configMap:
      name: mapName
volumeMounts:
  - name: config
    mountPath: /dir/file.cfg
    subPath: file.cfg