当前位置:主页 > 查看内容

使用subpath类型动态创建SFS Turbo存储卷_云容器引擎 CCE_最佳实

发布时间:2021-09-23 00:00| 位朋友查看

简介:约束与限制 该实践内容目前仅适用于 华东-上海二 和 华南-广州 局点,其他局点暂不支持。 使用subpath类型动态创建SFS Turbo存储卷 该特性仅支持1.15+集群,使用everest插件,插件版本要求1.1.13+。 当前版本未对前端进行适配,前端调用可能存在未知错误,su……

约束与限制

该实践内容目前仅适用于华东-上海二华南-广州局点,其他局点暂不支持。

使用subpath类型动态创建SFS Turbo存储卷

该特性仅支持1.15+集群,使用everest插件,插件版本要求1.1.13+。

当前版本未对前端进行适配,前端调用可能存在未知错误,subpath模式的卷请勿通过前端进行“扩容”、“解关联”、“删除”等操作。

  1. 创建SFS turbo资源,选择网络时,请选择与集群相同的vpc与子网。
  2. 新建一个sc的yaml文件,例如sfsturbo-sc-test.yaml。

    配置示例:

    apiVersion: storage.k8s.io/v1
    allowVolumeExpansion: true
    kind: StorageClass
    metadata:
      name: sfsturbo-sc-test
    mountOptions:
    - nolock=false
    parameters:
      csi.storage.k8s.io/csi-driver-name: sfsturbo.csi.everest.io
      csi.storage.k8s.io/fstype: nfs
      everest.io/archive-on-delete: "true"
      everest.io/share-access-to: 7ca2dba2-1234-1234-1234-626371a8fb3a
      everest.io/share-expand-type: bandwidth
      everest.io/share-export-location: 192.168.1.1:/sfsturbo/
      everest.io/share-source: sfs-turbo
      everest.io/share-volume-type: STANDARD
      everest.io/volume-as: subpath
      everest.io/volume-id: 0d773f2e-1234-1234-1234-de6a35074696
    provisioner: everest-csi-provisioner
    reclaimPolicy: Delete
    volumeBindingMode: Immediate

    其中:

    • name:storageclass的名称。
    • mountOptions:选填字段;mount挂载参数,目前仅开发对nolock参数配置,如果没有mountOptions或者是nolock设置为ture,mount操作会默认使用nolock参数。nolock参数为false时,使用lock参数。
    • everest.io/volume-as:该参数需设置为“subpath”来使用subpath模式。
    • everest.io/share-access-to:选填字段。subpath模式下,填写SFS Turbo资源的所在VPC的ID。
    • everest.io/share-expand-type:选填字段。若SFS Turbo资源存储类型为增强版(标准型增强版、性能型增强版),设置为bandwidth。
    • everest.io/share-export-location:挂载根配置。由SFS Turbo共享路径和子目录组成,共享路径可知SFS Turbo服务页面查询,子路径由用户自定义,后续指定改sc创建的pvc均位于该子目录下。
    • everest.io/share-volume-type:选填字段。填写SFS Turbo的类型。标准型为STANDARD,性能型为PERFORMANCE。对于增强型需配合“everest.io/share-expand-type”字段使用,标准型增强版需要将该字段设置为STANDARD同时设置everest.io/share-expand-type为“bandwidth”。
    • everest.io/zone:选填字段。指定SFS Turbo资源所在的可用区。
    • everest.io/volume-id:SFS Turbo资源的卷ID,可至SFS Turbo界面查询。
    • everest.io/archive-on-delete:若该参数设置为“true”,在回收策略为“Delete”时,删除pvc会将pv的原文档进行归档,归档目录的命名规则“archived-$pv名称.时间戳”,为“false”时,会将pv对应的SFS Turbo子目录删除。默认进行归档。

  1. 执行kubectl create -f sfsturbo-sc-test.yaml
  2. 新建一个pvc的yaml文件,sfs-turbo-test.yaml。

    配置示例:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: sfs-turbo-test
      namespace: default
    spec:
      accessModes:
      - ReadWriteMany
      resources:
        requests:
          storage: 50Gi
      storageClassName: csi-sfsturbo-test
      volumeMode: Filesystem

    其中:

    • name: PVC的名称。
    • storageClassName:SC的名称。
    • storage:subpath模式下,该参数无实际意义,容量受限于Turbo资源的总容量,若Turbo资源总容量不足,请及时到Turbo界面扩容。

  1. 执行kubectl create -f sfs-turbo-test.yaml

