Helm /bitnami/spark - 如何将文件加载到 extraVolumeMounts?

sam*_*mba 5 configuration apache-spark google-cloud-platform kubernetes-helm

我正在使用Helm 图表将 Spark 部署到 GCE 中的 Kubernetes。我已在value.yamlextraVolumes中配置了和,并且它们在部署过程中已成功创建。extraVolumeMounts

在图表部署期间将文件添加到这些卷的正确方法是什么?

  ## Array to add extra volumes
  extraVolumes:
    - name: spark-volume

  ## Array to add extra mounts (normally used with extraVolumes)
  extraVolumeMounts:
    - name: spark-volume
      mountPath: /tmp/new-data
Run Code Online (Sandbox Code Playgroud)

Cro*_*rou 9

取决于文件在哪里。如果您将它们放在存储库中,我会使用initContainer来克隆它。

这可能看起来像这样:

    initContainers:
      - name: git-clone-spark-volumes
        image: alpine/git
        args:
          - clone
          - --single-branch
          - --branch=master
          - --depth=1
          - --
          - https://github.com/your/repo.git
          - /tmp/new-data
        securityContext:
          runAsUser: 0
        volumeMounts:
          - name: spark-volume
            mountPath: /tmp/new-data
    extraVolumes:
      - name: spark-volume
        emptyDir: {}
    extraVolumeMounts:
      - name: spark-volume
        mountPath: /tmp/new-data
Run Code Online (Sandbox Code Playgroud)

这会将存储库 ( https://github.com/your/repo.git ) 克隆到/tmp/new-data文件夹中,安装到 Spark-volume 的位置。

如果您的文件key=value基于您可以使用ConfigMap

$ kubectl create configmap spark-volume --from-file=configure-pod-container/configmap/game.properties --from-file=configure-pod-container/configmap/ui.properties
Run Code Online (Sandbox Code Playgroud)

可以使用哪些:

    extraVolumes:
      - name: spark-volume
        configMap:
          name: spark-volume
    extraVolumeMounts:
      - name: spark-volume
        mountPath: /tmp/new-data
Run Code Online (Sandbox Code Playgroud)

配置 Pod 以使用 ConfigMap对此进行了很好的描述。