docs
uk8s
Cluster Management
Manage Cluster via Kubectl
Create PVC

Create PVC

The current storage volume supports SSD, SATA type UDisk and UFS, please refer to:

Create StorageClass

Before creating a persistent storage volume (persistentVolume), you need to create a StorageClass first, then use the StorageClassName in PVC.

UK8S cluster create two StorageClasses by default. you can also create a new StorageClass. Here is an example and description:

1、CSI version (UK8S clusters created after September 17, 2019)

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: udisk-ssd-test
provisioner: udisk.csi.ucloud.cn #Storage supplier, this cannot be changed.
parameters:
  type: "ssd"   # Storage medium, support sdd and sata, required
  fsType: "ext4"    # File system, required
  udataArkMode: "no"   # Whether to enable Ark mode, the default is not enabled, optional
  chargeType: "month" # Payment type, supports dynamic, month, year, default is month, optional
  quantity: "1" # Purchase duration, dynamic does not need to be filled in, can purchase 1-9 months, or 1-10 years
reclaimPolicy: Delete  # PV recovery policy, supports Delete and Retain, default is Delete, optional
allowVolumeExpansion: true # Declare that this storage class supports expandable features
mountOptions:
  - debug
  - rw

Note: Before the Kubernetes version 1.15, mountOptions cannot be used normally, please do not fill in, please refer to Issue80191 (opens in a new tab)

2、flexVolume version (UK8S clusters created before September 17, 2019)

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: udisk-ssd-test
provisioner: ucloud/udisk
parameters:
  type: ssd
reclaimPolicy: Retain

provisioner: Storage providers must set as ucloud/udisk, otherwise the created StorageClass may be invalid.

parameters.type: It's the storage medium type of UDisk, which supports SSD and SATA. SSD is set by default.

reclaimPolicy: It's recovery policy, which supports Delete and Retain. The default setting is to delete.

Create a volume claim and Mount it to Pod

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-pvc-claim
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: udisk-ssd-test #Be sure to modify it to the StorageClassName you created
  resources:
    requests:
      storage: 20Gi
 
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
    - name: test
      mountPath: /data
    ports:
    - containerPort: 80
  volumes:
  - name: test
    persistentVolumeClaim:
      claimName: test-pvc-claim

Note: Due to the limitations of the UDisk product, the minimum PVC is 20GB, and the step size is 10GB.

After the container starts, we can log in to the container to execute the df -h command to check whether the storage volume is successfully mounted.

  • Company
  • ContactUs
  • Blog
Copyright © 2024 SurferCloud All Rights Reserved