Use a PVC

Updated at:

After you create a PersistentVolumeClaim (PVC), you can use it when you create a pod.

Important

  • Cloud disks cannot be mounted across zones. If you create a PVC with volumeBindingMode set to Immediate, you must use nodeSelector or nodeAffinity. This ensures that any pod or workload that uses the PVC runs in the same zone as the underlying PersistentVolume (PV).

  • In the Agile Platform as a Service (PaaS) environment, AKS is not integrated with Alibaba Cloud NAS or cloud disk storage. To use storage features, you must install a third-party storage plugin.

Procedure

  1. Log on to the Containerized Application Service console. In the navigation pane on the left, click Workloads > Pods.

  2. On the Pods page, click Create from YAML.

  3. Enter the YAML content in the editor and click Submit.

    apiVersion: v1
    kind: Pod
    metadata:
      name: pod-with-disk
      labels:
        app: nginx
    spec:
      tolerations:
      - key: node.kubernetes.io/unreachable
        effect: NoSchedule
        operator: Exists
      automountServiceAccountToken: false
      containers:
      - name: busybox
        image: reg-cnsh-nf.cloud.alipay.com/library/busybox
        command: ["sleep", "3000"]
        ports:
        - containerPort: 80
        volumeMounts:
          - name: data
            mountPath: "/data"
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: test-pvc

After the container starts, the pod status changes to Running.

# kubectl get pod
NAME            READY   STATUS    RESTARTS   AGE
pod-with-disk   1/1     Running   0          103s