From 8544321d484b8ddeb056378f474257084c2aead8 Mon Sep 17 00:00:00 2001 From: Danil Grigorev Date: Wed, 24 Apr 2024 14:41:46 +0200 Subject: [PATCH] Add helm.sh/resource-policy: keep to CRDs to prevent deletion Signed-off-by: Danil Grigorev --- config/chart/kustomization.yaml | 5 +++++ config/chart/patches/keep-crds.yaml | 6 ++++++ test/e2e/resources/full-chart-install.yaml | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 config/chart/patches/keep-crds.yaml diff --git a/config/chart/kustomization.yaml b/config/chart/kustomization.yaml index 36301c68..a67da377 100644 --- a/config/chart/kustomization.yaml +++ b/config/chart/kustomization.yaml @@ -23,6 +23,11 @@ bases: # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. #- ../prometheus +patches: +- path: patches/keep-crds.yaml + target: + kind: CustomResourceDefinition + patchesStrategicMerge: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. # Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. diff --git a/config/chart/patches/keep-crds.yaml b/config/chart/patches/keep-crds.yaml new file mode 100644 index 00000000..6dcbc34c --- /dev/null +++ b/config/chart/patches/keep-crds.yaml @@ -0,0 +1,6 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + "helm.sh/resource-policy": keep + name: any diff --git a/test/e2e/resources/full-chart-install.yaml b/test/e2e/resources/full-chart-install.yaml index 148e6b50..20a59818 100644 --- a/test/e2e/resources/full-chart-install.yaml +++ b/test/e2e/resources/full-chart-install.yaml @@ -6,6 +6,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.14.0 + helm.sh/resource-policy: keep labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: addonproviders.operator.cluster.x-k8s.io @@ -1623,6 +1624,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.14.0 + helm.sh/resource-policy: keep labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: bootstrapproviders.operator.cluster.x-k8s.io @@ -4825,6 +4827,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.14.0 + helm.sh/resource-policy: keep labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: controlplaneproviders.operator.cluster.x-k8s.io @@ -8030,6 +8033,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.14.0 + helm.sh/resource-policy: keep labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: coreproviders.operator.cluster.x-k8s.io @@ -11232,6 +11236,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.14.0 + helm.sh/resource-policy: keep labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: infrastructureproviders.operator.cluster.x-k8s.io @@ -14437,6 +14442,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.14.0 + helm.sh/resource-policy: keep labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: ipamproviders.operator.cluster.x-k8s.io @@ -16054,6 +16060,7 @@ metadata: annotations: cert-manager.io/inject-ca-from: 'default/capi-operator-serving-cert' controller-gen.kubebuilder.io/version: v0.14.0 + helm.sh/resource-policy: keep labels: clusterctl.cluster.x-k8s.io/core: capi-operator name: runtimeextensionproviders.operator.cluster.x-k8s.io