Found 0 result in total
Content is empty
If you don't find the content you expect, please try another search term
Last updated:2021-11-11 17:43:13
You can use EBS volumes in Kubernetes clusters of KCE. An EBS volume can be mounted to the specified path in a container as a static volume. If the container is migrated, the EBS volume is migrated with the container.
Kingsoft Cloud provides the following methods for you to mount EBS volumes to Kubernetes:
Static volume
You can use EBS static volumes by using one of the following two methods:
An EBS volume does not support shared storage and can only be mounted to a single pod. The number of replicas must be set to 1.
Before you use a static volume, you must create an EBS volume in the EBS console and obtain the volume ID.
The volume name and PV name must be the same as the volume ID.
An EBS volume can only be mounted to a cluster node in the same availability zone.
File systems ext3, ext4, and xfs are supported.
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: "b5c80953-1499-40ff-918a-4d6d4dfbfddd"
mountPath: "/data"
volumes:
- name: "b5c80953-1499-40ff-918a-4d6d4dfbfddd"
flexVolume:
driver: "ksc/ebs"
fsType: "ext4"
options:
volumeId: "b5c80953-1499-40ff-918a-4d6d4dfbfddd"
Define a PV:
apiVersion: v1
kind: PersistentVolume
metadata:
name: "b5c80953-1499-40ff-918a-4d6d4dfbfddd"
spec:
capacity:
storage: 20Gi
storageClassName: disk
accessModes:
- ReadWriteOnce
flexVolume:
driver: "ksc/ebs"
fsType: "ext4"
options:
volumeId: "b5c80953-1499-40ff-918a-4d6d4dfbfddd"
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-flexvolume-disk
image: nginx
volumeMounts:
- name: pvc-disk
mountPath: "/data"
volumes:
- name: pvc-disk
persistentVolumeClaim:
claimName: pvc-disk
You need to manually create a StorageClass for a dynamic volume and specify the StorageClass name in a PVC.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ssd30
provisioner: ksc/ebs
parameters:
type: SSD3.0
zone: cn-beijing-6b # This parameter is optional. #
chargetype: Daily
Parameter description:
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
Pure Mode