operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.1k stars 1.73k forks source link

Default labels do not comply with recommendation #6704

Closed criscola closed 2 months ago

criscola commented 3 months ago

I would like to propose a few changes to the default labels as generated by the operator-sdk. Let's take the Namespace object generated by kustomize:

apiVersion: v1
kind: Namespace
metadata:
  labels:
    app.kubernetes.io/component: manager
    app.kubernetes.io/created-by: myoperator
    app.kubernetes.io/instance: system
    app.kubernetes.io/managed-by: kustomize
    app.kubernetes.io/name: namespace
    app.kubernetes.io/part-of: myoperator
    control-plane: controller-manager
  name: myoperator-system
  1. The created-by label is deprecated since v1.9.
  2. The instance label is misused because it should be applied to workload resources and be unique for that instance, not for that resource.
  3. The name label is misused because it should be the same for all resources and have the operator's name, not the kind of resource.
  4. The control-plane label is misleading since it confuses administrators; the controller-manager is a control-plane component, not a Kubernetes operator nor a normal controller. It is used as label selector. This label could be replaced entirely by the name label once corrected.

References:

jberkhahn commented 2 months ago

Hello,

These labels are actually created by Kubebuilder, not Operator-SDK directly. There was actually a recent pr that changed them here: https://github.com/kubernetes-sigs/kubebuilder/commit/bdfe5e4ea785323d84e2eb27869ef2079d814357 It looks like most of these got changed?

These will fixed when we bump to a version of Kubebuilder that has that PR and cut a release with 3.14.2 of Kubebuilder.

Thanks!