ceph集群:version 10.2.5
10.0.41.217:6789
10.0.41.203:6789
10.0.41.225:6789
其中一个节点执行
grep key /etc/ceph/ceph.client.admin.keyring |awk '{printf "%s", $NF}'|base64
返回值作为secret的key值QVFCYnZvWmdCVTl0RFJBQWpRK0xxNTNXV3NIZUpyTndqNkllSGc9PQ==
k8s集群:version 1.18.6
每个节点都要安装yum install -y ceph-common
本次直接部署在default命名空间
git clone https://github.com/kubernetes-incubator/external-storage.git
cd external-storage-master/ceph/rbd/deploy
kubectl apply -f ./rbac
定义secret进行ceph认证:
1 [root@master01 ceph]# cat ceph-secret.yaml 2 apiVersion: v1 3 kind: Secret 4 metadata: 5 name: ceph-secret 6 type: kubernetes.io/rbd 7 data: 8 key: QVFCYnZvWmdCVTl0RFJBQWpRK0xxNTNXV3NIZUpyTndqNkllSGc9PQ==
storageclass存储类定义: 注释:provisioner: kubernetes.io/rbd 修改为provisioner: ceph.com/rbd,意思就是不使用 k8s 内部提供的 rbd 存储类型,而是使用我们刚创建的扩展 rbd 存储,不然后报错 exemple: failed to create rbd image imageFormat: "2"默认值为1,会报错 exemple: rbd image format 1 is deprected
[root@master01 ceph]# cat sc.yaml kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: cephrbd provisioner: ceph.com/rbd parameters: monitors: 10.0.41.217:6789,10.0.41.203:6789,10.0.41.225:6789 adminId: admin adminSecretName: ceph-secret adminSecretNamespace: default userSecretName: ceph-secret fsType: ext4 imageFormat: "2" imageFeatures: "layering"
pvc定义:
[root@master01 test]# cat pvc.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: claim-local spec: accessModes: - ReadWriteOnce storageClassName: cephrbd resources: requests: storage: 1Gi
测试pod:
[root@master01 test]# cat pod.yaml kind: Pod apiVersion: v1 metadata: name: test01 spec: containers: - name: test01 image: busybox command: ["sleep", "3000"] volumeMounts: - mountPath: /ceph name: cephrbd readOnly: false volumes: - name: cephrbd persistentVolumeClaim: claimName: claim-local