(kubectl) Creating a StatefulSet Mounted with an OBS Volume
Scenario
CCE allows you to use an existing OBS volume to create a StatefulSet through a PersistentVolumeClaim (PVC).
Notes and Constraints
The following configuration example applies to clusters of Kubernetes 1.13 or earlier.
Procedure
- Create an OBS volume by referring to (kubectl) Automatically Creating an OBS Volume and obtain the PVC name.
- Use kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
- Create a YAML file for creating the workload. Assume that the file name is obs-statefulset-example.yaml.
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
Table 1 Key parameters 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.
- Create the StatefulSet.
kubectl create -f obs-statefulset-example.yaml
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot