New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use kubebuilder controller-gen for creating CRDs #2855
Conversation
looks great, thank you! 🎉 |
Question, can we also replace openapi-gen with controller-tools? I believe support for that has been added recently. |
$(PO_CRDGEN_BINARY): cmd/po-crdgen/main.go $(OPENAPI_TARGET) | ||
@go install -mod=vendor $(GO_PKG)/cmd/po-crdgen | ||
$(CONTROLLER_GEN_BINARY): | ||
@go install -mod=vendor sigs.k8s.io/controller-tools/cmd/controller-gen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use an arbitrary version, but download a binary. Controller tools is often lagging behind in Go and Kube version support. I would try to avoid any trouble by using a binary. We use those from https://github.com/openshift/kubernetes-sigs-controller-tools/releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just following what we are doing for the other build tools here which AFAIK is preferred since it avoids committing binary tools to git or downloading them at build time. It's not an arbitrary version because it's installed from the vendor directory set to v0.2.2. But I can certainly change it if that's preferred, @s-urbaniak wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pgier I am voting for pinning the version in the Makefile 👍
Whoa, awesome! 🎉 |
@s-urbaniak I'm not sure if we can replace openapi-gen, but we can at least replace the deepcopy-gen the rbac stuff also. |
Why not? |
@pgier CRD schema generation was added by @sttts in kubernetes-sigs/controller-tools#183, so we should be able to leverage that feature. Having said that I am also fine in doing this in a step-by-step manner as a follow-up. |
Replaces the custom po-crdgen command
Removes dependency on deepcopy-gen command
bde01cb
to
9592167
Compare
Generate bindata.go from the generated crd yaml and then unmarshal the bindata yaml into CRD structs at runtime. This removes the need for openapi-gen.
9592167
to
924a79a
Compare
cbf8253
to
11111cb
Compare
Assuming the tests pass this time, I think this is ready for another review and merge if everything looks ok. |
Just to add some notes about the changes here, we are now generating the CRDs as yaml files from
|
Overall lgtm, nice work! Happy to get rid of some of the tech debt we've build around this. |
@pgier the unit tests are spot on 👌 |
Testing switching over to kubebuilder controller-get for CRD generation