From 158910215ae0ef1ecda5cb46888a2e8c373b4319 Mon Sep 17 00:00:00 2001 From: Salah Al Saleh Date: Fri, 31 May 2024 15:54:12 -0700 Subject: [PATCH] Rename keep resources job and delete old one (#49) * Rename keep resources job and delete old one --- ...andon-resources-hook.yaml => keep-resources-hook.yaml} | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) rename templates/{abandon-resources-hook.yaml => keep-resources-hook.yaml} (86%) diff --git a/templates/abandon-resources-hook.yaml b/templates/keep-resources-hook.yaml similarity index 86% rename from templates/abandon-resources-hook.yaml rename to templates/keep-resources-hook.yaml index 6b6390f..e447d21 100644 --- a/templates/abandon-resources-hook.yaml +++ b/templates/keep-resources-hook.yaml @@ -2,7 +2,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: kotsadm-abandon-resources + name: kotsadm-keep-resources annotations: helm.sh/hook: pre-upgrade helm.sh/hook-weight: "2" @@ -20,6 +20,10 @@ spec: - /bin/sh - -c - | + # Delete old abandon-resources job if it exists + kubectl delete job kotsadm-abandon-resources -n {{ .Release.Namespace }} --ignore-not-found + + # Annotate resources to keep them if kubectl get configmap kotsadm-confg -n {{ .Release.Namespace }} -o jsonpath='{.metadata.labels.app\.kubernetes\.io/managed-by}' | grep -q "Helm"; then kubectl annotate configmap kotsadm-confg -n {{ .Release.Namespace }} helm.sh/resource-policy=keep fi @@ -33,7 +37,7 @@ spec: {{- end }} image: {{ .Values.images.kotsadm }} imagePullPolicy: IfNotPresent - name: abandon-resources + name: keep-resources resources: requests: cpu: 100m