k8s使用rbd作为存储
如果需要使用rbd作为后端存储的话,需要先安装ceph-common
需要提前在ceph集群上创建pool,然后创建image
[root@ceph01 ~]# ceph osd pool create pool01
[root@ceph01 ~]# ceph osd pool application enable pool01 rbd
[root@ceph01 ~]# rbd pool init pool01
[root@ceph01 ~]# rbd create pool01/test --size 10G --image-format 2 --image-feature layerin
[root@ceph01 ~]# rbd info pool01/test
编写yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: rbd
name: rbd
spec:
replicas: 1
selector:
matchLabels:
app: rbd
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: rbd
spec:
volumes:
- name: test
rbd:
fsType: xfs
keyring: /root/admin.keyring
monitors:
- 192.168.200.230:6789
pool: pool01
image: test
user: admin
readOnly: false
containers:
- image: nginx
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /usr/share/nginx/html
name: test
name: nginx
resources: {}
status: {}
[root@master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
rbd-888b8b747-n56wr 1/1 Running 0 26m
这个时候k8s就使用了rbd作为存储
如果这个地方一直显示ContainerCreating的话,可能是没有安装ceph-common
标签:存储,rbd,image,pool01,ceph,ceph01,k8s,root From: https://www.cnblogs.com/fsdstudy/p/18254695