专栏首页云计算与大数据云原生|Operator本质

云原生|Operator本质

什么是 Operator

CoreOS 在 2016 年底提出了 Operator 的概念,当时的一段官方定义如下:

“An Operator represents human operational knowledge in software, to reliably manage an application.

什么是Controller Loop?

简单来说,Controller Loop是Controller动作的基础。想象一下,有一个非终止的进程(在Kubernetes中称为和解循环)在不断地发生,如下图所示:

这个过程至少观察一个Kubernetes对象,该对象包含有关所需状态的信息。比如:

  • Deployment
  • Services
  • Secrets
  • Ingress
  • Config Maps

这些对象由JSON或YAML中的manifest组成的配置文件定义。然后controller根据内置逻辑,通过Kubernetes API进行持续调整,模仿所需状态,直到当前状态变成所需状态。

通过这种方式,Kubernetes通过处理不断的更改来处理Cloud Native系统的动态性质。为达到预期状态而执行的修改实例包括:

  • 注意到节点宕机时,要求更换新的节点。
  • 检查是否需要复制pods。
  • 如果需要,创建一个新的负载均衡器。

Operator是一个特定应用程序的controller,它扩展了一个Kubernetes API,替代运维工程师或SRE工程师来创建、配置和管理复杂的应用程序。在Kubernetes官方文档中对此有以下描述:

Operator是Kubernetes的软件拓展,它利用自定义资源来管理应用程序及其组件。Operator遵循Kubernetes的原则,尤其遵循control loop。

到目前为止,你已经了解Operator会利用观察Kubernetes对象的controller。这些controller有点不同,因为它们正在追踪自定义对象,通常称为自定义资源(CR)。CR是Kubernetes API的扩展,它提供了一个可以存储和检索结构化数据的地方——你的应用程序的期望状态。整个操作原理如下图所示:

Operator会持续跟踪与特定类型的自定义资源相关的集群事件。可以跟踪的关于这些自定义资源的事件类型有:

  • Add
  • Update
  • Delete

当Operator接收任何信息时,它将采取行动将Kubernetes集群或外部系统调整到所需的状态,作为其在自定义controller中的和解循环(reconciliation loop)的一部分。

Why are Operators different than other tools out there?
Operators are purpose-built to run a Kubernetes application, with operational knowledge baked in. They will be smarter and more tailored than generic tools.

The cloud-like capabilities that are encoded into the Operator code can provide an advanced user experience, automating such features as updates, backups and scaling. All of this is accomplished using standard Kubernetes tools, CLI and API.

What are benefits of using the Operator Framework?
If you are a community member, builder, consumer of applications, or a user of Kubernetes overall, the Operator Framework offers a number of benefits. Operators are built on top of a common set of Kubernetes APIs. They act like cloud services, make it more simple to install and update Kubernetes applications, without having to worry about the underlying platform.

Operators helps your teams to build a great automation experience. They allow teams to build in expertise of automated operations, instead of building manually each time.

How does the Operator Framework make hybrid cloud easier?
For consumers of applications across the hybrid cloud, keeping those applications up to date as new versions become available is of supreme importance, both for security reasons and for managing the applications’ lifecycles and other needs. The Operator Framework helps address these user requirements, aiding in the creation of cloud-native applications that are easier to consume, to keep updated, and to secure.

Who builds an Operator?
Operators are best built by those that are experts in the “business logic” of installing, running and upgrading an application.

Experience has shown that the creation of an Operator typically starts by automating an application’s installation and self-service provisioning capabilities, and then evolves to take on more complex automation.

Who deploys an Operator?
Operators are deployed by end-users through the Lifecycle Manager. Common patterns are for centralized infrastructure teams to grant access to a team’s Namespaces to run specific Operators. Afterwards, each team can manage, upgrade and scale their Operators in a self-service manner.

Operators can package internal applications at an enterprise, software that is deployed by commercial customers, or popular open source projects. Operators can even power a SaaS environment with a large amount of individual instances of an application.

Does an Operator require Kubernetes?
Yes, Kubernetes is required, but range of versions/distros are supported. The goal is to provide tooling to build Kubernetes applications, Operators, that are independent to a specific vendor or cloud platform.

Do I always need to write my own Operator to get value out of the Operator Framework?
You do not need to write your own Operator in order to get value out of the Operator Framework. Operators can be written such that they can be reused for applications. This means that you can, for example, create a generic Helm Operator that can be specialized for individual Charts. Even applications that do not require more than the built-in Kubernetes Workloads APIs can benefit from the lifecycle management and unified user-experience provided by the Operator Framework.

How do I join the community or help out?
All core components are part of a dedicated GitHub organization called “Operator Framework”. Please join the Operator Framework mailing list for discussion, questions and comments. Please also review and assist community operators as listed here and here.

https://developers.redhat.com/blog/2018/12/18/introduction-to-the-kubernetes-operator-framework/

https://coreos.com/operators/

https://www.openshift.com/blog/kubernetes-operators-best-practices?extIdCarryOver=true&sc_cid=701f2000001OH7EAAW

https://sdk.operatorframework.io/docs/building-operators/golang/tutorial/

https://book.kubebuilder.io/cronjob-tutorial/controller-overview.html

https://www.okd.io/

https://github.com/kubernetes-sigs/controller-tools

本文分享自微信公众号 - 黑洞日志(heidcloud),作者:砥砺前行不负韶华

原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。

原始发表时间:2020-09-20

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • 运维:k8s pod erro exit code 137

    If a container is no longer running, use the following command to find the statu...

    heidsoft
  • How to Monitor Zookeeper

    As per previous articles, our general rule of thumb is “collect all possible/rea...

    heidsoft
  • 研发:What is a DDoS Attack?

    A distributed denial-of-service (DDoS) attack is a malicious attempt to disrupt ...

    heidsoft
  • 对等网络中的搜索技术(Networking and Internet Architecture)

    点对点(Peer to Peer, P2P)网络是对互联网IP网络的一种覆盖,随着越来越多的人使用低价个人计算机来形成大型分布式系统集群,P2P网络可以通过参与...

    用户6869393
  • 保守性降低的非线性模型的线性变参数嵌入(CS SC)

    本文提出了一种将非线性系统的动力学描述嵌入到线性参数变化(LPV)系统表示中的系统方法。最初,模型表示中的非线性函数使用多元多项式回归来近似。考虑到近似的残差作...

    识檐
  • What's The Future Of Cognitive Computing? IBM Watson

    By Jay Bellisimo, IBM Watson Group We are entering a new period of computing his...

    首席架构师智库
  • python note #1

    To record my process of studying python and to practice my English meanwhile, I'...

    py3study
  • 学习从图像推断用户界面属性(cs CV)

    我们探索了一个学习推断用户界面属性的新领域,这将有助于开发人员自动执行用户界面实现过程。更具体来说,给定一个设计师创建的输入图像,我们学习推断它的实现,当渲染时...

    DANDAN用户6837186
  • 深入了解SAP note的技术细节

    Although I have been working on ABAP for several years, I am not well aware of t...

    Jerry Wang
  • 蝙蝠式在结构上栖息动作的仿生研究:惯性动力学(CS RO)

    蝙蝠的飞行特性在无人机设计中被忽视了。与其他动物不同,蝙蝠在栖息时利用惯性动力学来表现空中翻转。受这一独特动作的启发,这项工作开发并使用了一个名为“鱼叉”的微型...

    时代在召唤

扫码关注云+社区

领取腾讯云代金券