From 39471e77ddfc59cbfc58cf173b205ae51daab915 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/crd/kustomization.yaml | 5 +++++ config/crd/patches/keep-crds.yaml | 6 ++++++ test/e2e/resources/full-chart-install.yaml | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 config/crd/patches/keep-crds.yaml diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 04a24ac66..35f4cd623 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -11,6 +11,11 @@ resources: - bases/operator.cluster.x-k8s.io_runtimeextensionproviders.yaml # +kubebuilder:scaffold:crdkustomizeresource +patches: +- path: patches/keep-crds.yaml + target: + kind: CustomResourceDefinition + patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD diff --git a/config/crd/patches/keep-crds.yaml b/config/crd/patches/keep-crds.yaml new file mode 100644 index 000000000..3e36e4d61 --- /dev/null +++ b/config/crd/patches/keep-crds.yaml @@ -0,0 +1,6 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + "helm.sh/resource-policy": keep + name: any \ No newline at end of file diff --git a/test/e2e/resources/full-chart-install.yaml b/test/e2e/resources/full-chart-install.yaml index 148e6b507..20a598186 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