1.上传ceph-csi-yaml和ceph-csi-image 两个文件夹到服务器
2.加载 ceph-csi-image里面的镜像
3.将加载好的镜像上传到本地harbor上。
4.修改ceph-csi-yaml文件夹里面的 yaml文件内容
#csi-config-map.yaml
- ---
- apiVersion: v1
- kind: ConfigMap
- data:
- config.json: |-
- [
- {
- "clusterID": "2a5306a8-885f-40b7-91f6-ec9410b53d3c", // ceph集群的 id 通过ceph -s 可以看到
- "monitors": [
- "10.20.20.103:6789",
- "10.20.20.104:6789",
- "10.20.20.105:6789"
- ]
- }
- ]
- metadata:
- name: ceph-csi-config
#ceph-config-map.yaml
- ---
- apiVersion: v1
- kind: ConfigMap
- data:
- ceph.conf: |
- [global]
- fsid = 0c69001e-202b-11ed-a599-8c2a8e4b8e7f // ceph集群的 id
- mon_host = 192.168.4.130 // ceph mon 节点的 ip
-
- keyring: |
- metadata:
- name: ceph-config
#csi-rbd-secret.yaml
- ---
- apiVersion: v1
- kind: Secret
- metadata:
- name: csi-rbd-secret
- namespace: default
- stringData:
- userID: kubernetes
- userKey: AQA18kdi+4iYHhAAbRmfkKJ/XvB1PdYTTBEdwA==
- encryptionPassphrase: test_passphrase
其中的userID与userKey通过以下方式获取
其中userID 就是 下面的 kubernetes 当然如果在创建ceph集群的时候已经 创建好了池子并且给池子赋予了账户和权限,也可以直接用已经创建好了的,我是 直接用的 cinder的
userKey 就是 /etc/ceph/ceph.client.cinder.keyring 文件内容
ceph auth get-or-create client.kubernetes mon 'profile rbd' osd 'profile rbd pool=k8s' mgr 'profile rbd pool=k8s'
#csi-storageClass.yaml
- ---
- apiVersion: storage.k8s.io/v1
- kind: StorageClass
- metadata:
- name: csi-rbd-sc
- provisioner: rbd.csi.ceph.com
- parameters:
- clusterID: 0c69001e-202b-11ed-a599-8c2a8e4b8e7f
- pool: volumes
- imageFeatures: layering
- csi.storage.k8s.io/provisioner-secret-name: csi-rbd-secret
- csi.storage.k8s.io/provisioner-secret-namespace: default
- csi.storage.k8s.io/controller-expand-secret-name: csi-rbd-secret
- csi.storage.k8s.io/controller-expand-secret-namespace: default
- csi.storage.k8s.io/node-stage-secret-name: csi-rbd-secret
- csi.storage.k8s.io/node-stage-secret-namespace: default
- csi.storage.k8s.io/fstype: ext4
- reclaimPolicy: Delete
- allowVolumeExpansion: true
- mountOptions:
-
- - discard
#创建pvc yaml文件
- ---
- apiVersion: v1
- kind: PersistentVolumeClaim
- metadata:
- name: rbd-pvc
- spec:
- accessModes:
-
- - ReadWriteOnce
- resources:
- requests:
- storage: 1Gi
- storageClassName: csi-rbd-sc
#修改 csi-rbdplugin.yaml和csi-rbdplugin-provisioner.yaml 文件里面的 镜像地址,为自己的harbor地址