Operator

Operator

TPR(Third Party Resource) 在k8s 1.7 被集成,并命名为CRD(Custom Resource Definition).

通过CRD,K8S可以动态的添加和管理资源,controller跟踪这些资源。

CRD+custom Controller = decalartive API(声明式API),一般分为通用性controller和operator.

通用型controller一般用于平台需求,operator一般用于部署特定应用.

用于开发operator的工具有kubebuilder和operator-sdk, 他们都是基于controller-runtime开发.

https://github.com/operator-framework/awesome-operators

https://access.redhat.com/documentation/zh-cn/openshift_container_platform/4.2/html/operators/index

https://operatorhub.io/

开发示例:

https://github.com/kubernetes/sample-controller

operator的build三种模式:

  • go
  • ansible
  • helm

operator的run三种模式:

  • 在集群外部本地运行(开发测试).
  • 作为deployment在集群内部运行.
  • 通过OLM部署.

operator-sdk

redhat的operator-sdk可以方便的开发opeartor.

https://github.com/operator-framework/operator-sdk https://sdk.operatorframework.io/docs/installation/


kubebuilder

sig维护的kubebuilder也能方便的开发operator.

https://github.com/kubernetes-sigs/kubebuilder

Designed by Canux