• 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 NameIP配置备注
    k8s-c0-master010.0.3.6Ubuntu 22.04.3 LTS 8核32G, 200G(sda) + 100G(sdb)虚拟机
    k8s-c0-node010.0.3.7Ubuntu 22.04.3 LTS 4核8G, 200G(sda) + 100G(sdb)...
    k8s-c0-node110.0.3.8Ubuntu 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
      1. [Service]
      2. Environment="HTTP_PROXY=http://192.168.0.108:1081"
      3. Environment="HTTPS_PROXY=http://192.168.0.108:1081"
      4. 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个节点,去掉污点

    kubectl taint nodes --all node-role.kubernetes.io/control-plane-

    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

    1. #!/bin/bash
    2. kubectl apply -f /k8s_apps/rook/deploy/examples/crds.yaml
    3. kubectl apply -f /k8s_apps/rook/deploy/examples/common.yaml
    4. kubectl apply -f /k8s_apps/rook/deploy/examples/operator.yaml
    5. kubectl -n rook-ceph get pod
    6. kubectl apply -f /k8s_apps/rook/deploy/examples/cluster.yaml
    7. kubectl apply -f /k8s_apps/rook/deploy/examples/toolbox.yaml
    8. kubectl apply -f /k8s_apps/rook/deploy/examples/dashboard-ingress-https.yaml
    9. kubectl -n rook-ceph get secret rook-ceph-dashboard-password -o jsonpath="{['data']['password']}" | base64 --decode && echo
    10. # 应用各种存储
    11. kubectl apply -f /k8s_apps/rook/deploy/examples/filesystem.yaml
    12. kubectl apply -f /k8s_apps/rook/deploy/examples/nfs.yaml
    13. kubectl apply -f /k8s_apps/rook/deploy/examples/object.yaml
    14. # 声明存储类
    15. kubectl apply -f /k8s_apps/rook/deploy/examples/csi/rbd/storageclass.yaml
    16. # 上一个使用例子
    17. kubectl apply -f /k8s_apps/rook/deploy/examples/mysql.yaml
    18. kubectl apply -f /k8s_apps/rook/deploy/examples/wordpress.yaml

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

    1. #!/bin/bash
    2. kubectl delete -f /k8s_apps/rook/deploy/examples/wordpress.yaml
    3. kubectl delete -f /k8s_apps/rook/deploy/examples/mysql.yaml
    4. kubectl delete -n rook-ceph cephblockpool replicapool
    5. kubectl delete storageclass rook-ceph-block
    6. kubectl delete -f /k8s_apps/rook/deploy/examples/csi/cephfs/kube-registry.yaml
    7. kubectl delete storageclass csi-cephfs
    8. kubectl -n rook-ceph patch cephcluster rook-ceph --type merge -p '{"spec":{"cleanupPolicy":{"confirmation":"yes-really-destroy-data"}}}'
    9. kubectl -n rook-ceph delete cephcluster rook-ceph
    10. kubectl -n rook-ceph get cephcluster
    11. kubectl delete -f /k8s_apps/rook/deploy/examples/operator.yaml
    12. kubectl delete -f /k8s_apps/rook/deploy/examples/common.yaml
    13. kubectl delete -f /k8s_apps/rook/deploy/examples/crds.yaml
    14. kubectl delete -f /k8s_apps/rook/deploy/examples/toolbox.yaml
    15. kubectl delete -f /k8s_apps/rook/deploy/examples/dashboard-ingress-https.yaml
    16. kubectl delete -f /k8s_apps/rook/deploy/examples/csi/rbd/storageclass.yaml
    17. kubectl delete -f /k8s_apps/rook/deploy/examples/mysql.yaml
    18. kubectl delete -f /k8s_apps/rook/deploy/examples/wordpress.yaml

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

    进入工具pod检查应用状态 

    1. kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- bash
    2. bash-4.4$ ceph -s
    3. cluster:
    4. id: 1f97e89d-faba-405a-a200-4eaeb9c11035
    5. health: HEALTH_WARN
    6. clock skew detected on mon.c
    7. services:
    8. mon: 3 daemons, quorum a,b,c (age 17h)
    9. mgr: b(active, since 17h), standbys: a
    10. osd: 3 osds: 3 up (since 17h), 3 in (since 2d)
    11. data:
    12. pools: 1 pools, 1 pgs
    13. objects: 2 objects, 449 KiB
    14. usage: 64 MiB used, 300 GiB / 300 GiB avail
    15. pgs: 1 active+clean

    4. 相关命令

    1. - 实时查看pod创建进度
    2. kubectl get pod -n rook-ceph -w
    3. - 实时查看集群创建进度
    4. kubectl get cephcluster -n rook-ceph rook-ceph -w
    5. - 详细描述
    6. kubectl describe cephcluster -n rook-ceph rook-ceph
    7. # 进入ceph部署应用
    8. kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- bash
    9. # ceph 相关
    10. ceph status
    11. ceph osd status
    12. ceph df
    13. rados df

    5. 参考

    ​- ​https://rook.io/docs/rook/v1.8/ceph-block.html​​​​​

    Rook - Rook Ceph Documentation

  • 相关阅读:
    下载安全证书到jdk中的cacerts证书库
    Python基础
    [CAD二次开发]获取CAD内3D块参照的欧拉旋转交,Matrix3d矩阵转欧拉角。
    Linux系统编程函数介绍
    使用遗传算法优化模糊隶属函数以实现最优模糊控制
    JavaWeb之Cookie的简单使用!!!
    Java8中的Stream的汇总和分组操作~它并不难的
    Adobe Auditon 如何将音频文件切分成多段,并保存为多个单独的文件
    Redis事务、pub/sub、PipeLine-管道、benchmark性能测试详解
    Java Switch中使用多字段的枚举类
  • 原文地址:https://blog.csdn.net/bennybi/article/details/133995086