Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes Operator (Operator SDK, Kubebuilder VERSUS Kubernetes Client Libraries)

I am sorry if this question has been answered but after trying many different ways of googling for an answer, I have failed to get a definitive explanation so I am trying to seek clarifications here.

I am familiar with the operator/controller pattern in the context of Kubernetes and am trying to build a custom nodejs controller that handles my own custom-defined resource (CRD) using one of the nodejs Kubernetes Client libraries from Kubernetes.io.

While researching online, I came across OperatorSDK and Kubebuilder which seems to be tools that can bootstrap operators/controllers, providing the many functionalities to interface with the K8s Api Server much like the Kubernetes Client Libraries.

OperatorSDK and Kubebuilder seems to be more than just libraries So here are my questions

  1. What are the differences between the likes of OperatorSDK, Kubebuilder AND Kubernetes Client libraries from Kubernetes.io
  2. Are the Kubernetes Client Libraries implementations of things like the OperatorSDK and Kubebuilder?
  3. Do I need to use the OperatorSDK or Kubebuilder to implement my own controller because, as far as I can tell, the Kubernetes client library seems to suffice.
like image 473
KSheng Avatar asked Oct 19 '20 14:10

KSheng


People also ask

Does Operator SDK use Kubebuilder?

Operator SDK uses Kubebuilder under the hood to do so for Go projects, such that the operator-sdk CLI tool will work with a project created by kubebuilder .

What are Kubernetes Operators?

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.

What is controller runtime?

Overview. The controller-runtime library provides various abstractions to watch and reconcile resources in a Kubernetes cluster via CRUD (Create, Update, Delete, as well as Get and List in this case) operations.


1 Answers

What are the differences between the likes of OperatorSDK, Kubebuilder AND Kubernetes Client libraries from Kubernetes.io

OperatorSDK, Kubebuilder are specialized and gives you good starting point by generating boiler plate code and a runtime(via controller runtime) necessary to implement a controller in kubernetes. Client libraries are generate purpose library to do anything such as interacting with Kubernetes API Server etc.

Are the Kubernetes Client Libraries implementations of things like the OperatorSDK and Kubebuilder?

No. Actually OperatorSDK , Kubebuilder under the hood uses controller runtime which internally uses kubernetes client library to interact with Kubernetes API Server.

Do I need to use the OperatorSDK or Kubebuilder to implement my own controller because, as far as I can tell, the Kubernetes client library seems to suffice.

If you just use kubernetes client library you will end up writing some boiler plate code and patterns which are already provided by OperatorSDK and Kubebuilder or controller runtime. It's highly recommended but not mandatory to use OperatorSDK or Kubebuilder to write controllers. You could also use controller runtime directly instead of using OperatorSDK or Kubebuilder.

like image 189
Arghya Sadhu Avatar answered Nov 15 '22 06:11

Arghya Sadhu