K8S集群实践之九: 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.1. 说明

因香橙派和树莓派资源所限,转移到基于VirtualBox建立的VMs继续实践。

虚拟机环境列表:

|----------------|----------|-------------------------------------------------|-----|
| Host Name | IP | 配置 | 备注 |
| k8s-c0-master0 | 10.0.3.6 | Ubuntu 22.04.3 LTS 8核32G, 200G(sda) + 100G(sdb) | 虚拟机 |
| k8s-c0-node0 | 10.0.3.7 | Ubuntu 22.04.3 LTS 4核8G, 200G(sda) + 100G(sdb) | ... |
| k8s-c0-node1 | 10.0.3.8 | Ubuntu 22.04.3 LTS 4核8G, 200G(sda) + 100G(sdb) | ... |

2. 准备工作

  • 下载 ubuntu-22.04.2-live-server-amd64.iso,并映射到启动光盘

  • 虚拟机设置双网卡,1作桥接(同网访问),1作NAT网络(K8s内网)

  • 安装时选择镜像(重要)https://mirrors.aliyun.com/ubuntu

  • 初始化K8s环境

  • 为避免CTR拉取镜像失败,设置容器代理,编辑 /lib/systemd/system/containerd.service

    复制代码
    [Service]
    Environment="HTTP_PROXY=http://192.168.0.108:1081"
    Environment="HTTPS_PROXY=http://192.168.0.108:1081"
    Environment="NO_PROXY=aliyun.com,aliyuncs.com,huaweicloud.com,k8s-master-0,k8s-master-1,k8s-worker-0,localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
    
    systemctl daemon-reload && systemctl restart containerd

3. 方案及安装步骤

3.1 Rook

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.

3.2 安装要求

  • Raw devices (no partitions or formatted filesystems)
  • Raw partitions (no formatted filesystem)
  • LVM Logical Volumes (no formatted filesystem)
  • Persistent Volumes available from a storage class in block mode

一句话:有个裸盘 (100G /dev/sdb)

3.3 安装步骤

  1. 获取rook仓库到安装路径,如:/k8s_apps/rook

    git clone --single-branch --branch v1.12.6 https://github.com/rook/rook.git

  2. 编写安装脚本,/k8s_apps/scripts/k8s-rook-ceph.sh

    #!/bin/bash

    kubectl apply -f /k8s_apps/rook/deploy/examples/crds.yaml
    kubectl apply -f /k8s_apps/rook/deploy/examples/common.yaml
    kubectl apply -f /k8s_apps/rook/deploy/examples/operator.yaml

    kubectl -n rook-ceph get pod

    kubectl apply -f /k8s_apps/rook/deploy/examples/cluster.yaml

  3. 编写删除脚本,/k8s_apps/scripts/rook-ceph-delete.sh

    #!/bin/bash

    kubectl delete -f /k8s_apps/rook/deploy/examples/wordpress.yaml
    kubectl delete -f /k8s_apps/rook/deploy/examples/mysql.yaml
    kubectl delete -n rook-ceph cephblockpool replicapool
    kubectl delete storageclass rook-ceph-block
    kubectl delete -f /k8s_apps/rook/deploy/examples/csi/cephfs/kube-registry.yaml
    kubectl delete storageclass csi-cephfs

    kubectl -n rook-ceph patch cephcluster rook-ceph --type merge -p '{"spec":{"cleanupPolicy":{"confirmation":"yes-really-destroy-data"}}}'

    kubectl -n rook-ceph delete cephcluster rook-ceph

    kubectl -n rook-ceph get cephcluster

    kubectl delete -f /k8s_apps/rook/deploy/examples/operator.yaml
    kubectl delete -f /k8s_apps/rook/deploy/examples/common.yaml
    kubectl delete -f /k8s_apps/rook/deploy/examples/crds.yaml

  4. 执行安装,一切正常的话,如下图,不正常的话,执行删除脚本,排除问题后重来。

4. 参考

相关推荐
好奇的菜鸟26 分钟前
在 WSL 中安装 Docker
运维·docker·容器
芥子沫4 小时前
日记应用推荐-Docker安装DailyNotes应用
docker·容器·日记
2501_9418814012 小时前
Kubernetes 容器集群资源调度与弹性扩容高可用架构在互联网业务实战经验总结
云原生·容器·kubernetes
究極の法則に通じた野犬12 小时前
k8s设计理念-k8s中哪些服务要部署成StatefulSet哪些部署成Deployment
云原生·容器·kubernetes
wuxingge12 小时前
k8s集群误删node节点,怎么添加回去
云原生·容器·kubernetes
观测云15 小时前
Kubernetes CRD 方式配置容器日志采集最佳实践
容器·kubernetes·日志分析
运维-大白同学21 小时前
2025最全面开源devops运维平台功能介绍
linux·运维·kubernetes·开源·运维开发·devops
tianyuanwo1 天前
多平台容器化RPM构建流水线全指南:Fedora、CentOS与Anolis OS
linux·运维·容器·centos·rpm
敲上瘾1 天前
【探索实战】:Kurator分布式统一应用分发平台的全面解析与实践指南
分布式·容器·kubernetes·serverless
cui_win1 天前
Docker Compose 部署一个完整的Prometheus监控告警系统
docker·容器·prometheus