All Documents
Current Document

Content is empty

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

Documentation

EBS volumes

Last updated:2021-04-14 15:43:55

You can use EBS volumes in KSK.

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

Static volume

Instructions

  1. An EBS volume does not support shared storage and can only be mounted to a single KCI pod. The number of replicas must be set to 1.

  2. Before you use a static volume, you must create an EBS volume in the EBS console and obtain the volume ID.

  3. The volume name and PV name must be the same as the volume ID.

  4. An EBS volume can only be mounted to a KCI pod in the same availability zone.

  5. File systems ext3, ext4, and xfs are supported.

Directly use volumes

In the following nginx-disk-deploy.yaml file, the EBS volume specified in the YAML file is mounted to the /data path of the nginx-flexvolume-disk container in the pod.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-disk-deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx-flexvolume-disk
        image: nginx
        volumeMounts:
          - name: "db1bd24b-609b-4f3d-9b16-96249a809023"
            mountPath: "/data"
      volumes:
        - name: "db1bd24b-609b-4f3d-9b16-96249a809023"
          flexVolume:
            driver: "ksc/ebs"
            fsType: "ext4"
            options:
              volumeId: "db1bd24b-609b-4f3d-9b16-96249a809023"

Use PVs or PVCs

Define a PV.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: "db1bd24b-609b-4f3d-9b16-96249a809023"
spec:
  capacity:
    storage: 20Gi
  storageClassName: disk
  accessModes:
    - ReadWriteOnce
  flexVolume:
    driver: "ksc/ebs"
    fsType: "ext4"
    options:
      volumeId: "db1bd24b-609b-4f3d-9b16-96249a809023"

Define a PVC.

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-disk
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: disk
  resources:
    requests:
      storage: 20Gi

Create a Deployment.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-disk-deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx--disk
        image: nginx
        volumeMounts:
        - name: pvc-disk
          mountPath: "/data"
      volumes:
      - name: pvc-disk
        persistentVolumeClaim:
          claimName: pvc-disk

Dynamic volume

You need to manually create a StorageClass for a dynamic volume and specify the StorageClass name in a PVC.

Create a StorageClass

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: ssd30
provisioner: ksc/ebs
parameters:
  type: SSD3.0
  zone: cn-beijing-6b # Optional #
  chargetype: Daily

Parameter description:

  • provisioner: Set the value to ksc/ebs, indicating that the Kingsoft Cloud provisioner plug-in is used.
  • reclaimPolicy: the reclaim policy of the EBS volume. Default value: Delete. You can set this parameter to Retain to retain the EBS volume.
  • type: the type of the EBS volume. This parameter is required. Valid values: SSD2.0, SSD3.0, SATA2.0, and SATA3.0.
  • zone: the availability zone of the EBS volume. This parameter is optional. Note that EBS volume types that can be created vary with the availability zones. For more information, see Limits. If the availability zone is not specified, the EBS volume is created in one of the availability zones where nodes in the cluster reside.
  • chargetype: the billing mode of the EBS volume. Default value: Daily. For more information, see the chargetype field in CreateVolume.
  • purchasetime: If you select the Subscription billing mode, you must set the purchase period, in months.

Create a Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        volumeMounts:
        - name: pvc-disk
          mountPath: "/data"
      volumes:
      - name: pvc-disk
        persistentVolumeClaim:
          claimName: nginx-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nginx-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: ssd30
  resources:
    requests:
      storage: 20Gi
On this page
Pure ModeNormal Mode

Pure Mode

Click to preview the document content in full screen
Feedback