Building operator image directly without operator-sdk?

4/21/2020

I had created my Kubernetes operator with the help of the Operator SDK Now I want to make some automatic build with my GitHub repo so when I push something to the master to trigger build of the operator image.

Can I use go build + docker build (for building the image) instead of the operator-sdk build?

Because if it is doing the same job I don't want to depend on one more tool for building the image.

I run operator-sdk build with --verbose and it looks like it is doing these only two thing (go build + docker build) but I am not sure. There could be some validations and checks before these command if I don't want to such validations exist I don't want to skip them.

Is a bad idea to use go and docker to directly build the image instead of operator-sdk? Because I don't want to do something special during the build I just want to not have one more dependency in the build infrastructure if it's possible to avoid it.

-- aliench0
docker
go
kubernetes
kubernetes-operator
operator-sdk

1 Answer

5/1/2020

I faced a similar question and if you look at the source code for operator-sdk, it actually triggers go build and a docker build (the CLI, and not even the APIs for docker build). So yes, I wrote a simple docker file to do a go build. That's it.

EDIT: Here's the source for how the docker build command is formed and finally run as a system command: https://github.com/operator-framework/operator-sdk/blob/master/cmd/operator-sdk/build/cmd.go#L98

-- krish7919
Source: StackOverflow