(kubectl) Creating a Deployment Mounted with an SFS Volume
Scenario
After an SFS volume is created or imported to CCE, you can mount the volume to a workload.
Prerequisites
You have created a CCE cluster and installed the CSI plug-in (everest) in the cluster.
Notes and Constraints
The following configuration example applies to clusters of Kubernetes 1.15 or later.
Procedure
- Use kubectl to connect to the cluster. For details, see Connecting to a Cluster Using kubectl.
- Run the following commands to configure the sfs-deployment-example.yaml file, which is used to create a pod.
touch sfs-deployment-example.yaml
vi sfs-deployment-example.yaml
Example of mounting an SFS volume to a Deployment (PVC-based, shared volume):apiVersion: apps/v1 kind: Deployment metadata: name: sfs-deployment-example # Workload name namespace: default spec: replicas: 1 selector: matchLabels: app: sfs-deployment-example template: metadata: labels: app: sfs-deployment-example spec: containers: - image: nginx name: container-0 volumeMounts: - mountPath: /tmp # Mount path name: pvc-sfs-example imagePullSecrets: - name: default-secret restartPolicy: Always volumes: - name: pvc-sfs-example persistentVolumeClaim: claimName: pvc-sfs-auto-example # PVC name
spec.template.spec.containers.volumeMounts.name and spec.template.spec.volumes.name must be consistent because they have a mapping relationship.
- Run the following command to create a pod:
kubectl create -f sfs-deployment-example.yaml
After the creation is complete, log in to the CCE console. In the navigation pane, choose Resource Management > Storage > SFS. Then, click the PVC name. On the PVC details page, you can view the binding relationship between SFS and PVC.
Related Operations
Last Article: (kubectl) Creating a PV from an Existing SFS File System
Next Article: (kubectl) Creating a StatefulSet Mounted with an SFS Volume
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.