From c73ae71b4b6f147377cf30d714e2178d3ce702ea Mon Sep 17 00:00:00 2001 From: Wenbin Yu Date: Thu, 12 Dec 2024 18:17:52 +0800 Subject: [PATCH] fix: typo Signed-off-by: Wenbin Yu --- ...24\347\224\250\345\217\202\350\200\203.md" | 187 ++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 "docs/knowledge_base/CSI/CSI\345\272\224\347\224\250\345\217\202\350\200\203.md" diff --git "a/docs/knowledge_base/CSI/CSI\345\272\224\347\224\250\345\217\202\350\200\203.md" "b/docs/knowledge_base/CSI/CSI\345\272\224\347\224\250\345\217\202\350\200\203.md" new file mode 100644 index 0000000..aac2639 --- /dev/null +++ "b/docs/knowledge_base/CSI/CSI\345\272\224\347\224\250\345\217\202\350\200\203.md" @@ -0,0 +1,187 @@ + +# 前言 + +本文档从细节入手,比较多种不同存储驱动,主要提供给产品PM、研发和测试人员进行参考。 + +--- + +## 2. 存储资源 + +### 2.1 StorageClass + +```yaml +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: csi-cephfs-sc +provisiner: cephfs.csi.ceph.com +parameters: + key: value +reclaimPolicy: Delete +allowVolumeExpansion: true +volumeBidingMode: Immediate +allowedTopologies: +- matchLabelExpressions: + - key: failure-domain.beta.kubernetes.io/zone + values: + - us-central1-a # 保留 PV 的一种方式 +``` + +--- + +### 2.2 PersistentVolumeClaim + +```yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: csi-cephfs-pvc + namesapce: default +spec: + accessModes: + - ReedWriteMany + resorces: + requests: + storage: 2Gi + volmeMode: Filesystem + VolumeName: pvc-xxxxxx # 绑定 PV 自动填充 +``` + +--- + +### 2.3 PersistentVolume + +```yaml +apiVersion: v1 +kind: PersistentVolume +metadata: + annotations: + pv.kubernetes.io/provisioned-by: cephfs.csi.ceph.com + finalizers: + - kubernetes.io/pv-protection # 保护机制 +spec: + capcity: + storage: 2Gi + nodaAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - node01 # 分配到任何节点 +``` + +--- + +## 3. CSI资源 + +### 3.1 CSIDriver + +```yaml +apiVersion: storage.k8s.io/v1beta1 +kind: CSIDriver +metadata: + name: rook-ceph.cephfs.csi.ceph.com +spec: + attchRequired: true + podinfoOnMount: false + volumeLifecycleModes: # 一个生命周期设置 + - Persistent +``` + +--- + +## 4. 各个 CSI 驱动能力列表 + +| 村储能力 | Ceph FS CSI | Ceph rbd CSI | +| -------------- | ----------- | ------------ | +| 支 持 | 支持 | 支持 | +| 圈创建快照 | 支持 | 支持 | + +--- + +## 5. 测试资源 + +### 5.1 PersistentVolumeClaim + +```yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: rbd-pvc +spec: + storageClasName: csi-rbd-sc + reqests: + storage: 1Gi + volumeMode: Block # 一种模式 +``` + +--- + +### 5.2 Deployment + +```yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: csi-cephfs-demo-depl +spec: + replicas: 1 + template: + spec: + containers: + - name: web-server + image: docker.io/library/nginx:latest + command: ["/bin/sleep", "infinity"] # 使用 dd 命令 + volumeMounts: + - name: mypvc + moutPath: /var/lib/www/html +``` + +--- + +### 5.4 VolumeSnapshot + +```yaml +apiVersion: snapshot.storage.k8s.io/v1beta1 +kind: VolumeSnapshot +metadata: + name: cephfs-pvc-snapshot +spec: + volumeSnapshotClassName: csi-cephfsplugin-snapclass + source: + persistentVolumeClaimName: csi-cephfs-pvc # 恢复时指定的快照 +``` + +--- + +### 5.5 恢复 VolumeSnapshot + +```yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: cephfs-pvc-restore +spec: + storageClassName: csi-cephfs-sc + dataSource: + name: cephfs-pvc-snapshot + kind: VolumeSnapshot + aipGroup: snapshot.storage.k8s.io + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi +``` + +--- + +## 6. 部署 + +### 6.1 NFS-CSI + +```text +- 部署方式:`http://192.168.1.23:8890/Share/products/Kubernetes/CSI/nfs-csi` +``` \ No newline at end of file