Kubernetes Operator,SDK与OperatorHub

一、什么是 Operator?

若是你关心 Operator pattern, 请阅读 herehtml

 

二、使用Operator-SDK

欢迎

若是你考虑建立一个 Kubernetes Operator, 很是欢迎。从2016年启动以来, Kubernetes Operators 已经帮助用户解决了不少问题。Operators 减小了部署有状态的或者分布式应用的复杂性,帮助用户简化使用Helm chart初始部署的问题,也帮助 Kubernetes API的开发。git

如何开始编写Operator?

一般,没有工具和库须要学习,除了 Kubernetes API, 库 client-gocontroller-runtime 可以启动监视Kubernetes集群中特定的事件和对象。github

这里还有 operator-sdk, 是 Operator Framework的一部分,是一个社区项目,目的在于简化Operator建立和实现定制化的控制逻辑。docker

一般这里有三种方法,决定了有三种 Operators由SDK提供支持:分布式

Operator 类型  SDK建立的 须要你定义的
Go Operator
  • General go program structure
  • Boilerplate code to talk to the Kubernetes API
  • Boilerplate code to watch for Kubernetes objects of interest
  • An entry point to the reconciliation loop
  • An example YAML files based on CRDs
  • Custom objects via CRDs
  • Control loop logic in Go
  • Potentially artistic stunts only possible by talking directly to the API from Go
Ansible Operator
  • A Go program that runs an Ansible playbook or role every time a certain type of object is detected / modified
  • Ansible playbook or role
  • Custom objects via CRD
Helm Operator
  • A custom object via CRD containing the same properties as the chart's values.yaml
  • A Go program that reads a helm chart and deploys all its resources
  • Watch statements to detect changes in the custom objects specification, re-deploying all resources with updated values
  • The location / repository of the helm chart

这是 Operators的不一样阶段的成熟度模型:ide

感兴趣吗?试一下 operator-sdk,参考 Getting Started Guide工具

三、访问OperatorHub.io

为了可以管理和搜索Operator,Red hat、Google等公司联合社区发起了operatorhub项目,能够直接访问相关的Operator仓库。oop

已经有了Operator,能够贡献到 OperatorHub.io,访问  here.学习

相关文章
相关标签/搜索