Kubernetes - Operators

Last Updated: 2023-07-19

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 a RESTClient on top of http.Client (Generic HTTP + REST). client-go is used by k8s clients to talk to API Server. E.g. used by kubectl.
  • controller-runtime defines the Client (built on top of client-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 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



//+kubebuilder:object:root=true is a marker used by https://github.com/kubernetes-sigs/controller-tools to generate CRM manifests from go code.