安装
# 1. 检查磁盘是否满足条件
lsblk -f
# 2. clone相关配置
git clone --single-branch --branch master https://github.com/rook/rook.git
# 3. 进入rook ceph目录
cd rook/cluster/examples/kubernetes/ceph
# 4. 安装crd,operator
kubectl create -f crds.yaml -f common.yaml -f operator.yaml
# 5. 检查pod运行情况
kubectl -n rook-ceph get pod
# 6. 安装ceph cluster
kubectl create -f cluster.yaml
# 7. 检查pod运行情况
kubectl -n rook-ceph get pod
安装ceph tool
保存toolbox.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: rook-ceph-tools
namespace: rook-ceph
labels:
app: rook-ceph-tools
spec:
replicas: 1
selector:
matchLabels:
app: rook-ceph-tools
template:
metadata:
labels:
app: rook-ceph-tools
spec:
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: rook-ceph-tools
image: rook/ceph:master
command: ["/tini"]
args: ["-g", "--", "/usr/local/bin/toolbox.sh"]
imagePullPolicy: IfNotPresent
env:
- name: ROOK_CEPH_USERNAME
valueFrom:
secretKeyRef:
name: rook-ceph-mon
key: ceph-username
- name: ROOK_CEPH_SECRET
valueFrom:
secretKeyRef:
name: rook-ceph-mon
key: ceph-secret
volumeMounts:
- mountPath: /etc/ceph
name: ceph-config
- name: mon-endpoint-volume
mountPath: /etc/rook
volumes:
- name: mon-endpoint-volume
configMap:
name: rook-ceph-mon-endpoints
items:
- key: data
path: mon-endpoints
- name: ceph-config
emptyDir: {}
tolerations:
- key: "node.kubernetes.io/unreachable"
operator: "Exists"
effect: "NoExecute"
tolerationSeconds: 5
# 1. 安装
kubectl create -f toolbox.yaml
# 2. 进入容器
kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- bash
# 3. 执行相关命令
ceph status
ceph osd status
ceph df
rados df
block存储(被单个pod使用)
kubectl create -f cluster/examples/kubernetes/ceph/csi/rbd/storageclass.yaml
Shared Filesystem存储(被多个pod共享使用)
filesystem.yaml
apiVersion: ceph.rook.io/v1
kind: CephFilesystem
metadata:
name: myfs
namespace: rook-ceph
spec:
metadataPool:
replicated:
size: 3
dataPools:
- replicated:
size: 3
preserveFilesystemOnDelete: true
metadataServer:
activeCount: 1
activeStandby: true
# 1.
kubectl create -f filesystem.yaml
# 2.
kubectl create -f cluster/examples/kubernetes/ceph/csi/cephfs/storageclass.yaml
配置自动扩容
新增一块设备后能被自动发现
# 开启自动发现磁盘
# vim operator.yaml
ROOK_ENABLE_DISCOVERY_DAEMON: "true"