All Documents
Current Document

Content is empty

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

Documentation

Use KFS volumes

Last updated:2021-05-11 10:41:17

You can use KFS volumes in Kubernetes clusters of KCE.

Kingsoft Cloud provides the following methods for you to mount KFS volumes to Kubernetes:

Prerequisites

A KFS file system is created before the file system can be mounted.

Instructions

  1. KFS can provide shared storage services for multiple pods simultaneously. A PVC can be used by multiple pods.
  2. Do not delete the mount target of the file system before you unmount the file system. Otherwise, the operating system will not respond.
  3. KFS dynamic volumes can be directly used in clusters created on February 24, 2021 or later. To use KFS 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

image.png In the preceding figure:

The server version is 10.0.1.***.

The mount path is ** /***-7EVaUh33Wd /mnt.

Static volume

Directly use volumes

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kfs
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        volumeMounts:
          - name: "kfs"
            mountPath: "/data"
      volumes:
        - name: "kfs"
          nfs: 
            server: "10.0.1.x"
            path: "/share-2c51940a-6261-4044-addc-xxxxxxx"

Use PVs or PVCs

Create a PV:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: kfs-pv
spec:
  storageClassName: "kfs"
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteMany
  mountOptions:
    - nfsvers=3
  nfs:
    server: 10.0.1.x
    path: "/share-2c51940a-6261-4044-addc-xxxxxxx"

Create a PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: kfs-pvc
spec:
  storageClassName: "kfs"
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Mi

Create a deployment:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kfs-deploy
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        volumeMounts:
        - name: kfs
          mountPath: "/data"
      volumes:
      - name: kfs
        persistentVolumeClaim:
          claimName: kfs-pvc

Dynamic volume

Parameter description

Parameter Description
server The IP address of the KFS server. This parameter is required.
path The mount directory of the KFS volume. A mount directory is automatically created if no sub-directory is available. This parameter is required.
archiveOnDelete The way of processing the KFS volume mount directory when a PVC or a PV is deleted. If reclaimPolicy is set to Delete and archiveOnDelete is set to false, the mount directory and data are directly deleted. Use this setting with caution. If reclaimPolicy is set to Delete and archiveOnDelete is set to true, the mount directory is deleted and a mount directory backup is created with another name. If reclaimPolicy is set to Retain, the mount directory is retained without modifications. This parameter is optional. The default value is false.
storageType The storage type. Set the value to ksc/kfs, indicating that KFS is used. This parameter is required.

Create a StorageClass:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ksc-kfs
parameters:
  server: 10.0.1.xx
  path: /cfs-AyQaA3xxxx/test-path
  archiveOnDelete: "false"
  storageType: ksc/kfs
provisioner: ksc/storage

Create a StatefulSet:

apiVersion:  apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  serviceName: test
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx
          volumeMounts:
            - name: www
              mountPath: "/data"
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes:
      - ReadWriteOnce
      storageClassName: ksc-kfs
      resources:
        requests:
          storage: 10Gi

Appendix

The YAML file of the disk-provisioner component is as follows:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: disk-provisioner
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: disk-provisioner
  replicas: 1
  revisionHistoryLimit: 2
  template:
    metadata:
      labels:
        app: disk-provisioner
    spec:
      dnsPolicy: Default
      tolerations:
        # this taint is set by all kubelets running `--cloud-provider=external`
        - key: "node.cloudprovider.kubernetes.io/uninitialized"
          value: "true"
          effect: "NoSchedule"
      containers:
      - image: hub-cn-shanghai-2.kce.ksyun.com/ksyun/disk-provisioner:v1.6.0
        name: ebs-provisioner
        env:
        - name: OPENAPI_ENDPOINT
          value: "internal.api.ksyun.com"
        - name: OPENAPI_PREFIX
          value: "http"
        volumeMounts:
          - name: kubeconfig
            mountPath: /root/.kube/config
          - name: clusterinfo
            mountPath: /opt/app-agent/arrangement/clusterinfo
      - image: hub-cn-shanghai-2.kce.ksyun.com/ksyun/disk-provisioner:v1.6.0
        name: ksc-storage-provisioner
        securityContext:
          privileged: true   # do mount
        args:
        - --provisioner=ksc/storage
        env:
        - name: OPENAPI_ENDPOINT
          value: "internal.api.ksyun.com"
        - name: OPENAPI_PREFIX
          value: "http"
        volumeMounts:
          - name: kubeconfig
            mountPath: /root/.kube/config
          - name: clusterinfo
            mountPath: /opt/app-agent/arrangement/clusterinfo
      volumes:
        - name: kubeconfig
          hostPath:
            path: /root/.kube/config
        - name: clusterinfo
          hostPath:
            path: /opt/app-agent/arrangement/clusterinfo
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback