kubebuilder
kubebuilder copied to clipboard
Labels added to generated YAML seem a bit aggressive
What broke? What's expected?
Nothing is broken really, but I find myself removing all (or nearly all) of the app.kubernetes.io labels on the YAML the kubebuilder generates.
For example: https://github.com/kubernetes-sigs/kubebuilder/blob/2302f6e131cb6b4a042069bf460f101fcf5e5da3/testdata/project-v4/config/rbac/admiral_editor_role.yaml#L6-L11
I know these are present based on recommendations made here: https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/#labels
I would propose the following:
app.kubernetes.io/name-> Project nameapp.kubernetes.io/instance-> Remove; Kubebuilder doesn't know what the instance names will be. This is only known at create time in a cluster.app.kubernetes.io/component-> Remove; Kubebuilder doesn't know the architecture for this project.app.kubernetes.io/created-by-> Remove; Not in the recommended labels doc, also Kubebuilder doesn't know what will eventully create it.app.kubernetes.io/part-of-> Remove; Kubebuilder doesn't know the architecture for this project.app.kubernetes.io/managed-by-> Remove; Kubebuilder doesn't know how this project will be managed.
Reproducing this issue
No response
KubeBuilder (CLI) Version
master
PROJECT version
No response
Plugin versions
No response
Other versions
No response
Extra Labels
No response
Hi @joelanford,
Thank you for bringing this to our attention. The label app.kubernetes.io/created-by caught me off guard, and I appreciate the discussion on it.
I concur with the proposed changes, except for one:
app.kubernetes.io/managed-by -> Suggested removal; reasoning being that Kubebuilder cannot predetermine the project's management tool.
However, referencing the official documentation:
app.kubernetes.io/managed-by | This label indicates the tool used to manage the operation of an application | Example: helm | Type: string
In our context, the managing tool is Kustomize, as it is the technology chosen during scaffolding. Hence, I believe we should retain the app.kubernetes.io/managed-by label to reflect our use of Kustomize accurately.
Therefore, I think we can move forward anyway with what we convey and this one is a great fit for good first issue
So, what should be done here:
See that we scaffold those labels in thekustomize/v2 see: https://github.com/kubernetes-sigs/kubebuilder/blob/8afeb403549fa87bf55a00e10a819a34719eec53/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/crd_sample.go#L55-L65 plugins and we need to:
- app.kubernetes.io/name -> Change to be the Project name
- Remove: app.kubernetes.io/instance, app.kubernetes.io/component, app.kubernetes.io/created-by, app.kubernetes.io/part-of
@joelanford @camilamacedo86 I would love to work on this issue
/assign
Closing it is done and released with 3.14.1