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.學習

相關文章
相關標籤/搜索