CCE allows you to use an existing SFS Turbo volume to create a StatefulSet.
You have created a CCE cluster and installed the FlexVolume plug-in (storage-driver) in the cluster.
The following configuration example applies to clusters of Kubernetes 1.13 or earlier.
touch efs-statefulset-example.yaml
vi efs-statefulset-example.yaml
Example YAML:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: efs-statefulset-example
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: efs-statefulset-example
template:
metadata:
annotations:
metrics.alpha.kubernetes.io/custom-endpoints: '[{"api":"","path":"","port":"","names":""}]'
pod.alpha.kubernetes.io/initialized: 'true'
labels:
app: efs-statefulset-example
spec:
containers:
- image: 'nginx:1.0.0'
name: container-0
resources:
requests: {}
limits: {}
env:
- name: PAAS_APP_NAME
value: efs-statefulset-example
- name: PAAS_NAMESPACE
value: default
- name: PAAS_PROJECT_ID
value: b18296881cc34f929baa8b9e95abf88b
volumeMounts:
- name: efs-statefulset-example
mountPath: /tmp
readOnly: false
subPath: ''
imagePullSecrets:
- name: default-secret
terminationGracePeriodSeconds: 30
volumes:
- persistentVolumeClaim:
claimName: cce-efs-import-jnr481gm-3y5o
name: efs-statefulset-example
affinity: {}
tolerations:
- key: node.kubernetes.io/not-ready
operator: Exists
effect: NoExecute
tolerationSeconds: 300
- key: node.kubernetes.io/unreachable
operator: Exists
effect: NoExecute
tolerationSeconds: 300
podManagementPolicy: OrderedReady
serviceName: test
updateStrategy:
type: RollingUpdate
Parameter |
Description |
|---|---|
replicas |
Number of pods. |
name |
Name of the created workload. |
image |
Image used by the workload. |
mountPath |
Mount path in the 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 efs-statefulset-example.yaml