云原生|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
- 经典面试问题: Top K 之 -- 海量数据找出现次数最多或,不重复的
- Java多线程详解4【面试+工作】
- Java多线程详解5【面试+工作】
- Java多线程详解6【面试+工作】
- MySQL备份恢复第二篇(r5笔记第6天)
- SpringMVC 中配置 Swagger 插件.
- MySQL和Oracle对比学习之事务(r5笔记第4天)
- 【面试宝典】Java如何打印数组
- MySQL数据导入导出牛刀小试(r5笔记第3天)
- SpringMVC 异常处理.
- 一条简单的sql在11g和12c中的不同(r5笔记第2天)
- 浅析 SpringMVC 原理和配置.
- 使用impdp不当导致的数据丢失问题(r5笔记第1天)
- MySQL数据库 Event 定时执行任务.
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- Docker六脉神剑(二) 使用Docker构建lnmp开发环境
- redis主从配置+集群搭建
- 【Ceph RGW】找一个用Go写的s3cmd
- 技术分享 | 如何优雅地在 Windows 上从 MySQL 5.6 升级到 5.7
- SpringCloud分布式配置中心
- Sharding-Proxy的基本功能使用
- React-Redux 对Todolist修改
- 快排解决寻找数组中的第K个最大元素
- Docker六脉神剑(一) Mac极速体验
- React-Router 5.0 制作导航栏+页面参数传递
- Vue3.0快速入门(速查)
- 憧憬博客Nginx到Tengine的迁移
- SpringCloud微服务构建浅析
- 宋宝华:Linux设备与驱动的手动解绑与手动绑定
- ELK7.x日志系统搭建 1. elk基础搭建