Kubernetes - Operators
What are Operators?
Why called "operators"? The goal of an Operator is to put operational knowledge into software, i.e. to automate manual work (deploy, restart, upgrade, etc) of human operator / administrator.
Operators = Kubernetes native applications
= Business Logic + Automated Operations
= Custom Resources + Custom Controllers
Layers of Abstractions
- Golang provides a generic
http.Client
. client-go
defines aRESTClient
on top ofhttp.Client
(Generic HTTP + REST).client-go
is used by k8s clients to talk to API Server. E.g. used bykubectl
.controller-runtime
defines theClient
(built on top ofclient-go
RESTClient
) that knows how to perform CRUD operations on Kubernetes objects.- kubebuilder: built on top of
controller-runtime
and make it easier to build k8s API. - Operator-SDK: uses Kubebuilder as a library; uses the plugin feature to include non-Go operators e.g. operator-sdk's Ansible and Helm-based language Operators.
- Operator-SDK is part of Operator Framework, by redhat. (SDK for development, lifecycle manager after deployment, a public catalog to share Operators like Docker Hub)
Kubebuilder
kubebuilder is a framework for building Kubernetes APIs using CRDs, Controllers and Admission Webhooks; (use comment in go code like // +kubebuilder:xxx
to auto generate code) is built on top of controller-runtime
Markers
//+kubebuilder:object:root=true
is a marker used by https://github.com/kubernetes-sigs/controller-tools to generate CRM manifests from go code.