使用rook部署ceph_如何使用Rook在Kubernetes中设置Ceph集群

使用rook部署ceph

The author selected the Mozilla Foundation to receive a donation as part of the Write for DOnations program.

作者选择Mozilla基金会作为Write for DOnations计划的一部分接受捐赠。

介绍 (Introduction)

Kubernetes containers are stateless as a core principle, but data must still be managed, preserved, and made accessible to other services. Stateless means that the container is running in isolation without any knowledge of past transactions, which makes it easy to replace, delete, or distribute the container. However, it also means that data will be lost for certain lifecycle events like restart or deletion.

Kubernetes容器是无状态的核心原则,但是数据仍然必须被管理,保留并使其可被其他服务访问。 无状态意味着容器正在孤立运行,无需任何有关过去事务的知识,这使得替换,删除或分发容器变得容易。 但是,这也意味着对于某些生命周期事件(如重新启动或删除),数据将丢失。

Rook is a storage orchestration tool that provides a cloud-native, open source solution for a diverse set of storage providers. Rook uses the power of Kubernetes to turn a storage system into self-managing services that provide a seamless experience for saving Kubernetes application or deployment data.

Rook是一种存储编排工具,可为各种存储提供商提供云原生的开源解决方案。 Rook利用Kubernetes的功能将存储系统转变为自我管理服务,这些服务提供了无缝的体验来保存Kubernetes应用程序或部署数据。

Ceph is a highly scalable distributed-storage solution offering object, block, and file storage. Ceph clusters are designed to run on any hardware using the so-called CRUSH algorithm (Controlled Replication Under Scalable Hashing).

Ceph是一种高度可扩展的分布式存储解决方案,提供对象,块和文件存储。 Ceph集群被设计为使用所谓的CRUSH算法 (可伸缩哈希下的受控复制)在任何硬件上运行

One main benefit of this deployment is that you get the highly scalable storage solution of Ceph without having to configure it manually using the Ceph command line, because Rook automatically handles it. Kubernetes applications can then mount block devices and filesystems from Rook to preserve and monitor their application data.

这种部署的一个主要好处是,您可以获得Ceph​​的高度可扩展的存储解决方案,而无需使用Ceph命令行手动配置它,因为Rook会自动处理它。 然后,Kubernetes应用程序可以从Rook挂载块设备和文件系统,以保留和监视其应用程序数据。

In this tutorial, you will set up a Ceph cluster using Rook and use it to persist data for a MongoDB database as an example.

在本教程中,您将使用Rook设置一个Ceph集群,并以其为MongoDB数据库持久化数据。

先决条件 (Prerequisites)

Before you begin this guide, you’ll need the following:

在开始本指南之前,您需要满足以下条件:

  • A DigitalOcean Kubernetes cluster with at least three nodes that each have 2 vCPUs and 4 GB of Memory. To create a cluster on DigitalOcean and connect to it, see the Kubernetes Quickstart.

    一个DigitalOcean Kubernetes集群,至少具有三个节点,每个节点具有2个vCPU和4 GB的内存。 要在DigitalOcean上创建集群并连接到集群,请参见Kubernetes Quickstart

  • The kubectl command-line tool installed on a development server and configured to connect to your cluster. You can read more about installing kubectl in its official documentation.

    kubectl命令行工具安装在开发服务器上,并配置为连接到集群。 您可以在其官方文档中阅读有关安装kubectl的更多信息。

  • A DigitalOcean block storage Volume with at least 100 GB for each node of the cluster you just created—for example, if you have three nodes you will need three Volumes. Select Manually Format rather than automatic and then attach your Volume to the Droplets in your node pool. You can follow the Volumes Quickstart to achieve this.

    每个刚创建的群集的每个节点至少具有100 GB的DigitalOcean块存储卷-例如,如果您有三个节点,则需要三个卷。 选择“ 手动格式化”而不是“自动格式化” ,然后将卷附加到节点池中的Droplet。 您可以按照Volumes Quickstart来实现。

第1步-设置Rook (Step 1 — Setting up Rook)

After completing the prerequisite, you have a fully functional Kubernetes cluster with three nodes and three Volumes—you’re now ready to set up Rook.

完成前提条件后,您将拥有一个具有三个节点和三个卷的功能齐全的Kubernetes集群,现在您可以设置Rook。

In this section, you will clone the Rook repository, deploy your first Rook operator on your Kubernetes cluster, and validate the given deployment status. A Rook operator is a container that automatically bootstraps the storage clusters and monitors the storage daemons to ensure the storage clusters are healthy.

在本节中,您将克隆Rook存储库,在Kubernetes集群上部署第一个Rook 运算符 ,并验证给定的部署状态。 Rook运算符是一个容器,可以自动引导存储集群并监视存储后台驻留程序以确保存储集群运行状况良好。

