[Kubernetes Operator] The point about the integration of operator-sdk and kubebuilder
Tags: kubernetes, operator, kubebuilder, operatorsdk
Published: 2020-08-06 12:39:36

# Operator-sdk command structure changed from v0.19.0 (2020/7 release)

Because the command structure of Go-based Operator is now along the lines of kubebuilder, existing commands are no longer passed.

```bash
operator-sdk new osushi-operator --repo github.com/iaoiui/osushi
Error: unknown flag: --repo
```

The version of operator-sdk is as follows:

```bash
❯ operator-sdk version
operator-sdk version: "v0.19.2", commit: "4282ce9acdef6d7a1e9f90832db4dc5a212ae850", kubernetes version: "v1.18.2", go version: "go1.14.5 darwin/amd64"
```

If you check the Operatorframework documentation below, prior to v0.19.0, it was called “Legacy" and instructed to refer to a other document.

There seems to be a lot of changes, but it seems that the subcommand to create the first template has been changed from “new" to “init" and there is an error that there is no --repo option.

[Golang Based Operator Quickstart](https://sdk.operatorframework.io/docs/golang/quickstart/)

So I was able to handle it by replacing the “new"  with "init".

```bash
operator-sdk init osushi-operator --repo github.com/iaoiui/osushi
```

According to the release information for operator-sdk, v0.19.0 will be released in July, 2020, so almost all books will need to be replaced with new command structure of operator-sdk.

[https://github.com/operator-framework/operator-sdk/releases/tag/v0.19.0](https://github.com/operator-framework/operator-sdk/releases/tag/v0.19.0)


# Background on Operator-sdk and kubebuilder's Go-based Operator integration

There are two major frameworks for creating Kubernetes Operators, operator-sdk and kubebuilder, each of which has been maintained by different communities.

Both tools could do operator scaffolding (template generation) using Go, and although the directories and files created were different, the purpose of what they could achieve was the same.

Since we are doing the same thing with both tools, our motivation has been to reduce maintenance costs and speed up development by integrating them.

In concrete terms, since operator SDK has various functions related to Go Operator, the contributor on operator SDK side will take the lead in merging those functions into kubebuilder side.

In other words, I'm guessing it was settled in a way that smells a bit of politics, with kubebuilder as the upstream and operator sdk acting as a wrapper for kubebuilder.

It will merge operator sdk documents to kubebuilder and maintain kubebuilder as well.



Reference: [kubebuilder's design documentation on the integration of kubebuilder and operator-sdk](https://github.com/kubernetes-sigs/kubebuilder/blob/master/designs/integrating-kubebuilder-and-osdk.md)


# The PR on the change of CLI in operator-sdk

As indicated in operator-sdk's [PR(#3190)]([https://github.com/operator-framework/operator-sdk/pull/3190](https://github.com/operator-framework/operator-sdk/pull/3190)), **Operator for Go is now in line with the Kubebuilder CLI**.

![Untitled.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/94861/df4410ae-0623-1d0c-99bf-bcff88fbaf11.png)

For that reason, the command has changed since 0.19.0, and the previous command is Legacy  now.

In particular, note that the files generated by the operator-sdk command have changed entirely and it would be faster to got the point by forgetting the legacy operator-sdk.

It's safer to avoid specifying particular books, but I purchased the following books yesterday and will read it while taking into account the background on integration.
[The Road to Custom Controller](https://www.amazon.co.jp/実践入門-Kubernetesカスタムコントローラーへの道-技術の泉シリーズ（NextPublishing）-磯-賢大/dp/4844378546)

This is also great book "[Kubernetes perfect guide 2nd edition](https://www.amazon.co.jp/⻘⼭真也/dp/4295009792/ref=pd_sbs_14_4/358-3368657-0445345?_encoding=UTF8&pd_rd_i=4295009792&pd_rd_r=c596e921-6755-4482-8463-ccc5c1ef3ec5&pd_rd_w=V0iNB&pd_rd_wg=KKhVK&pf_rd_p=4acc31d7-eae8-4ee9-8e37-275fb9bc20c2&pf_rd_r=Q0E23M0BTBQEKAWSTTHY&psc=1&refRID=Q0E23M0BTBQEKAWSTTHY)" which is the 2nd edition of kubernetes perfect guide, which I recently read.


# Conclusion

- As the use of Kubernetes Operator becomes more and more widespread, the integration of similar frameworks will reduce the amount of time spent on choosing tools for first-time users, which is a very positive development trend.
- To be precise, it's not a complete integration of the operator creation for Helm and Ansible based Operator but Go-based.
  It is clear that they want to make operator-sdk wrapper because the function relationship will be operator-sdk>kubebuilder.
- Anyway, it's a problem for the user side if the command changes many times, so we'll continue to keep a close eye on developments.