Kubernetes Operators:
So I am pretty sure that you are aware of what Kubernetes is and why do we use it. If not then kindly go and check what Kubernetes is and then came back here to know about its operators.
Starting with Kubernetes architecture
As we know that Kubernetes mainly containers:
- An API Server
- Scheduler
- Controller manager
- etcd
What is an Operator in Kubernetes:
A Kubernetes operator is an application-specific controller that extends the functionality of the Kubernetes API to create, configure, and manage instances of complex applications on behalf of a Kubernetes user.
5 stages of maturity in Kubernetes Operator: To build our own custom Kubernetes Operators we have some toolkits:
- Kubebuilder
- Operator SDK
Control Loop
Here the control loop acts like an replica set i.e watch the state of your cluster, then make or request changes where needed.
Custom resources
A resource is an endpoint in the Kubernetes API that stores a collection of API object] of a certain kind; for example, the built-in pods resource contains a collection of Pod objects.
A custom resource is an extension of the Kubernetes API that is not necessarily available in a default Kubernetes installation. It represents a customization of a particular Kubernetes installation. However, many core Kubernetes functions are now built using custom resources, making Kubernetes more modular.
Custom resources can appear and disappear in a running cluster through dynamic registration, and cluster admins can update custom resources independently of the cluster itself. Once a custom resource is installed, users can create and access its objects using kubectl, just as they do for built-in resources like Pods.
Custom controllers
On their own, custom resources let you store and retrieve structured data. When you combine a custom resource with a custom controller, custom resources provide a true declarative API.
The Kubernetes declarative API enforces a separation of responsibilities. You declare the desired state of your resource. The Kubernetes controller keeps the current state of Kubernetes objects in sync with your declared desired state. This is in contrast to an imperative API, where you instruct a server what to do.
You can deploy and update a custom controller on a running cluster, independently of the cluster's lifecycle. Custom controllers can work with any kind of resource, but they are especially effective when combined with custom resources. The Operator pattern combines custom resources and custom controllers. You can use custom controllers to encode domain knowledge for specific applications into an extension of the Kubernetes API.
With Operators
Without operator
Difference between Operator and Controller:
In simple words we can say that every operator is a controller but every controller is not an operator.
Kubernetes operator toolkit:
Here are some toolkits for building your own operators in Kubernetes:
- Redhat operator Framework:
- Operator SDKs
- Operator Lifecycle manager
- operator registry
- support Golang
Kubebuilder:
- support Golang
Kopf:
- Zalando Open Source Project
- support Python
Kubernetes Command vs Event:
Subscribe to my newsletter
Read articles from Shankar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Shankar
Shankar
5G & Cloud