基于kubesphere的k8s环境部署单点版本的rook-ceph,实验性质大于使用性质,不推荐在物理资源有限的情况下使用。
Rook is an open source cloud-native storage orchestrator, providing the platform, framework, and support for Ceph storage to natively integrate with cloud-native environments.
Rook是一个开源的云原生存储编排器,为Ceph存储提供平台、框架和支持,以便与云原生环境进行本地集成。
虚拟机一台
k8s的部署: 在centos7.9上以 All-in-One 模式安装 KubeSphere
安装软件包,加载rbd模块
#软件包装备
yum install -y git lvm2 gdisk
#内核加载rbd模块
modprobe rbd
lsmod | grep rbd
备注:删除残留数据,如果部署失败,一定清理下数据,不清理的话会影响下一次的部署
删除配置文件目录
rm -rf /var/lib/rook/
格式化磁盘
gdisk --zap-all /dev/vda
gdisk --zap-all /dev/vdb
gdisk --zap-all /dev/vdc
dd if=/dev/zero of=/dev/vda bs=1M count=100 oflag=direct,dsync
dd if=/dev/zero of=/dev/vdb bs=1M count=100 oflag=direct,dsync
dd if=/dev/zero of=/dev/vdc bs=1M count=100 oflag=direct,dsync
下载文件并提取核心文件到自己的部署文件夹
cd /tmp/
git clone --single-branch --branch v1.11.6 https://github.com/rook/rook.git
mkdir -p /data/rook-ceph/
cp /tmp/rook/deploy/examples/crds.yaml /data/rook-ceph/crds.yaml
cp /tmp/rook/deploy/examples/common.yaml /data/rook-ceph/common.yaml
cp /tmp/rook/deploy/examples/operator.yaml /data/rook-ceph/operator.yaml
cp /tmp/rook/deploy/examples/cluster-test.yaml /data/rook-ceph/cluster-test.yaml
cp /tmp/rook/deploy/examples/filesystem.yaml /data/rook-ceph/filesystem.yaml
cp /tmp/rook/deploy/examples/toolbox.yaml /data/rook-ceph/toolbox.yaml
cp /tmp/rook/deploy/examples/csi/rbd/storageclass.yaml /data/rook-ceph/storageclass-rbd.yaml
cp /tmp/rook/deploy/examples/csi/cephfs/storageclass.yaml /data/rook-ceph/storageclass-cephfs.yaml
cp /tmp/rook/deploy/examples/csi/nfs/storageclass.yaml /data/rook-ceph/storageclass-nfs.yaml
修改镜像仓库信息,operator.yaml中镜像仓库修改为阿里云的镜像仓库配置
ROOK_CSI_CEPH_IMAGE: "quay.io/cephcsi/cephcsi:v3.8.0"
ROOK_CSI_REGISTRAR_IMAGE: "registry.cn-hangzhou.aliyuncs.com/google_containers/csi-node-driver-registrar:v2.7.0"
ROOK_CSI_RESIZER_IMAGE: "registry.cn-hangzhou.aliyuncs.com/google_containers/csi-resizer:v1.7.0"
ROOK_CSI_PROVISIONER_IMAGE: "registry.cn-hangzhou.aliyuncs.com/google_containers/csi-provisioner:v3.4.0"
ROOK_CSI_SNAPSHOTTER_IMAGE: "registry.cn-hangzhou.aliyuncs.com/google_containers/csi-snapshotter:v6.2.1"
ROOK_CSI_ATTACHER_IMAGE: "registry.cn-hangzhou.aliyuncs.com/google_containers/csi-attacher:v4.1.0"
执行部署
# 开始部署
cd /data/rook-ceph
kubectl create -f crds.yaml
kubectl create -f common.yaml
kubectl create -f operator.yaml
# 检查operator的创建运行状态
kubectl -n rook-ceph get pod
# 输出
NAME READY STATUS RESTARTS AGE
rook-ceph-operator-xxxxx-xxxxx 1/1 Running 0 4m9s
执行部署cluster-test.yaml
kubectl create -f cluster-test.yaml
# 会部署一段时间
kubectl -n rook-ceph get pod
# 查看部署结果,当全部为Running之后部署工具容器进行集群确认
# 创建工具容器
kubectl apply -f toolbox.yaml
# 进入工具容器
kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- bash
# 查看集群状态
bash-4.4$ ceph -s
cluster:
id: ec2162d1-cab0-402d-ba04-f0f3f6cfb95d
health: HEALTH_OK
services:
mon: 1 daemons, quorum a (age 11m)
mgr: a(active, since 10m)
osd: 3 osds: 3 up (since 10m), 3 in (since 10m)
data:
pools: 1 pools, 32 pgs
objects: 2 objects, 463 KiB
usage: 60 MiB used, 90 GiB / 90 GiB avail
pgs: 32 active+clean
备注:这里使用7000端口是因为cluster-test.yaml中dashboard没有做特殊的配置,所以使用默认的mgr的7000端口
cat > /data/rook-ceph/dashboard-external-https.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
name: rook-ceph-mgr-dashboard-external-https
namespace: rook-ceph
labels:
app: rook-ceph-mgr
rook_cluster: rook-ceph
spec:
ports:
- name: dashboard
port: 7000
protocol: TCP
targetPort: 7000
nodePort: 30808
selector:
app: rook-ceph-mgr
rook_cluster: rook-ceph
sessionAffinity: None
type: NodePort
EOF
# 这里的nodeport端口建议更换为适合自己环境规划的端口
kubectl apply -f dashboard-external-https.yaml
# 输出
service/rook-ceph-mgr-dashboard-external-https created
# 获取admin用户密码
kubectl -n rook-ceph get secret rook-ceph-dashboard-password -o jsonpath="{['data']['password']}" | base64 --decode && echo
使用浏览器访问端口192.168.XXX.XX:30808,使用admin用户登陆,登陆后可以修改密码,也可以新建用户
成功登陆
cat > /data/rook-ceph/metric-external-https.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
name: rook-ceph-mgr-metric-external-https
namespace: rook-ceph
labels:
app: rook-ceph-mgr
rook_cluster: rook-ceph
spec:
ports:
- name: metric
port: 9283
protocol: TCP
targetPort: 9283
nodePort: 30809
selector:
app: rook-ceph-mgr
rook_cluster: rook-ceph
sessionAffinity: None
type: NodePort
EOF
# 这里的nodeport端口建议更换为适合自己环境规划的端口
kubectl apply -f metric-external-https.yaml
# 输出
service/rook-ceph-mgr-metric-external-https created
还是开头提到的,实验性质大于使用性质。没啥其他的。实验的东西用来提供服务肯定会是一个大坑。