Attach a dynamically provisioned volume to a StatefulSet

Updated at:

Note

Currently, AKS in the Agile Platform as a Service (PaaS) environment is not integrated with Alibaba Cloud NAS or disks. To use the storage feature, you must install a third-party storage plugin.

Prerequisites

Create a multi-instance StatefulSet using NAS

Sample YAML:

apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "<Specify an existing service>"
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: csi-nas-pvc
          mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: csi-nas-pvc
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "csi-nas-capacity"
      resources:
        requests:
          storage: 25G

Create a multi-instance StatefulSet using a disk

Sample YAML:

apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "<Specify an existing service>"
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: disk-efficiency
          mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: disk-efficiency
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "csi-disk-efficiency"
      resources:
        requests:
          storage: 25G

For more information about the parameters, see Attach a dynamically provisioned volume.