First, you will clone the Rook repository, so you have all the resources needed to start setting up your Rook cluster:

首先,您将克隆Rook存储库,因此您拥有开始设置Rook集群所需的所有资源:

  • git clone --single-branch --branch release-1.3 https://github.com/rook/rook.git

    git clone --single-branch --branch版本-1.3 https://github.com/rook/rook.git

This command will clone the Rook repository from Github and create a folder with the name of rook in your directory. Now enter the directory using the following command:

该命令将从Github克隆Rook存储库,并在目录中创建一个名为rook的文件夹。 现在,使用以下命令输入目录:

  • cd rook/cluster/examples/kubernetes/ceph

    cd rook / cluster / examples / kubernetes / ceph

Next you will continue by creating the common resources you needed for your Rook deployment, which you can do by deploying the Kubernetes config file that is available by default in the directory:

接下来,您将继续创建Rook部署所需的公共资源,这可以通过部署Kubernetes配置文件来完成,该文件默认情况下在目录中可用:

  • kubectl create -f common.yaml

    kubectl创建-f common.yaml

The resources you’ve created are mainly CustomResourceDefinitions (CRDs) and define new resources that the operator will later use. They contain resources like the ServiceAccount, Role, RoleBinding, ClusterRole, and ClusterRoleBinding.

您创建的资源主要是CustomResourceDefinitions (CRD),并定义了操作员以后将使用的新资源。 它们包含诸如ServiceAccount,Role,RoleBinding,ClusterRole和ClusterRoleBinding之类的资源。

Note: This standard file assumes that you will deploy the Rook operator and all Ceph daemons in the same namespace. If you want to deploy the operator in a separate namespace, see the comments throughout the common.yaml file.

注意:此标准文件假定您将Rook运算符和所有Ceph守护程序部署在同一名称空间中。 如果要在单独的命名空间中部署操作员,请参阅common.yaml文件中的注释。

After the common resources are created, the next step is to create the Rook operator.

创建公用资源后,下一步是创建Rook运算符。

Before deploying the operator.yaml file, you will need to change the CSI_RBD_GRPC_METRICS_PORT variable because your DigitalOcean Kubernetes cluster already uses the standard port by default. Open the file with the following command:

在部署operator.yaml文件之前,您将需要更改CSI_RBD_GRPC_METRICS_PORT变量,因为默认情况下,DigitalOcean Kubernetes集群已使用标准端口。 使用以下命令打开文件:

  • nano operator.yaml

    纳米算子

Then search for the CSI_RBD_GRPC_METRICS_PORT variable, uncomment it by removing the #, and change the value from port 9001 to 9093:

然后搜索CSI_RBD_GRPC_METRICS_PORT变量,通过删除#取消注释,并将值从端口9001更改为9093

operator.yaml
运算符
kind: ConfigMap
apiVersion: v1
metadata:
  name: rook-ceph-operator-config
  namespace: rook-ceph
data:
  ROOK_CSI_ENABLE_CEPHFS: "true"
  ROOK_CSI_ENABLE_RBD: "true"
  ROOK_CSI_ENABLE_GRPC_METRICS: "true"
  CSI_ENABLE_SNAPSHOTTER: "true"
  CSI_FORCE_CEPHFS_KERNEL_CLIENT: "true"
  ROOK_CSI_ALLOW_UNSUPPORTED_VERSION: "false"
  # Configure CSI CSI Ceph FS grpc and liveness metrics port
  # CSI_CEPHFS_GRPC_METRICS_PORT: "9091"
  # CSI_CEPHFS_LIVENESS_METRICS_PORT: "9081"
  # Configure CSI RBD grpc and liveness metrics port
  CSI_RBD_GRPC_METRICS_PORT: "9093"
  # CSI_RBD_LIVENESS_METRICS_PORT: "9080"

Once you’re done, save and exit the file.

完成后,保存并退出文件。

Next, you can deploy the operator using the following command:

接下来,您可以使用以下命令部署操作员:

  • kubectl create -f operator.yaml

    kubectl创建-f operator.yaml

The command will output the following:

该命令将输出以下内容:


   
   
   
Output
configmap/rook-ceph-operator-config created deployment.apps/rook-ceph-operator created

Again, you’re using the kubectl create command with the -f flag to assign the file that you want to apply. It will take around a couple of seconds for the operator to be running. You can verify the status using the following command:

同样,您使用带有-f标志的kubectl create命令来分配要应用的文件。 操作员将需要大约几秒钟的时间运行。 您可以使用以下命令来验证状态:

  • kubectl get pod -n rook-ceph

    kubectl获取pod -n rook-ceph

You use the -n flag to get the pods of a specific Kubernetes namespace (rook-ceph in this example).

您可以使用-n标志来获取特定Kubernetes名称空间的Pod(在此示例中为rook-ceph ceph)。

Once the operator deployment is re

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值