Ceph 与 PV/PVC 集成

ceph osd lspools

rbd create -p kubernetes --image-feature layering demo-1.img --size 5G

rbd -p kubernetes ls

mkdir -p /data/pv_pvc
cd /data/pv_pvc

# 创建 pv.yaml
vi pv.yaml 
apiVersion: v1
kind: PersistentVolume
metadata:
  name: rbd-demo
spec:
  accessModes:
   - ReadWriteOnce
  capacity:
    storage: 5G
  rbd:
    monitors:
     - 192.168.31.207:6789
     - 192.168.31.159:6789
     - 192.168.31.198:6789
    pool: kubernetes
    image: demo-1.img 
    fsType: ext4
    user: kubernetes
    secretRef:
      name: ceph-secret
  persistentVolumeReclaimPolicy: Retain
  storageClassName: rbd


kubectl apply -f pv.yaml

# 定义 PVC,引用 PV
vi pvc.yaml 
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-demo
spec:
  accessModes:
   - ReadWriteOnce
  volumeName: rbd-demo
  resources:
    requests:
      storage: 5G
  storageClassName: rbd

kubectl apply -f pvc.yaml

kubectl get pvc

# Pod 中引用 PVC
vi pod-demo.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: pod-demo-pv-pvc
spec:
  containers:
  - name: pod-demo-pv-pvc
    image: nginx:1.7.9
    imagePullPolicy: IfNotPresent
    ports:
    - name: www
      protocol: TCP
      containerPort: 80
    volumeMounts:
    - name: rbd
      mountPath: /data
  volumes:
  - name: rbd
    persistentVolumeClaim:
      claimName: pvc-demo

kubectl apply -f pod-demo.yaml 

Ceph 与 PV/PVC 集成
Ceph 与 PV/PVC 集成

上一篇:@ceph 分布式存储


下一篇:ceph 运维操作-PG