全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

K8S CSI 部署

最近更新时间:2025-02-25 14:42:42

Helm方式部署

  1. 创建Helm应用

    前往容器服务,在Helm 应用页面,选择集群,单击新建按钮。

  2. 配置应用信息

    选择Chart来源,Ksyun Helm Chart:

  3. 更新helm values文件

    编辑 values.yaml,更新values.yaml中的secret部分及kubeletdir参数。

    ---
    driver:
      name: "kingstoragenas.csi.kingsoftcloud.com"
      attachRequired: false
    ofs:
      name: "kingstorage"
      secretName: "kingstorage-backend"
    serviceAccount:
      create: true
    secret:
      MngtServer: "10.x.x.x"
      MngtPort: 8443
      account: "accountname"
      secret: "secretkey"
      StoragePool: "storage_pool"
      FileSystemVolume: "defaultfs"
      AccessZoneID: 1
      AuthProviderID: 4
      BusinessVIPDomainName: "nas1.xxxx.ksyuncs.com"
      DNSserver: ""
      IAMSystem: "02"
      FSType: "02"
    images:
      imagePullPolicy: "IfNotPresent"
      provisioner: "hub.kce.ksyun.com/nas-s/csi/csi-provisioner:2.2.0"
      resizer: "hub.kce.ksyun.com/nas-s/csi/csi-resizer:1.2.0"
      livenessprobe: "hub.kce.ksyun.com/nas-s/csi/csi-livenessprobe:2.3.0"
      snapshotter: "hub.kce.ksyun.com/nas-s/csi/csi-snapshotter:4.1.0"
      attacher: "hub.kce.ksyun.com/nas-s/csi/csi-attacher:3.2.1"
      registrar: "hub.kce.ksyun.com/nas-s/csi/csi-node-driver-registrar:2.2.0"
      csi: "hub.kce.ksyun.com/nas-s/csi/kingstorage-nas-s-csi:1.7.4"
    controller:
      runOnMaster: false
      runOnControlPlane: false
      healthPort: 29652
      affinity: {}
      nodeSelector: {}
    node:
      healthPort: 29653
      affinity: {}
      nodeSelector: {}
    kubeletDir: "/data/kubelet"
    skipIAM: false

    参数

    说明

    MngtServer

    存储管理地址,请联系金山云技术团队获取

    MngtPort

    8443,默认端口,无需改动

    account

    存储集群特权用户,请联系您的存储管理员获取该用户名

    secret

    存储集群用户名对应编码规则创建的密码,使用echo -n "password" | base64 命令获取。

    请联系您的存储管理员获取该密码

    StoragePool

    数据存储池名称。在本环境中使用 storage_pool

    FileSystemVolume

    文件卷名称。根据使用的文件系统指定

    默认文件系统,如果PV指定文件系统,即指定的文件系统生效,不指定时,使用默认文件系统。

    AccessZoneID

    访问区ID,请联系您的存储管理员获取

    AuthProviderID

    认证服务器ID,请联系您的存储管理员获取

    BusinessVIPDomainName

    访问域名,请联系您的存储管理员获取

    DNSserver

    DNS域名,主要用于特殊公网DNS解析,本环境不需要

    IAMSystem

    访问IAM类型。金山IAM:02

    kubeletDir

    填写实际的kubelet目录,本例中为/data/kubelet

    skipIAM

    是否使用金山云IAM做挂载鉴权检查,建议设定为True。

  4. 部署服务

    单击确定,完成CSI部署。

    如下图所示,待所有容器都处于running时,驱动部署完成。

    kubectl get pod -A|grep csi-king

脚本方式部署

首次安装需要下载完整的安装包,该安装包中有csi运行容器镜像以及基础配置(含secret.yaml/部署脚本),后续升级版本只需要下载csi运行容器镜像即可。

建议将安装包下载到有kubectl且有需部署kubernetes集群操作权限的节点。

  1. 下载部署脚本

    wget https://nas-s-bj.ks3-cn-beijing.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_b040843_20241115_091019_linux_amd64.tar.gz

    地域

    外网下载地址

    内网下载地址

    华北1(北京亦庄)

    cn-beijing-6

    https://nas-s-bj.ks3-cn-beijing.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_b040843_20241115_091019_linux_amd64.tar.gz

    https://nas-s-bj.ks3-cn-beijing-internal.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_b040843_20241115_091019_linux_amd64.tar.gz

    华东2(宁波)

    cn-ningbo-1

    https://nas-s-nb.ks3-cn-ningbo.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_67bce72_20241123_093405_linux_amd64.tar.gz

    https://nas-s-nb.ks3-cn-ningbo-internal.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_67bce72_20241123_093405_linux_amd64.tar.gz

    西北1(庆阳)

    cn-northwest-1

    https://nas-s-qy.ks3-cn-qingyang.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_67bce72_20241123_093405_linux_amd64.tar.gz

    https://nas-s-qy.ks3-cn-qingyang-internal.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_67bce72_20241123_093405_linux_amd64.tar.gz

    西北3(宁夏)

    cn-northwest-3

    https://nas-s-nx.ks3-cn-ningxia.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_b040843_20241115_091019_linux_amd64.tar.gz

    https://nas-s-nx.ks3-cn-ningxia-internal.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_b040843_20241115_091019_linux_amd64.tar.gz

    西北4(海东)

    cn-northwest-4

    西北5(克拉玛依)

    cn-northwest-5

    https://nas-s-qh.ks3-cn-qinghai.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_67bce72_20241123_093405_linux_amd64.tar.gz

    https://nas-s-qh.ks3-cn-qinghai-internal.ksyuncs.com/ofs_csidriver_1.7.4_feature_ofs3.1.3_jscloud_main_without_flash_csi_helm_67bce72_20241123_093405_linux_amd64.tar.gz

    CSI sidercar公共组件容器镜像

    插件运行依赖的CSI sidecar公共组件容器镜像作为第三方容器镜像,没有直接包含在插件软件包中,需要用户通过公共渠道获取有关的镜像,也可联系我们的对应支持人员。目前kingstorage k8s CSI驱动插件部署所依赖的CSI sidecar公共组件容器镜像一览如下(根据后续支持情况更新):

    容器名

    版本

    说明

    项目链接

    csi-provisioner

    2.2.0

    负责耦合卷的动态供给管理

    https://hub.kce.ksyun.com/nas-s/csi/csi-provisioner

    csi-resizer

    1.2.0

    负责耦合卷的扩容管理

    https://hub.kce.ksyun.com/nas-s/csi/csi-resizer

    csi-attacher

    3.2.1

    负责耦合卷的挂载管理

    https://hub.kce.ksyun.com/nas-s/csi/csi-attacher

    csi-snapshotter

    4.1.0

    负责耦合卷的快照管理

    https://hub.kce.ksyun.com/nas-s/csi/csi-snapshotter

    csi-livenessprobe

    2.3.0

    负责组件健康状态监测

    https://hub.kce.ksyun.com/nas-s/csi/livenessprobe

    node-driver-registrar

    2.2.0

    负责驱动插件到kubelet的注册

    https://hub.kce.ksyun.com/nas-s/csi/csi-node-driver-registrar

  2. 修改部署脚本参数

    2.1 CSI驱动目录下deploy中secrets.yaml

    ---
    apiVersion: v1
    kind: Secret
    metadata:
           name: kingsoftcloud-backend
           namespace: kube-system
    stringData:
         MngtServer: "10.x.x.x"
         MngtPort: "8443"
         account: xxadmin
         secret:   xxxxxx
         StoragePool: storage_pool
         FileSystemVolume:  filesystemname
         AccessZoneID: "1"
         AuthProviderID: "4"
         BusinessVIPDomainName: "example.kingstorage.kingsoftcloud.com" 
         DNSserver: ""
        IAMSystem: "02"
        FSType: "02"

    参数

    说明

    MngtServer

    存储管理地址,请联系金山云技术团队获取

    MngtPort

    8443,默认端口,无需改动

    account

    存储集群特权用户,请联系您的存储管理员获取该用户名

    secret

    存储集群用户名对应编码规则创建的密码,使用echo -n "password" | base64 命令获取。

    请联系您的存储管理员获取该密码

    StoragePool

    数据存储池名称。在本环境中使用 storage_pool

    FileSystemVolume

    文件卷名称。根据使用的文件系统指定

    默认文件系统,如果PV指定文件系统,即指定的文件系统生效,不指定时,使用默认文件系统。

    AccessZoneID

    访问区ID,请联系您的存储管理员获取

    AuthProviderID

    认证服务器ID,请联系您的存储管理员获取

    BusinessVIPDomainName

    访问域名,请联系您的存储管理员获取

    DNSserver

    DNS域名,主要用于特殊公网DNS解析,本环境不需要

    IAMSystem

    访问IAM类型。金山IAM:02

    FSType

    存储服务类型:(存储版本相关)

    01:313 定制 Kingstorage

    02:412d storage

    03:402v3 parastor

    该类型可以通过任意posix客户端执行mount,查看对应文件系统的挂载类型后的内容判断。

    请联系您的存储管理员获取合适值。

    2.2 CSI controller 对应的 deploy/csi-kingstorage-controller.yaml

    注:供您参考,请结合Kubernetes集群实际情况修改相应参数

    ---
    kind: Deployment
    apiVersion: apps/v1
    metadata:
      name: csi-kingstorage-controller
      namespace: kube-system
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: csi-kingstorage-controller
      template:
        metadata:
          labels:
            app: csi-kingstorage-controller
        spec:
          hostNetwork: true  # controller also needs to mount kingstorage to create dir
          dnsPolicy: ClusterFirstWithHostNet
          serviceAccountName: csi-kingstorage-controller-sa
          nodeSelector:
            kubernetes.io/os: linux  # add "kubernetes.io/role: master" to run controller on master node
          priorityClassName: system-cluster-critical
          #tolerations:
          #  - key: "node-role.kubernetes.io/master"
          #   operator: "Equal"
          #   value: "true"
          #   effect: "NoSchedule"
          # - key: "node-role.kubernetes.io/controlplane"
          #   operator: "Equal"
          #   value: "true"
          #   effect: "NoSchedule"
          containers:
            - name: csi-provisioner
              image: hub.kce.ksyun.com/nas-s/csi/csi-provisioner:2.2.0
              imagePullPolicy: IfNotPresent
              args:
                - "-v=2"
                - "--csi-address=$(ADDRESS)"
                - "--leader-election"
              env:
                - name: ADDRESS
                  value: /csi/csi.sock
              volumeMounts:
                - mountPath: /csi
                  name: socket-dir
              resources:
                limits:
                  cpu: 100m
                  memory: 400Mi
                requests:
                  cpu: 10m
                  memory: 20Mi
            - name: csi-resizer
              image: hub.kce.ksyun.com/nas-s/csi/csi-resizer:1.2.0
              imagePullPolicy: "IfNotPresent"
              args:
                - "--v=5"
                - "--csi-address=$(ADDRESS)"
                - "--leader-election"
              env:
                - name: ADDRESS
                  value: /csi/csi.sock
              volumeMounts:
                - name: socket-dir
                  mountPath: /csi
            - name: liveness-probe
              image: hub.kce.ksyun.com/nas-s/csi/csi-livenessprobe:2.3.0
              imagePullPolicy: IfNotPresent
              args:
                - --csi-address=/csi/csi.sock
                - --probe-timeout=3s
                - --health-port=29752
                - --v=2
              volumeMounts:
                - name: socket-dir
                  mountPath: /csi
              resources:
                limits:
                  cpu: 100m
                  memory: 100Mi
                requests:
                  cpu: 10m
                  memory: 20Mi
            - name: csi-snapshotter
              image: hub.kce.ksyun.com/nas-s/csi/csi-snapshotter:4.1.0
              args:
                - "--csi-address=$(ADDRESS)"
                - "--v=5"
                - "--timeout=150s"
                - "--leader-election=true"
              env:
                - name: ADDRESS
                  value: unix:///csi/csi.sock
              imagePullPolicy: "IfNotPresent"
              securityContext:
                privileged: true
              volumeMounts:
                - name: socket-dir
                  mountPath: /csi
            - name: csi-attacher
              image: hub.kce.ksyun.com/nas-s/csi/csi-attacher:3.2.1
              args:
                - "--v=5"
                - "--csi-address=$(ADDRESS)"
                - "--leader-election=true"
                - "--retry-interval-start=500ms"
              env:
                - name: ADDRESS
                  value: /csi/csi.sock
              imagePullPolicy: "IfNotPresent"
              volumeMounts:
                - name: socket-dir
                  mountPath: /csi
            - name: kingstorage
              image: hub.kce.ksyun.com/nas-s/csi/kingstorage-nas-s-csi:1.7.4
              imagePullPolicy: IfNotPresent
              securityContext:
                privileged: true
                capabilities:
                  add: ["SYS_ADMIN"]
                allowPrivilegeEscalation: true
              args:
                - "--v=5"
                - "--nodeid=$(NODE_ID)"
                - "--nodeip=$(NODE_HOSTIP)"
                - "--endpoint=$(CSI_ENDPOINT)"
              env:
                - name: NODE_ID
                  valueFrom:
                    fieldRef:
                      fieldPath: spec.nodeName
                - name: NODE_HOSTIP
                  valueFrom:
                    fieldRef:
                      fieldPath: status.hostIP
                - name: CSI_ENDPOINT
                  value: unix:///csi/csi.sock
              ports:
                - containerPort: 29752
                  name: healthz
                  protocol: TCP
              livenessProbe:
                failureThreshold: 5
                httpGet:
                  path: /healthz
                  port: healthz
                initialDelaySeconds: 30
                timeoutSeconds: 10
                periodSeconds: 30
              volumeMounts:
                - name: pods-mount-dir
                  mountPath: /data/kubelet/pods
                  mountPropagation: "Bidirectional"
                - mountPath: /csi
                  name: socket-dir
                - name: secrets
                  mountPath: /secrets
                  readOnly: true
              resources:
                limits:
                  cpu: 200m
                  memory: 200Mi
                requests:
                  cpu: 10m
                  memory: 20Mi
          volumes:
            - name: secrets
              secret:
                secretName: kingsoftcloud-backend
            - name: pods-mount-dir
              hostPath:
                path: /data/kubelet/pods
                type: Directory
            - name: socket-dir
              emptyDir: {}

    2.3 CSI Node 对应的 deploy/csi-kingstorage-node.yaml

    注:供您参考,请结合Kubernetes集群实际情况修改相应参数

    ---
    # This YAML file contains driver-registrar & csi driver nodeplugin API objects
    # that are necessary to run CSI nodeplugin for kingstorage
    kind: DaemonSet
    apiVersion: apps/v1
    metadata:
      name: csi-kingstorage-node
      namespace: kube-system
    spec:
      selector:
        matchLabels:
          app: csi-kingstorage-node
      template:
        metadata:
          labels:
            app: csi-kingstorage-node
        spec:
          hostNetwork: true  # original kingstorage connection would be broken without hostNetwork setting
          dnsPolicy: Default
          nodeSelector:
            kubernetes.io/os: linux
          tolerations:
            - operator: "Exists"
          containers:
            - name: liveness-probe
              image:     hub.kce.ksyun.com/nas-s/csi/livenessprobe:2.3.0
              imagePullPolicy: IfNotPresent
              args:
                - --csi-address=/csi/csi.sock
                - --probe-timeout=3s
                - --health-port=29753
                - --v=2
              volumeMounts:
                - name: socket-dir
                  mountPath: /csi
              resources:
                limits:
                  cpu: 100m
                  memory: 100Mi
                requests:
                  cpu: 10m
                  memory: 20Mi
            - name: node-driver-registrar
              image: hub.kce.ksyun.com/nas-s/csi/csi-node-driver-registrar:2.2.0
              imagePullPolicy: IfNotPresent
              lifecycle:
                preStop:
                  exec:
                    command: ["/bin/sh", "-c", "rm -rf /registration/csi-kingstorage-csi /registration/csi-kingstorage-csi-reg.sock"]
              args:
                - --v=2
                - --csi-address=/csi/csi.sock
                - --kubelet-registration-path=/data/kubelet/plugins/csi-kingstorage-csi/csi.sock
              env:
                - name: KUBE_NODE_NAME
                  valueFrom:
                    fieldRef:
                      fieldPath: spec.nodeName
              volumeMounts:
                - name: socket-dir
                  mountPath: /csi
                - name: registration-dir
                  mountPath: /registration
            - name: kingstorage
              securityContext:
                privileged: true
                capabilities:
                  add: ["SYS_ADMIN"]
                allowPrivilegeEscalation: true
              image: hub.kce.ksyun.com/nas-s/csi/kingstorage-nas-s-csi:1.7.4
              imagePullPolicy: IfNotPresent
              args:
                - "-v=5"
                - "--nodeid=$(NODE_ID)"
                - "--nodeip=$(NODE_HOSTIP)"
                - "--endpoint=$(CSI_ENDPOINT)"
              env:
                - name: NODE_ID
                  valueFrom:
                    fieldRef:
                      fieldPath: spec.nodeName
                - name: NODE_HOSTIP
                  valueFrom:
                    fieldRef:
                      fieldPath: status.hostIP
                - name: CSI_ENDPOINT
                  value: unix:///csi/csi.sock
              ports:
                - containerPort: 29753
                  name: healthz
                  protocol: TCP
              livenessProbe:
                failureThreshold: 5
                httpGet:
                  path: /healthz
                  port: healthz
                initialDelaySeconds: 30
                timeoutSeconds: 10
                periodSeconds: 30
              volumeMounts:
                - name: socket-dir
                  mountPath: /csi
                - name: pods-mount-dir
                  mountPath: /data/kubelet/pods
                  mountPropagation: "Bidirectional"
                - name: mnt-dir
                  mountPath: /mnt
                  mountPropagation: "Bidirectional"
                - name: secrets
                  mountPath: /secrets
                  readOnly: true
          volumes:
            - name: socket-dir
              hostPath:
                path: /data/kubelet/plugins/csi-kingstorage-csi
                type: DirectoryOrCreate
            - name: pods-mount-dir
              hostPath:
                path: /data/kubelet/pods
                type: Directory
            - name: mnt-dir
              hostPath:
                path: /mnt
                type: Directory
            - hostPath:
                path: /data/kubelet/plugins_registry
                type: Directory
              name: registration-dir
            - name: secrets
              secret:
                secretName: kingsoftcloud-backend

  3. 部署CSI

cd  deploy
./kingstorage-csi.sh install
#卸载
./kingstorage-csi.sh uninstall

如下图所示,待所有容器都处于running时,驱动部署完成。

kubectl get pod -A|grep csi-king

纯净模式常规模式

纯净模式

点击可全屏预览文档内容