全部产品
云市场

StatefulSet 挂载动态存储卷

更新时间:2019-08-30 17:07:03

前提条件

使用 NAS 创建多实例 StatefulSet

Yaml 样例如下:

  1. apiVersion: apps/v1beta2
  2. kind: StatefulSet
  3. metadata:
  4. name: web
  5. spec:
  6. selector:
  7. matchLabels:
  8. app: nginx
  9. serviceName: "<指定已有的Service>"
  10. replicas: 2
  11. template:
  12. metadata:
  13. labels:
  14. app: nginx
  15. spec:
  16. containers:
  17. - name: nginx
  18. image: nginx
  19. ports:
  20. - containerPort: 80
  21. name: web
  22. volumeMounts:
  23. - name: csi-nas-pvc
  24. mountPath: /data
  25. volumeClaimTemplates:
  26. - metadata:
  27. name: csi-nas-pvc
  28. spec:
  29. accessModes: [ "ReadWriteOnce" ]
  30. storageClassName: "csi-nas-capacity"
  31. resources:
  32. requests:
  33. storage: 25G

使用云盘创建多实例 StatefulSet

Yaml 样例如下:

  1. apiVersion: apps/v1beta2
  2. kind: StatefulSet
  3. metadata:
  4. name: web
  5. spec:
  6. selector:
  7. matchLabels:
  8. app: nginx
  9. serviceName: "<指定已有的Service>"
  10. replicas: 2
  11. template:
  12. metadata:
  13. labels:
  14. app: nginx
  15. spec:
  16. containers:
  17. - name: nginx
  18. image: nginx
  19. ports:
  20. - containerPort: 80
  21. name: web
  22. volumeMounts:
  23. - name: disk-efficiency
  24. mountPath: /data
  25. volumeClaimTemplates:
  26. - metadata:
  27. name: disk-efficiency
  28. spec:
  29. accessModes: [ "ReadWriteOnce" ]
  30. storageClassName: "csi-disk-efficiency"
  31. resources:
  32. requests:
  33. storage: 25G

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