CCE allows you to use an existing OBS volume to create a StatefulSet through a PersistentVolumeClaim (PVC).
The following configuration example applies to clusters of Kubernetes 1.13 or earlier.
touch obs-statefulset-example.yaml
vi obs-statefulset-example.yaml
Example YAML:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: obs-statefulset-example
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: obs-statefulset-example
serviceName: qwqq
template:
metadata:
annotations:
metrics.alpha.kubernetes.io/custom-endpoints: '[{"api":"","path":"","port":"","names":""}]'
pod.alpha.kubernetes.io/initialized: "true"
creationTimestamp: null
labels:
app: obs-statefulset-example
spec:
affinity: {}
containers:
image: nginx:latest
imagePullPolicy: Always
name: container-0
volumeMounts:
- mountPath: /tmp
name: pvc-obs-example
imagePullSecrets:
- name: default-secret
volumes:
- name: pvc-obs-example
persistentVolumeClaim:
claimName: cce-obs-demo
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. |
kubectl create -f obs-statefulset-example.yaml