From 4dc2c0b04c4d9b13fce1b0442dd1dbc5595825b4 Mon Sep 17 00:00:00 2001 From: Richard Case Date: Tue, 2 Apr 2024 10:53:53 +0100 Subject: [PATCH] fix: chart changes for upgrade and uninstall This makes changes to the resource created by the hooks to fix issues with upgrading and to make uninstall cleaner. Specifcally: - Check if the namespace already exists - Use the pre-delete hook to help uninstall the resources Signed-off-by: Richard Case --- charts/rancher-turtles/templates/core-provider.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/charts/rancher-turtles/templates/core-provider.yaml b/charts/rancher-turtles/templates/core-provider.yaml index bc94bc1b..dcb3ba58 100644 --- a/charts/rancher-turtles/templates/core-provider.yaml +++ b/charts/rancher-turtles/templates/core-provider.yaml @@ -1,12 +1,15 @@ {{- if index .Values "cluster-api-operator" "cluster-api" "enabled" }} +{{- $namespace := index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }} +{{- if not (lookup "v1" "Namespace" "" $namespace) }} --- apiVersion: v1 kind: Namespace metadata: annotations: - "helm.sh/hook": "post-install, post-upgrade" + "helm.sh/hook": "post-install, post-upgrade, pre-delete" "helm.sh/hook-weight": "1" name: {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }} +{{- end }} --- apiVersion: turtles-capi.cattle.io/v1alpha1 kind: CAPIProvider @@ -14,7 +17,7 @@ metadata: name: cluster-api namespace: {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }} annotations: - "helm.sh/hook": "post-install, post-upgrade" + "helm.sh/hook": "post-install, post-upgrade, pre-delete" "helm.sh/hook-weight": "2" spec: name: cluster-api @@ -45,7 +48,7 @@ metadata: name: capi-additional-rbac-roles namespace: {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }} annotations: - "helm.sh/hook": "post-install, post-upgrade" + "helm.sh/hook": "post-install, post-upgrade, pre-delete" "helm.sh/hook-weight": "2" data: manifests: |-