1

我使用以下代码创建了一个集群

from dask_kubernetes import KubeCluster
cluster = KubeCluster.from_yaml('worker.yaml')
cluster.adapt(minimum=1, maximum=10)

使用以下 yaml 代码 ( worker.yaml):

kind: Pod
metadata:
  labels:
    foo: bar
spec:
  restartPolicy: Never
  containers:
  - image: daskdev/dask:latest
    imagePullPolicy: IfNotPresent
    args: [dask-worker, --nthreads, '4', --no-bokeh, --memory-limit,  3GB, --death-timeout, '300']
    name: dask
    resources:
      limits:
        cpu: "4"
        memory: 3G
      requests:
        cpu: "2"
        memory: 2G

这按预期工作。现在我添加了一个卷挂载,如图所示

kind: Pod
metadata:
  labels:
    foo: bar
spec:
  restartPolicy: Never
  containers:
  - image: daskdev/dask:latest
    imagePullPolicy: IfNotPresent
    args: [dask-worker, --nthreads, '4', --no-bokeh, --memory-limit,  3GB, --death-timeout, '300']
    name: dask
    resources:
      limits:
        cpu: "4"
        memory: 3G
      requests:
        cpu: "2"
        memory: 2G
    volumeMounts:
    - name: somedata
      mountPath: /opt/some/data
  volumes:
  - name: somedata
    azureFile:
      secretName: azure-secret
      shareName: somedata
      readOnly: true

我没有看到已安装卷。但是当我简单地跑

kubectl create -f worker.yaml

我可以看到卷已安装。

是否KubeCluster支持卷挂载?如果是这样,您如何配置它们?

4

1 回答 1

0

使用卷进行测试时,我无法重现您的问题HostPath

from dask_kubernetes import KubeCluster
cluster = KubeCluster.from_yaml('worker.yaml')
cluster.adapt(minimum=1, maximum=10)
# worker.yaml
kind: Pod
metadata:
  labels:
    foo: bar
spec:
  restartPolicy: Never
  containers:
  - image: daskdev/dask:latest
    imagePullPolicy: IfNotPresent
    args: [dask-worker, --nthreads, '4', --no-bokeh, --memory-limit,  3GB, --death-timeout, '300']
    name: dask
    resources:
      limits:
        cpu: "4"
        memory: 3G
      requests:
        cpu: "2"
        memory: 2G
    volumeMounts:
    - name: somedata
      mountPath: /opt/some/data
  volumes:
  - name: somedata
    hostPath:
      path: /tmp/data
      type: Directory

如果我kubectl describe po <podname>为创建的工作人员运行,我可以看到成功创建的卷。

Volumes:
  somedata:
    Type:          HostPath (bare host directory volume)
    Path:          /tmp/data
    HostPathType:  Directory

它安装在我期望的位置。

    Mounts:
      /opt/some/data from somedata (rw)

此外,如果我在容器中创建一个 shell kubectl exec -it <podname> bashls /opt/some/data我可以看到我在主机路径中创建的文件。

因此KubeCluster, volumes 可以与azureFile.

于 2020-05-26T09:52:05.883 回答