1. 为kubernetes创建一个存储池 ceph osd pool create k8s 128

2.为ceph添加一个kubernetes secret [root@k8s-master1 ceph]# echo "$(ceph auth get-key client.admin)"|base64 QVFCTk9DZGNlWXM4TEJBQTJ4YTROcGh5WUhaN2FBWGNRV1VFVHc9PQo=

[root@k8s-master1 ceph]# cat ceph-secret.yaml apiVersion: v1 kind: Secret metadata: name: ceph-secret namespace: kube-system type: "kubernetes.io/rbd" data: key: "QVFCTk9DZGNlWXM4TEJBQTJ4YTROcGh5WUhaN2FBWGNRV1VFVHc9PQo="

[root@k8s-master1 ceph]kubectl create -f ceph-secret.yaml

  1. 创建一个StorageClass ceph-rbd-storageclass.yaml

[root@k8s-master1 ceph]# cat ceph-secret.yaml apiVersion: v1 kind: Secret metadata: name: ceph-secret namespace: kube-system type: "kubernetes.io/rbd" data: key: "QVFCTk9DZGNlWXM4TEJBQTJ4YTROcGh5WUhaN2FBWGNRV1VFVHc9PQo=" [root@k8s-master1 ceph]# cat ceph- ceph-pvc.json ceph-rbd-storageclass.yaml ceph-secret.yaml
[root@k8s-master1 ceph]# cat ceph-rbd-storageclass.yaml apiVersion: storage.k8s.io/v1beta1 kind: StorageClass metadata: name: fast provisioner: kubernetes.io/rbd parameters: monitors: 192.168.1.86:6789,192.168.1.87:6789,192.168.1.88:6789 adminId: admin adminSecretName: ceph-secret adminSecretNamespace: kube-system pool: k8s userId: admin userSecretName: ceph-secret

[root@k8s-master1 ceph]kubectl create -f ceph-rbd-storageclass.yaml [root@k8s-master1 ceph]kubectl get storageclass

4.测试 ceph-pvc.json { "kind": "PersistentVolumeClaim", "apiVersion": "v1", "metadata": { "name": "claim1", "annotations": { "volume.beta.kubernetes.io/storage-class": "fast" } }, "spec": { "accessModes": [ "ReadWriteOnce" ], "resources": { "requests": { "storage": "3Gi" } } } }