如何在 kubeflow 中为用户 pvc 指定存储 class
How to specify a storage class to user pvc in kubeflow
我正在尝试将存储 class 附加到个人用户 pods 为 kubeflow 中的 jupyter 笔记本创建的所有 PVC 请求。
我尝试编辑一些值并指定 storage_class。但是 none 它正在工作,每当出现新的 pvc 时它都没有存储 class 名称。
期望的结果是每当用户 pods 的 pvc 出现时,它应该附有存储名称 class。请帮忙解决这个问题。我从昨天开始卡住了
您的集群中需要有默认存储 class,因此如果 pvc 未指定任何存储 class,则将选择默认存储。
列出集群中的 StorageClasses:
kubectl get storageclass
将 StorageClass 标记为默认值:
设置注释 storageclass.kubernetes.io/is-default-class=true.
kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
这里是详细步骤change-default-storage-class
While PersistentVolumeClaims allow a user to consume abstract storage resources, it is common that users need PersistentVolumes with varying properties, such as performance, for different problems.
Cluster administrators need to be able to offer a variety of PersistentVolumes that differ in more ways than just size and access modes, without exposing users to the details of how those volumes are implemented. For these needs there is the StorageClass resource.
A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes.
apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume
labels:
type: local
spec:
storageClassName: <name_of_your_StorageClass>
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
A PersistentVolumeClaim (PVC) is a request for storage by a user.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: task-pv-claim
spec:
storageClassName: <name_of_your_StorageClass>
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Then you can create a Pod that uses your PVC as a volume(which uses PV with storageClass)
apiVersion: v1
kind: Pod
metadata:
name: task-pv-pod
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim
containers:
- name: task-pv-container
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storage
Before you are going to create a PV and PVC StorageClass must already exist, if it's not a default one will be used instead.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: <name_of_your_StorageClass>
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Retain
allowVolumeExpansion: true
mountOptions:
- debug
volumeBindingMode: Immediate
您可以使用此命令检查您的 StorageClasses:
kubectl get sc
我正在尝试将存储 class 附加到个人用户 pods 为 kubeflow 中的 jupyter 笔记本创建的所有 PVC 请求。
我尝试编辑一些值并指定 storage_class。但是 none 它正在工作,每当出现新的 pvc 时它都没有存储 class 名称。
期望的结果是每当用户 pods 的 pvc 出现时,它应该附有存储名称 class。请帮忙解决这个问题。我从昨天开始卡住了
您的集群中需要有默认存储 class,因此如果 pvc 未指定任何存储 class,则将选择默认存储。
列出集群中的 StorageClasses:
kubectl get storageclass
将 StorageClass 标记为默认值: 设置注释 storageclass.kubernetes.io/is-default-class=true.
kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
这里是详细步骤change-default-storage-class
While PersistentVolumeClaims allow a user to consume abstract storage resources, it is common that users need PersistentVolumes with varying properties, such as performance, for different problems. Cluster administrators need to be able to offer a variety of PersistentVolumes that differ in more ways than just size and access modes, without exposing users to the details of how those volumes are implemented. For these needs there is the StorageClass resource.
A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes.
apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume
labels:
type: local
spec:
storageClassName: <name_of_your_StorageClass>
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
A PersistentVolumeClaim (PVC) is a request for storage by a user.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: task-pv-claim
spec:
storageClassName: <name_of_your_StorageClass>
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
Then you can create a Pod that uses your PVC as a volume(which uses PV with storageClass)
apiVersion: v1
kind: Pod
metadata:
name: task-pv-pod
spec:
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim
containers:
- name: task-pv-container
image: nginx
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storage
Before you are going to create a PV and PVC StorageClass must already exist, if it's not a default one will be used instead.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: <name_of_your_StorageClass>
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp2
reclaimPolicy: Retain
allowVolumeExpansion: true
mountOptions:
- debug
volumeBindingMode: Immediate
您可以使用此命令检查您的 StorageClasses:
kubectl get sc