文档

StatefulSet 挂载动态存储卷

更新时间:

说明

目前敏捷 PaaS 底座环境下,AKS 未对接阿里云的 NAS 及云盘存储,若要使用存储功能,需要您安装第三方存储插件。

前提条件

使用 NAS 创建多实例 StatefulSet

Yaml 样例如下:

apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "<指定已有的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

使用云盘创建多实例 StatefulSet

Yaml 样例如下:

apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "<指定已有的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

参数说明请参考 挂载动态存储卷

  • 本页导读 (0)