简体   繁体   English

如何在kubeflow中为用户pvc指定存储类

[英]How to specify a storage class to user pvc in kubeflow

I am trying to attach a storage class to all the PVC request created by individual user pods for jupyter notebooks in kubeflow. 我正在尝试将存储类附加到单个用户吊舱为kubeflow中的jupyter笔记本创建的所有PVC请求中。

I tried editing some values and specify storage_class. 我尝试编辑一些值并指定storage_class。 but none of it is working, whenever a new pvc comes up it doesnot come with a storage class name. 但是它们都不起作用,每当出现新的pvc时,它都不会带有存储类名称。

The desired result is whenever a pvc of user pods comes, it should have the name of storage class attached with it. 期望的结果是,每当有一个用户pod的pvc出现时,它都应该附带存储类的名称。 Kindly help with this. 请对此提供帮助。 I am stuck from last day 我被困在最后一天

you need to have a default storage class in your cluster, so if a pvc does not specify any storage class then default one would be selected. 您需要在群集中具有默认存储类,因此,如果pvc没有指定任何存储类,则将选择默认存储类。

List the StorageClasses in your cluster: 列出集群中的StorageClasses:

kubectl get storageclass

Mark a StorageClass as default: set the annotation storageclass.kubernetes.io/is-default-class=true. 将StorageClass标记为默认值:设置注释storageclass.kubernetes.io/is-default-class=true。

kubectl patch storageclass <your-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

Here are the detail steps change-default-storage-class 这是详细步骤change-default-storage-class

Basing on documentation 基于文档

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. 虽然PersistentVolumeClaims允许用户使用抽象存储资源,但是对于不同的问题,用户通常需要具有不同属性(例如性能)的PersistentVolume 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. 集群管理员需要能够提供各种PersistentVolume ,这些PersistentVolume不仅在大小和访问模式上有更多差异,而且还不让用户了解如何实现这些卷的细节。 For these needs there is the StorageClass resource. 对于这些需求,有StorageClass资源。

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. PersistentVolume (PV)是群集中的一块存储,已由管理员提供或使用存储类动态提供。

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. PersistentVolumeClaim (PVC)是用户存储请求。

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) 然后,您可以创建一个将PVC用作卷的Pod(将PV与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. 在创建PV和PVC之前, StorageClass必须已经存在,如果不是默认值,则将使用它。

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

You can check your StorageClasses with this command: 您可以使用以下命令检查StorageClasses:

kubectl get sc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM