有奖捉虫:云通信与企业服务文档专题,速来> HOT

操作场景

CBS-CSI 组件 支持 TKE 集群通过控制台快捷选择存储类型,并创建对应块存储云硬盘类型的 PV 和 PVC。本文提供 CBS-CSI 组件功能特性等说明并介绍几种常见示例用法。

功能特性

功能
说明
静态数据卷
支持手动创建 Volume、PV 对象及 PVC 对象。
动态数据卷
支持通过 StorageClass 配置、创建和删除 Volume 及 PV 对象。
存储拓扑感知
云硬盘不支持跨可用区挂载,在多可用区集群中,CBS-CSI 组件将先调度 Pod,后调度 Node 的 zone 创建 Volume。
调度器感知节点 maxAttachLimit
腾讯云单个云服务器上默认最多挂载20块云硬盘,调度器调度 Pod 时将过滤超过最大可挂载云硬盘数量的节点。
卷在线扩容
支持通过修改 PVC 容量字段,实现在线扩容(仅支持云硬盘类型)。
卷快照和恢复
支持通过快照创建数据卷。

组件说明

CBS-CSI 组件在集群内部署后,包含以下组件:
DaemonSet:每个 Node 提供一个 DaemonSet,简称为 NodePlugin。由 CBS-CSI Driver 和 node-driver-registrar 两个容器组成,负责向节点注册 Driver,并提供挂载能力。
StatefulSet 和 Deployment:简称为 Controller。由 Driver 和多个 Sidecar(external-provisioner、external-attacher、external-resizer、external-snapshotter、snapshot-controller)一起构成,提供创删卷、attach、detach、扩容、快照等能力。
示例图如下:



限制条件

TKE 集群版本 ≥ 1.14
使用 CBS-CSI 组件后,才可在 TKE 集群中为云硬盘在线扩容和创建快照。
已经使用 QcloudCbs(In-Tree 插件)的 TKE 集群,可以继续正常使用。(后续将通过 Volume Migration 统一到 CBS-CSI)
CBS-CSI 组件版本 ≥ 1.0.4,支持原生节点。

cbs-csi 权限

说明:
权限场景章节中仅列举了组件核心功能涉及到的相关权限,完整权限列表请参考权限定义章节。

权限说明

该组件权限是当前功能实现的最小权限依赖。
需要挂载主机 /var/lib/kubelet 相关目录到容器来完成 volume 的 mount/umount,所以需要开启特权级容器。

权限场景

功能
涉及对象
涉及操作权限
获取 node 资源中 providerID 来感知节点最大可挂盘数量
node
get/list
根据 pvc/pv 等信息完成盘的创建和删除
pv/pvc/storageclasses/csinode
get/list/watch/create/update/patch/delete
根据 volumeattachments 资源对象来完成盘的挂载和卸载
volumeattachments/volumesnapshotclasses
create/get/list/watch/update/delete
对盘进行扩容快照
pod/volumesnapshotclasses/volumesnapshots/configmap
get/list/watch

权限定义

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cbs-csi-controller-role
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update", "patch", "create", "delete"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: [""]
resources: ["persistentvolumeclaims/status"]
verbs: ["update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["storageclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["events"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["csi.storage.k8s.io"]
resources: ["csinodeinfos"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["volumeattachments", "volumeattachments/status"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotclasses"]
verbs: ["get", "list", "watch"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents"]
verbs: ["create", "get", "list", "watch", "update", "delete"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots"]
verbs: ["get", "list", "watch", "update"]
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["create", "list", "watch", "delete"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshotcontents/status"]
verbs: ["update"]
- apiGroups: ["snapshot.storage.k8s.io"]
resources: ["volumesnapshots/status"]
verbs: ["update"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "watch", "update", "patch", "create", "delete"]
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: cbs-csi-node-role
namespace: kube-system
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list"]

使用示例