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

1.8k views Asked by At

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.
1

There are 1 answers

3
Arghya Sadhu On BEST ANSWER

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.