Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add CSI application reference documentation #218

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 187 additions & 0 deletions docs/knowledge_base/CSI/CSI应用参考.md
Original file line number Diff line number Diff line change
@@ -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
img: docker.io/library/nginx:latest
command: ["/bin/sleep", "infinity"] # 写入工具
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:
volmeSnapshotClassName: 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`
```
Loading