Kubernetes Operators vs. Helm Charts_ Which to Use and When

Kubernetes Operators vs. Helm Charts: Which to Use and When

Kubernetes Operators 与 Helm Charts:使用哪个以及何时使用

转载来源: https://www.itprotoday.com/containers/kubernetes-operators-vs-helm-charts-which-use-and-when

Kubernetes operators and Helm charts are complementary, rather than competing, technologies. Kubernetes Operator 和 Helm Chart 是互补而非竞争的技术。

Christopher Tozzi | Aug 10, 2020 克里斯托弗·托齐 | 2020 年 8 月 10 日

In Kubernetes, Helm charts and operators are both handy tools for automating tasks that would otherwise require a great deal of manual effort. But although they do similar things, they are not exactly interchangeable tools. Here’s a breakdown of how Helm charts work, how Kubernetes operators work, and when you should use one or the other. 在 Kubernetes 中,Helm 图表和运算符都是用于自动化任务的便捷工具,否则这些任务需要大量手动操作。但是,尽管它们做类似的事情,但它们并不是完全可以互换的工具。以下详细介绍了 Helm 图表的工作原理、Kubernetes 运算符的工作原理以及何时应该使用其中之一。

The Need for Helm Charts and Kubernetes Operators 对 Helm Chart 和 Kubernetes Operator 的需求

Helm charts and Kubernetes operators exist to solve similar types of problems (although not the same exact problem) in Kubernetes: Writing YAML files by hand is not a lot of fun for most people, and it is not practical to write custom YAML manually every time you need to deploy an app or modify a configuration setting within your Kubernetes cluster. Helm 图表和 Kubernetes 运算符的存在是为了解决 Kubernetes 中类似类型的问题(尽管不是完全相同的问题):对于大多数人来说,手动编写 YAML 文件并不是很有趣,而且每次都手动编写自定义 YAML 是不切实际的您需要在 Kubernetes 集群中部署应用程序或修改配置设置。

Helm charts and Kubernetes operators solve this challenge by providing an easy way for admins to deploy applications and/or configurations into a Kubernetes cluster. In this way, they double-down on the automation features that Kubernetes enables. Helm 图表和 Kubernetes 操作员通过为管理员提供一种将应用程序和/或配置部署到 Kubernetes 集群的简单方法来解决这一挑战。通过这种方式,他们加倍利用 Kubernetes 支持的自动化功能。

Kubernetes Operators vs. Helm charts Kubernetes Operator 与 Helm 图表

That said, whether you should use Kubernetes operators vs. Helm charts depends on what kind of application you are deploying and how much special configuration it requires. To understand the difference, let’s look at how the use cases for Helm charts and operators are different. 也就是说,您是否应该使用 Kubernetes 运算符还是 Helm 图表取决于您正在部署的应用程序类型以及它需要多少特殊配置。为了理解其中的差异,我们来看看 Helm 图表和运算符的用例有何不同。

Use cases for Helm Helm 的用例

Helm is a package management system for Kubernetes. Helm 是 Kubernetes 的包管理系统。 Using a packaging format called charts, someone can package an application–like Kafka or Apache HTTP, for example–in a format that anyone else can deploy on a Kubernetes cluster with just a few commands, while making few or no manual changes to YAML files. 使用称为图表的打包格式,某人可以将应用程序(例如 Kafka 或 Apache HTTP)打包为其他任何人都可以通过几个命令部署在 Kubernetes 集群上的格式,同时很少或无需进行手动更改YAML 文件。

If you’re familiar with package management in the context of Linux, Helm charts should be pretty easy to understand. They’re analogous to Debian or RPM packages, while Helm itself is like apt or dnf. Just as you can apt-get install [some package] on Ubuntu, you can helm install [some package] on Kubernetes to get an application up and running quickly. 如果您熟悉 Linux 环境中的包管理,那么 Helm 图表应该很容易理解。它们类似于 Debian 或 RPM 软件包,而 Helm 本身类似于 apt 或 dnf。就像您可以在 Ubuntu 上 apt-get install [some package] 一样,您可以在 Kubernetes 上 helm install [some package] 来快速启动并运行应用程序。

Use cases for Kubernetes operators Kubernetes 操作员的用例

