kubeadm k8s配置 cephfs 动态pv 类型storageClass

1、安装ceph(略),
2、添加 mds 节点

#ceph mds stat
e2: 0/0/1 up
# ceph-deploy mds create $nodes    
# ceph mds stat
e4: 1/1/1 up {0=node03=up:active}

3、创建cephfs文件系统

ceph osd pool create cephfs_data 64
ceph osd pool create cephfs_metadata 64
ceph fs new cephfs cephfs_metadata cephfs_data

4、测试挂载

mkdir /mnt/cephfs
mount.ceph $nodes:6789:/  /mnt/cephfs/ -o name=admin,secret=AQAzCfRadRzIDhAAATbRfsO6kOhqDKKPejrRnw==
df -h   #查看是否正常挂载了

5、参考https://github.com/kubernetes-incubator/external-storage/tree/master/ceph/cephfs 创建Provisioner

#创建秘钥
ceph auth get-key client.admin > /tmp/secret
kubectl create ns cephfs
kubectl create secret generic ceph-secret-admin --from-file=/tmp/secret --namespace=cephfs
#部署Provisioner 
# yaml文件 https://github.com/kubernetes-incubator/external-storage/tree/master/ceph/cephfs/deploy/rbac
NAMESPACE=cephfs
sed -r -i "s/namespace: [^ ]+/namespace: $NAMESPACE/g" ./rbac/*.yaml
sed -r -i "N;s/(name: PROVISIONER_SECRET_NAMESPACE.*\n[[:space:]]*)value:.*/\1value: $NAMESPACE/" ./rbac/deployment.yaml
kubectl -n $NAMESPACE apply -f ./rbac
#检查pod 的状态是否正常
 kubectl get pods -n cephfs
	 NAME                                  READY   STATUS    RESTARTS   AGE
	 cephfs-provisioner-7bf7d44886-wvjz8   1/1     Running   0          4h13m

6、创建storageclass

#cat    storageclass.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: cephfs
provisioner: ceph.com/cephfs
parameters:
    monitors: 172.24.0.6:6789   #换成自己的ceph地址
    adminId: admin
    adminSecretName: ceph-secret-admin
    adminSecretNamespace: cephfs
    claimRoot: /pvc-volumes
#kubectl apply -f storageclass.yaml

7、创建pvc

#cat  pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: claim1
spec:
  storageClassName: cephfs
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
#kubectl apply -f pvc.yaml
#kubectl get pvc   #出现 Bound 则为正常状态
NAME         STATUS   VOLUME                      CAPACITY   ACCESS MODES   STORAGECLASS   AGE
claim1        Bound    ceph-pv                                    2Gi        RWX                      cephfs                      5s

你可能感兴趣的:(k8s,ceph)