对subpath类型的SFS Turbo扩容时,没有实际的扩容意义。该操作不会对SFS Tubor资源进行实际的扩容,需要用户自行保证Turbo的总容量不被耗尽。

创建Deployment挂载已有数据卷

  1. 新建一个deployment的yaml文件,deployment-test.yaml。

    配置示例:
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: test-turbo-subpath-example
      namespace: default
      generation: 1
      labels:
        appgroup: ''
    spec: 
      replicas: 1 
      selector: 
        matchLabels: 
          app: test-turbo-subpath-example 
      template: 
        metadata: 
          labels: 
            app: test-turbo-subpath-example 
        spec: 
          containers: 
          - image: nginx:latest 
            name: container-0 
            volumeMounts: 
            - mountPath: /tmp
              name: pvc-sfs-turbo-example 
          restartPolicy: Always 
          imagePullSecrets:
          - name: default-secret
          volumes: 
          - name: pvc-sfs-turbo-example 
            persistentVolumeClaim: 
              claimName: sfs-turbo-test

    其中:

    • name:创建的工作负载名称。
    • image:工作负载的镜像。
    • mountPath:容器内挂载路径,示例中挂载到“/tmp”路径。
    • claimName:已有的pvc名称。

  1. kubectl create -f deployment-test.yaml创建deployment负载。

Statefulset动态创建subpath模式的数据卷

  1. 新建一个statefulset的yaml文件,statefulset-test.yaml。

    配置示例:

    apiVersion: apps/v1
    kind: StatefulSet
    metadata:
      name: test-turbo-subpath
      namespace: default
      generation: 1
      labels:
        appgroup: ''
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: test-turbo-subpath
      template:
        metadata:
          labels:
            app: test-turbo-subpath
          annotations:
            metrics.alpha.kubernetes.io/custom-endpoints: '[{"api":"","path":"","port":"","names":""}]'
            pod.alpha.kubernetes.io/initialized: 'true'
        spec:
          containers:
            - name: container-0
              image: 'nginx:latest'
              env:
                - name: PAAS_APP_NAME
                  value: deploy-sfs-nfs-rw-in
                - name: PAAS_NAMESPACE
                  value: default
                - name: PAAS_PROJECT_ID
                  value: 8190a2a1692c46f284585c56fc0e2fb9
              resources: {}
              volumeMounts:
                - name: sfs-turbo-160024548582479676
                  mountPath: /tmp
              terminationMessagePath: /dev/termination-log
              terminationMessagePolicy: File
              imagePullPolicy: IfNotPresent
          restartPolicy: Always
          terminationGracePeriodSeconds: 30
          dnsPolicy: ClusterFirst
          securityContext: {}
          imagePullSecrets:
            - name: default-secret
          affinity: {}
          schedulerName: default-scheduler
      volumeClaimTemplates:
        - metadata:
            name: sfs-turbo-160024548582479676
            namespace: default
            annotations: {}
          spec:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 10Gi
            storageClassName: sfsturbo-sc-test
      serviceName: wwww
      podManagementPolicy: OrderedReady
      updateStrategy:
        type: RollingUpdate
      revisionHistoryLimit: 10

    其中:

    • name:创建的工作负载名称。
    • image:工作负载的镜像。
    • mountPath:容器内挂载路径,示例中挂载到“/tmp”路径。
    • “spec.template.spec.containers.volumeMounts.name ”和 “spec.volumeClaimTemplates.metadata.name”有映射关系,必须保持一致。
    • storageClassName: 填写自建的sc名称。

  1. kubectl create -f statefulset-test.yaml创建statefulset负载。

本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!
上一篇:DescribeScalingActivityDetail - 弹性伸缩 下一篇:没有了

推荐图文

  • 周排行
  • 月排行
  • 总排行

随机推荐