From 63a4b7c1e5dcf94e327879110323e4e8ca56aa63 Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Fri, 6 Dec 2024 14:55:17 +0100 Subject: [PATCH] feat: make control namespace field immutable Signed-off-by: Bence Csati --- api/telemetry/v1alpha1/collector_types.go | 3 +++ .../crds/telemetry.kube-logging.dev_collectors.yaml | 3 +++ config/crd/bases/telemetry.kube-logging.dev_collectors.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/api/telemetry/v1alpha1/collector_types.go b/api/telemetry/v1alpha1/collector_types.go index 8ea02ad..33aef2c 100644 --- a/api/telemetry/v1alpha1/collector_types.go +++ b/api/telemetry/v1alpha1/collector_types.go @@ -52,6 +52,9 @@ type CollectorSpec struct { // TenantSelector is used to select tenants for which the collector should collect data. TenantSelector metav1.LabelSelector `json:"tenantSelector,omitempty"` + // +kubebuilder:validation:Required + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable, please recreate the resource" + // Namespace where the Otel collector DaemonSet is deployed. ControlNamespace string `json:"controlNamespace"` diff --git a/charts/telemetry-controller/crds/telemetry.kube-logging.dev_collectors.yaml b/charts/telemetry-controller/crds/telemetry.kube-logging.dev_collectors.yaml index 1264e87..7abefac 100644 --- a/charts/telemetry-controller/crds/telemetry.kube-logging.dev_collectors.yaml +++ b/charts/telemetry-controller/crds/telemetry.kube-logging.dev_collectors.yaml @@ -51,6 +51,9 @@ spec: controlNamespace: description: Namespace where the Otel collector DaemonSet is deployed. type: string + x-kubernetes-validations: + - message: Value is immutable, please recreate the resource + rule: self == oldSelf daemonSet: description: DaemonSetOverrides is used to override the default DaemonSet configuration. diff --git a/config/crd/bases/telemetry.kube-logging.dev_collectors.yaml b/config/crd/bases/telemetry.kube-logging.dev_collectors.yaml index 1264e87..7abefac 100644 --- a/config/crd/bases/telemetry.kube-logging.dev_collectors.yaml +++ b/config/crd/bases/telemetry.kube-logging.dev_collectors.yaml @@ -51,6 +51,9 @@ spec: controlNamespace: description: Namespace where the Otel collector DaemonSet is deployed. type: string + x-kubernetes-validations: + - message: Value is immutable, please recreate the resource + rule: self == oldSelf daemonSet: description: DaemonSetOverrides is used to override the default DaemonSet configuration.