Kubernetes operators

根据Rob Szumski的presentation
Kubernetes operator是把专家平常的经验,流程,比如写在wiki里面的诀窍,使用Operator来固化。这些经验就会集成在Operator软件里面。

换句话说,这个叫做Best practices. 也是软件工程里面把logic封装起来的一个例子。It’s a fancy script.

比如failover,用软件来建立模型。使用K8S的原语,比如stateless workload,stateful workload,服务发现等来实现。

好处是到处可以使用,跨平台。

Kubernetes提供了一个Operator框架,供大家使用。控制集群里面的节点。

  • Operator SDK for Build
  • Operator Lifecycle manager for Run, 多个Operator的生命周期,比如版本。
  • Operator Metering for Operate,收集统计信息。

业界Open operators, 提供在github。比如etcd,Spark, MongoDB.

例如,mongoDB提供了operator,封装了创造ReplicaSet的best practice。在PROD namespace,用户提供High level configuration,提供Intention about如何部署。Operator会帮助deploy。

另外一个例子,根据Luke Bond的video, Cassandra需要把3节点扩展到5节点的时候,因为是stateful应用,需要做一系列的动作,这个知识就可以封装在operator。就像Kubectl增加instance的数量一样。

etcd的operators

  • create/destroy
  • resize
  • backup
  • upgrade

BTW,CoreOS还提供Prometheus,rook的operators。

Operator model

  • Observe:2 running pods, different version (one is old)
  • Analyze: should run 3 pods and in the latest version
  • Act: Recover 1 member, backup cluster, upgrade one pod to the latest version.
  1. //create an operator
    kubectrl create -f xxxx.yaml

run the operator… Launch an operator container

  1. create a new third party type when installed into K8s.
    The code is using k8s libraries. For example, in Go, you can import k8s libs.

  2. Using k8s primitives like Services and Replica Sets. For example, Etcd operator uses a ReplicaSet with replica=1

  3. Operators should be backward compatible and understand previous versions of resources.

  4. Should be online change without affecting databases running.

chaos monkey can be a special operator that wakes up periodically and kills stuff, for example, a pod using k8s APIs.

你可能感兴趣的:(introduction)