Skip to content

Commit

Permalink
Abandon removed resources but don't delete them on upgrade (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh authored Mar 25, 2024
1 parent 4757742 commit b113014
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
36 changes: 36 additions & 0 deletions templates/abandon-resources-hook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This job is used to stop Helm from managing resources without deleting them.
apiVersion: batch/v1
kind: Job
metadata:
name: kotsadm-abandon-resources
annotations:
helm.sh/hook: pre-upgrade
helm.sh/hook-weight: "2"
labels:
{{- include "admin-console.labels" . | nindent 4 }}
spec:
template:
metadata:
labels:
{{- include "admin-console.labels" . | nindent 8 }}
spec:
containers:
- command:
- /bin/sh
- -c
- |
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
if kubectl get configmap kotsadm-application-metadata -n {{ .Release.Namespace }} -o jsonpath='{.metadata.labels.app\.kubernetes\.io/managed-by}' | grep -q "Helm"; then
kubectl annotate configmap kotsadm-application-metadata -n {{ .Release.Namespace }} helm.sh/resource-policy=keep
fi
image: {{ .Values.images.kotsadm }}
imagePullPolicy: IfNotPresent
name: abandon-resources
resources:
requests:
cpu: 100m
memory: 100Mi
restartPolicy: OnFailure
serviceAccountName: kotsadm
11 changes: 0 additions & 11 deletions templates/kotsadm-config.yaml

This file was deleted.

0 comments on commit b113014

Please sign in to comment.