All Documents
Current Document

Content is empty

If you don't find the content you expect, please try another search term

Documentation

Use KPFS volumes

Last updated:2021-05-25 17:26:04

You can use KPFS volumes in Kubernetes clusters of KCE.

You can use KPFS volumes by using one of the following two methods:

Background

KPFS is a high-performance file storage system developed by Kingsoft Cloud for high-performance computing. KPFS enables business applications with a high aggregate bandwidth and high Input/Output Operations Per Second (IOPS) to read and write data within milliseconds. KPFS provides high-performance file storage with a high throughput and high IOPS, and adopts a scalable and fully managed design, enabling you to quickly develop business applications and focus on business innovation.

Prerequisites

A KPFS file system is created before the file system can be mounted. You can create a file system in the KPFS console.

Instructions

  1. KPFS can provide shared storage services for multiple pods simultaneously. A PVC can be used by multiple pods.
  2. The KPFS client must be installed on a node before KPFS can be used.
  3. KPFS can be directly used in clusters created on December 15, 2020 or later. To use KPFS in clusters created before December 15, 2020, update the image of the ksc-flexvolume-ds component in the clusters to hub.kce.ksyun.com/ksyun/ksc-flexvolume:v1.8.2-mp. To update the image, run the following command:

    kubectl set image ds/ksc-flexvolume-ds ksc-flexvolume-ds=hub.kce.ksyun.com/ksyun/ksc-flexvolume:v1.8.2-mp --record -n kube-system 
  4. KPFS dynamic volumes can be directly used in clusters created on February 24, 2021 or later. To use KPFS dynamic volumes in clusters created before February 24, 2021, update the disk-provisioner component in the kube-system namespace of the clusters. For more information about the YAML file, see Appendix.

View a file system

After creating a KPFS file system, you can view the information and obtain the conrresponding server address of the KPFS file system in the KPFS console.

Static volume

Parameter description

Parameter Description
server The mount target of the KPFS file system.
fileSystem The name of the KPFS file system.
subPath The mount sub-directory of the KPFS file system, relative to the root directory of the KPFS file system.

Directly use volumes

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: static-kpfs-dep
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx-flexvolume-kpfs
          image: nginx
          volumeMounts:
            - name: kpfs-test
              mountPath: "/data"
      volumes:
        - name: kpfs-test
          flexVolume:
            driver: "ksc/kpfs"
            options:
              server: 10.0.1.xx
              fileSystem: kpfs-xxxxxxx
              subPath: /test-dep  # This parameter is optional.

Use PVs or PVCs

Create a PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: static-kpfs-pv
spec:
  capacity:
    storage: 5Gi
  storageClassName: static-kpfs-pv
  accessModes:
    - ReadWriteMany
  flexVolume:
    driver: "ksc/kpfs"
    options:
      server: 10.0.1.47
      fileSystem: kpfs-xxxxxx
      subPath: /test1-dep

Create a PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: static-kpfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: static-kpfs-pv
  resources:
    requests:
      storage: 5Gi

Create a Deployment:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: static-kpfs-dep
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx-flexvolume-disk
          image: nginx
          volumeMounts:
            - name: kpfs-test
              mountPath: "/data"
      volumes:
        - name: kpfs-test
          persistentVolumeClaim:
            claimName: static-kpfs-pvc

Dynamic volume

Parameter description

Parameter Description
server The mount target of the KPFS file system. This parameter is required.
fileSystem The name of the KPFS file system. This parameter is required.
subPath The mount sub-directory of the KPFS file system, relative to the root directory of the KPFS file system. This parameter is optional.
archiveOnDelete The way of processing the sub-directory of the KPFS file system when a PVC or a PV is deleted. If reclaimPolicy is set to Delete and archiveOnDelete is set to false, the sub-directory and data are directly deleted. Use this setting with caution. If reclaimPolicy is set to Delete and archiveOnDelete is set to true, the sub-directory is deleted and a sub-directory backup is created with another name. If reclaimPolicy is set to Retain, the sub-directory is retained without modifications. This parameter is optional. The default value is false.
storageType The storage type. Set the value to ksc/kpfs, indicating that KPFS is used. This parameter is required.

Create a StorageClass:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ksc-kpfs
parameters:
  server: "10.0.1.xx"
  fileSystem: "kpfs-xxxxx"
  subPath: provisioner-kpfs
  archiveOnDelete: "true"
  storageType: ksc/kpfs
provisioner: ksc/storage

Create a StatefulSet:

apiVersion:  apps/v1
kind: StatefulSet
metadata:
  name: test-sts
spec:
  serviceName: test
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx
          volumeMounts:
            - name: pvc-disk
              mountPath: "/data"
  volumeClaimTemplates:
  - metadata:
      name: pvc-disk
    spec:
      accessModes:
      - ReadWriteOnce
      storageClassName: ksc-kpfs
      resources:
        requests:
          storage: 10Gi
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback