Closed rmb938 closed 2 years ago
Hi @rmb938,
Could you please provide some additional info?
1) Are the multi-group support enabled in your project? see: https://book.kubebuilder.io/migration/multi-group.html 2) Could you please copy and paste here the PROJECT file content?
See that we have sample projects generated at testdata/ directory and I could not find the issue raised by you in the project which has multi-group support (see, kubebuilder/testdata/project-v3-multigroup).
The crd patches generated in config/crd/patches and the rbac generated (for viewer and editor) in config/rbac are only for the first group and kind that gets generated. They should be generated for all groups.
Note the config/crd/patches generated for all groups:
Also, see the rbac generated for all: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/project-v3-multigroup/config/rbac
If you want see how the sample/testdata project is generated see the script: https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/testdata/generate.sh
I created a kubebuilder project and push it to a repo for easy reference.
PROJECT file: https://github.com/rmb938/multi-group-test/blob/main/PROJECT as you can see there's 2 groups each with a kind that is named the same.
APIs https://github.com/rmb938/multi-group-test/tree/main/apis
Controllers https://github.com/rmb938/multi-group-test/tree/main/controllers
CRD Patches https://github.com/rmb938/multi-group-test/tree/main/config/crd/patches Notice they only exist for the single group foo
, the one for group fiz
does not exist.
RBAC https://github.com/rmb938/multi-group-test/tree/main/config/rbac notice that the editor and viewer roles only exist for foo
not for fiz
.
You can replicate this project by running the following commands:
kubebuilder init --domain rmb938.com --repo github.com/rmb938/multi-group-test
kubebuilder edit --multigroup=true
kubebuilder create api --group foo --version v1alpha1 --kind Bar
kubebuilder create api --group fiz --version v1alpha1 --kind Bar
make generate
make manifests
Hi @rmb938,
Thank you for the clarifications
That shows that when the multi-group support is enabled we are not using the group in the name of the files and generating them. So we need to:
a) Ensure that we will consider the group to do the scaffolds
Such as, change the boilerplates to use the group, see: https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/crd/patches. In the same way that we do here (https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/golang/v2/scaffolds/internal/templates/api/group.go#L37-L43). ( The same implementation actually)
b) Update the sample/testdata to have the same kind for different groups to ensure the scenario The change must be done in: https://github.com/kubernetes-sigs/kubebuilder/blob/master/test/testdata/generate.sh for the sample kubebuilder/testdata/project-v3-multigroup.
Could you help out with this fix? WDYT about a collab with a PR to fix this scenario?
Yup I can get that done. I've been working on some internal kubebuilder scaffolds myself so I'm familiar with the modifications. I'll get the changes committed and a PR ready.
What broke? What's expected?
In a multi-group project when 2 groups have the same CRD name for example
The crd patches generated in
config/crd/patches
and the rbac generated (for viewer and editor) inconfig/rbac
are only for the first group and kind that gets generated. They should be generated for all groups.Reproducing this issue
Run the following
KubeBuilder (CLI) Version
Version: main.version{KubeBuilderVersion:"3.3.0", KubernetesVendor:"1.23.1", GitCommit:"47859bf2ebf96a64db69a2f7074ffdec7f15c1ec", BuildDate:"2022-01-18T17:03:29Z", GoOs:"darwin", GoArch:"amd64"}
PROJECT version
3
Plugin versions
Other versions
Extra Labels
No response