-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.
Milestone
Description
What broke? What's expected?
kubebuilder-helm ignores per-resource labels and deosn't copy them over to the generated CRDs. For instance, a resource that has a label
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:metadata:labels=cluster.x-k8s.io/v1beta1=v1beta1
// Foo is the Schema for the foos API
type Foo struct {
metav1.TypeMeta `json:",inline"`
// metadata is a standard object metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
// spec defines the desired state of Foo
// +required
Spec FooSpec `json:"spec"`
// status defines the observed state of Foo
// +optional
Status FooStatus `json:"status,omitempty,omitzero"`
}doesn't get that specific label, and instead only has
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
labels:
{{- include "chart.labels" . | nindent 4 }}
annotations:
{{- if .Values.crd.keep }}
"helm.sh/resource-policy": keep
{{- end }}
controller-gen.kubebuilder.io/version: v0.18.0
name: foos.example.orgwhere chart.labels is defined as
{{- define "chart.labels" -}}
{{- if .Chart.AppVersion -}}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Chart.Version }}
helm.sh/chart: {{ .Chart.Version | quote }}
{{- end }}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
however the CRD that's generated by default in config/crd/bases already has the correct label
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.18.0
labels:
cluster.x-k8s.io/v1beta1: v1beta1
name: foos.example.orgReproducing this issue
Create a kubebuilder project and create an api
kubebuilder init --domain example.org
kubebuilder create api --kind Foo --version v1alpha1 --resource --controlleradd a label to the resource
// +kubebuilder:metadata:labels=cluster.x-k8s.io/v1beta1=v1beta1
run make manifests
and generate a helm chart using kubebuilder edit --plugins=helm/v1-alpha
KubeBuilder (CLI) Version
4.7.1
PROJECT version
3
Plugin versions
layout:
- go.kubebuilder.io/v4
plugins:
helm.kubebuilder.io/v1-alpha: {}Other versions
go version go1.25.0 darwin/arm64
controller-runtime v0.21.0
kubernetes version v1.32.0
kubectl version v1.32.0
Extra Labels
No response
AshleyDumaine and ricardo1u
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.