CCE allows you to use an existing SFS Turbo volume to create a StatefulSet.
You have created a CCE cluster and installed the CSI plug-in (everest) in the cluster.
The following configuration example applies to clusters of Kubernetes 1.15 or later.
touch sfsturbo-statefulset-example.yaml
vi sfsturbo-statefulset-example.yaml
Configuration example:
apiVersion: apps/v1 kind: StatefulSet metadata: name: sfsturbo-statefulset-example namespace: default spec: replicas: 1 selector: matchLabels: app: sfsturbo-statefulset-example template: metadata: labels: app: sfsturbo-statefulset-example spec: volumes: - name: pvc-sfsturbo-example persistentVolumeClaim: claimName: pvc-sfsturbo-example containers: - name: container-0 image: 'nginx:latest' volumeMounts: - name: pvc-sfsturbo-example mountPath: /tmp restartPolicy: Always imagePullSecrets: - name: default-secret serviceName: sfsturbo-statefulset-example-headless updateStrategy: type: RollingUpdate
Parameter |
Description |
---|---|
replicas |
Number of pods. |
name |
Name of the new workload. |
image |
Image used by the workload. |
mountPath |
Mount path of a container. |
serviceName |
Service corresponding to the workload. For details about how to create a Service, see Creating a StatefulSet. |
claimName |
Name of an existing PVC. |
spec.template.spec.containers.volumeMounts.name and spec.template.spec.volumes.name must be consistent because they have a mapping relationship.
kubectl create -f sfsturbo-statefulset-example.yaml
kubectl get po | grep sfsturbo-statefulset-example
Expected outputs:
sfsturbo-statefulset-example-0 1/1 Running 0 2m5s
kubectl exec sfsturbo-statefulset-example-0 -- mount|grep /tmp
Expected outputs:
192.168.0.108:/ on /tmp type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,noresvport,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.0.108,mountvers=3,mountport=20048,mountproto=tcp,local_lock=all,addr=192.168.0.108)
kubectl exec sfsturbo-statefulset-example-0 -- touch /tmp/test
kubectl exec sfsturbo-statefulset-example-0 -- ls -l /tmp
Expected outputs:
-rw-r--r-- 1 root root 0 Jun 1 02:50 test
kubectl delete po sfsturbo-statefulset-example-0
kubectl get po
Expected outputs:
sfsturbo-statefulset-example-0 1/1 Running 0 2m
kubectl exec sfsturbo-statefulset-example-0 -- ls -l /tmp
Expected outputs:
-rw-r--r-- 1 root root 0 Jun 1 02:50 test
The test file still exists after the pod is rebuilt, indicating that the data in the SFS Turbo volume can be persistently stored.