Kubernetes operators also package applications into easy-to-deploy formats, but they do much more than that. Using Kubernetes custom resources, operators also make it possible to include a great deal of complex configuration data within the package. Kubernetes 运营商还将应用程序打包成易于部署的格式,但他们做的远不止于此。使用 Kubernetes 自定义资源,操作员还可以在包中包含大量复杂的配置数据。

Thus, you can use Kubernetes operators to do things like deploy a stateful application and its database schema in a completely automatic way, or deploy an application across a cluster that is configured in a particular way to achieve high availability. 因此,您可以使用 Kubernetes Operator 来执行一些操作,例如以完全自动的方式部署有状态应用程序及其数据库模式,或者跨以特定方式配置的集群部署应用程序以实现高可用性。 Indeed, you don’t even need to deploy an application when using an operator; you can use operators to automate other tasks, like performing backups or configuring your cluster in a special way based on predefined templates. 事实上,使用 Operator 时甚至不需要部署应用程序;您可以使用操作员来自动执行其他任务,例如执行备份或基于预定义模板以特殊方式配置集群。

Unlike Helm charts, Kubernetes operators don’t have any direct analogies from other platforms, although they are comparable to other types of tools. 与 Helm 图表不同,Kubernetes 运算符与其他平台没有任何直接类比,尽管它们与其他类型的工具具有可比性。 You can think of operators in some respects as being like a Bash script that you deploy on a Linux server to modify the server’s configuration, although operators are packaged and deployed in a cleaner, more discrete way than a generic Bash script. 在某些方面,您可以将操作符视为部署在 Linux 服务器上以修改服务器配置的 Bash 脚本,尽管操作符的打包和部署方式比通用 Bash 脚本更干净、更离散。

Kubernetes operators are perhaps also analogous in some ways to an operating system image file, which you could use to deploy copies of an operating system environment that is set up in a specific way. However, operators are easier to modify and deploy than an image file. Kubernetes Operator 在某些方面可能也类似于操作系统映像文件,您可以使用它来部署以特定方式设置的操作系统环境的副本。然而,操作员比镜像文件更容易修改和部署。 If you want to deploy an OS image, you have to build a new OS from scratch. In contrast, operators can be deployed on an existing Kubernetes cluster, where they will change only the parts of the cluster configuration that they are designed to change. 如果要部署操作系统映像,则必须从头开始构建新的操作系统。相比之下,操作员可以部署在现有的 Kubernetes 集群上,他们将仅更改其设计要更改的集群配置部分。

When to use Helm charts and when to use operators 何时使用 Helm 图表以及何时使用运算符

So, when should you use Helm, and when are Kubernetes operators a better solution? The answer depends on a few factors: 那么,什么时候应该使用 Helm,什么时候 Kubernetes Operator 是更好的解决方案?答案取决于几个因素:

  • Are you just installing an application? If your main goal is to deploy an application, Helm is probably the better solution. 您只是安装一个应用程序吗?如果您的主要目标是部署应用程序,Helm 可能是更好的解决方案。
  • How much customization is involved? If you are deploying a generic application and are happy with the default settings, Helm will work well. If you need a special configuration, however, Kubernetes operators will allow you to deploy that. 涉及多少定制?如果您正在部署通用应用程序并且对默认设置感到满意,Helm 将运行良好。但是,如果您需要特殊配置,Kubernetes Operator 将允许您进行部署。
  • How mature is your cluster? In general, Helm charts are most useful when you are first setting up a Kubernetes cluster and want to deploy applications. Operators come in handy later in the game, when your cluster is already up and running, but you want to implement a complex, custom configuration or deploy a special application. 当您的集群已经启动并运行,但您想要实现复杂的自定义配置或部署特殊应用程序时,操作员会在游戏后期派上用场。 您的集群有多成熟?一般来说,当您首次设置 Kubernetes 集群并想要部署应用程序时,Helm 图表最有用。

The bottom line is that most teams will use both Helm charts and Kubernetes operators at different points to achieve different goals. They are complementary, rather than competing, technologies. 最重要的是,大多数团队会在不同的点同时使用 Helm Chart 和 Kubernetes Operator 来实现不同的目标。它们是互补而非竞争的技术。 They both help to automate Kubernetes workflows, as well as to share Kubernetes applications and configurations with other people, but they address different types of use cases. 它们都有助于自动化 Kubernetes 工作流程,以及与其他人共享 Kubernetes 应用程序和配置,但它们解决不同类型的用例。


评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注