【3】为kubeflow配置默认的StorageClass

背景

  • 如果没有配置默认的StorageClass,kubeflow在创建notebook时会提示“No default Storage Class is set. Can't create new Disks for the new Notebook. Please use an Existing Disk.”
  • 此时选择volume时,需要现在集群中手动创建pv, pvc,然后才可使用;


    image.png

实现方法

  • 参考:https://blog.51cto.com/wks97/2173503
  • 这里使用nfs作为provisioner,需要先安装插件,nfs安装在上一篇文章【2】Kubeflow安装(新)
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: nfs-provisioner
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nfs-provisioner
    spec:
      serviceAccount: nfs-client-provisioner
      containers:
        - name: nfs-provisioner
          image: registry.cn-hangzhou.aliyuncs.com/open-ali/nfs-client-provisioner
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: kubeflow/nfs
            - name: NFS_SERVER
              value: 172.16.32.33 # 需要修改为自己的nfs server
            - name: NFS_PATH
              value: /data/kubeflow # 需要修改为自己的nfs path
      volumes:
        - name: nfs-client-root
          nfs:
            server: 172.16.32.33 # 需要修改为自己的nfs server
            path: /data/kubeflow # 需要修改为自己的nfs server
  • 如果集群使用了rbac,则需要创建
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    namespace: kubeflow-anonymous
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["list", "watch", "create", "update", "patch"]
  • 创建StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: kubeflow-nfs-storage
provisioner: kubeflow/nfs
  • 将新创建的StorageClass设为默认
# 这里的 `` 是您选择的 StorageClass 的名字。
kubectl patch storageclass  -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
  • 完成之后,则可使用“NEW” 来创建volume


    image.png

你可能感兴趣的:(【3】为kubeflow配置默认的StorageClass)