如何通过 ConfigMap 在 k8 部署中提供 NFS 挂载服务器的值

How to supply a value of a server in NFS mount in a k8 Deployment via a ConfigMap

我正在写一个 helm chart,我需要从 ConfigMap (efs-url 在下面的例子中)。

文档中有关于如何将值从 ConfigMap 传递到环境变量甚至挂载 ConfigMaps 的示例。我了解如何从 values.yaml 传递此值,但我找不到有关如何使用 ConfigMap.

完成此操作的示例

我可以控制这个 ConfigMap 所以我可以根据需要重新格式化它。

  1. 我是不是遗漏了一些非常明显的东西?
  2. 甚至可以做到吗?
  3. 如果没有,可能的解决方法是什么?
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: efs-url
data:
  url: yourEFSsystemID.efs.yourEFSregion.amazonaws.com

---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: efs-provisioner
spec:
  replicas: 1
  strategy:
    type: Recreate 
  template:
    metadata:
      labels:
        app: efs-provisioner
    spec:
      containers:
        - name: efs-provisioner
          image: quay.io/external_storage/efs-provisioner:latest
          env:
            - name: FILE_SYSTEM_ID
              valueFrom:
                configMapKeyRef:
                  name: efs-provisioner
                  key: file.system.id
            - name: AWS_REGION
              valueFrom:
                configMapKeyRef:
                  name: efs-provisioner
                  key: aws.region
            - name: PROVISIONER_NAME
              valueFrom:
                configMapKeyRef:
                  name: efs-provisioner
                  key: provisioner.name
          volumeMounts:
            - name: pv-volume
              mountPath: /persistentvolumes
      volumes:
        - name: pv-volume
          nfs:
            server:  <<< VALUE SHOULD COME FROM THE CONFIG MAP >>>
            path: /

经过分析,使用 ConfigMap 方法的评论似乎不适合此示例,因为 ConfigMap

is an API object used to store non-confidential data in key-value pairs. Pods can consume ConfigMaps as environment variables, command-line arguments, or as configuration files in a volume.

要了解更多关于 ConfigMaps 以及如何使用它们的信息,可以访问 "ConfigMaps" section and the "Configure a Pod to Use a ConfigMap" section