k8s使用现有ceph集群
先决条件:
yaml文件参考:
https://github.com/kubernetes-retired/external-storage/tree/master/ceph/rbd/examples
https://github.com/kubernetes-retired/external-storage/tree/master/ceph/rbd/deploy
1. Ceph端操作
1.1 创建k8s ceph pool 与k8s用户
ceph --cluster ceph osd pool create kube 1024 1024
ceph --cluster ceph auth get-or-create client.k8s mon 'allow r' osd 'allow rwx pool=k8s'
1.2 获取k8s所需的secret
ceph auth get-key client.admin | base64
ceph auth get-key client.k8s | base64
2. K8S端操作
2.1 集群node节点安装ceph-common
(版本需要与ceph 集群版本一致)
yum install –y ceph-common
2.2 安装rbd-provisioner
Kubectl apply –f . /rbd-provisioner
2.2 将1.2生成的密钥替换到secret.yaml中
apiVersion: v1
kind: Secret
metadata:
name: ceph-secret-admin
namespace: default
type: "kubernetes.io/rbd"
data:
# ceph auth get-key client.admin | base64
key: QVFDL2hGaGZKOHRLTEJBQS9LYk9HMkVaaGkvZTRITGZkUXpEWlE9PQ==
---
apiVersion: v1
kind: Secret
metadata:
name: ceph-secret
namespace: default
type: "kubernetes.io/rbd"
data:
# ceph auth add client.kube mon 'allow r' osd 'allow rwx pool=kube'
# ceph auth get-key client.kube | base64
key: QVFEYjExcGY0Qk9NQUJBQTdjS2xlL3pOZUFGQ1BURHFNOHR1amc9PQ==
2.3 创建k8s secret
Kubectl apply –f secret.yaml
2.4 创建storageclass
Kubctl apply –f class.yaml
2.5 创建测试pvc
Kubectl apply –f pvc.yaml
2.6 创建测试pod
Kubectl apply –f test-pod.yaml