From 49d7b993d7a5adb7974e7620a492c4c50d4fbe1a Mon Sep 17 00:00:00 2001 From: Grace Do Date: Wed, 18 Oct 2023 17:32:42 -0700 Subject: [PATCH] feat(koperator): Remove pre-upgrade job to set kcore version (#1670) * Revert "fix: used dedicated clusterrole for kcore hooks (#1635)" This reverts commit 6d2c1f300f5659268662390ccfdf319961388687. * Revert "feat: patch kcore status to kommander ver pre upgrade (#1608)" This reverts commit 585e249c1822526b88b9f1a714241aa10fc251bb. * fix: use dedicated clusterrole for kcore hooks * chore: add patch & update for post install job --------- Co-authored-by: York Chen --- .../pre_upgrade_kommandercore_hook.yaml | 121 ------------------ 1 file changed, 121 deletions(-) delete mode 100644 charts/kommander-operator/templates/pre_upgrade_kommandercore_hook.yaml diff --git a/charts/kommander-operator/templates/pre_upgrade_kommandercore_hook.yaml b/charts/kommander-operator/templates/pre_upgrade_kommandercore_hook.yaml deleted file mode 100644 index 6b3ba83e8..000000000 --- a/charts/kommander-operator/templates/pre_upgrade_kommandercore_hook.yaml +++ /dev/null @@ -1,121 +0,0 @@ ---- -# TODO: remove this job in 2.8 -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ .Chart.Name }}-pre-upgrade - namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": pre-upgrade - "helm.sh/hook-weight": "-5" - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ .Chart.Name }}-pre-upgrade - annotations: - "helm.sh/hook": pre-upgrade - "helm.sh/hook-weight": "-5" - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded -rules: - - apiGroups: - - dkp.d2iq.io - - helm.toolkit.fluxcd.io - resources: - - kommandercores - - helmreleases - verbs: - - get - - list - - watch - - apiGroups: - - dkp.d2iq.io - resources: - - kommandercores - - kommandercores/status - verbs: - - patch - - update ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ .Chart.Name }}-pre-upgrade - annotations: - "helm.sh/hook": pre-upgrade - "helm.sh/hook-weight": "-5" - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: {{ .Chart.Name }}-pre-upgrade -subjects: - - kind: ServiceAccount - name: {{ .Chart.Name }}-pre-upgrade - namespace: {{ .Release.Namespace }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Chart.Name }}-pre-upgrade - namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": pre-upgrade - "helm.sh/hook-weight": "-5" - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded -data: - pre_process_kcore.sh: |- - #!/bin/bash - set -eo pipefail - - kcore_status=$(kubectl get kommandercore kommander-core -o jsonpath='{.status}') - # do nothing if the .status field is already populated - if [ -n "$kcore_status" ]; then - exit 0 - fi - - # get the version of kommander before upgrade - KOMMANDER_VERSION_PREUPGRADE=$(kubectl get helmrelease -n kommander kommander -o jsonpath='{.status.lastAppliedRevision}') - cat < kcore_patch.yaml - apiVersion: dkp.d2iq.io/v1alpha1 - kind: KommanderCore - metadata: - name: kommander-core - status: - version: $KOMMANDER_VERSION_PREUPGRADE - EOF - - kubectl patch kommandercore kommander-core --subresource='status' --type='merge' --patch-file kcore_patch.yaml ---- -apiVersion: batch/v1 -kind: Job -metadata: - name: {{ .Chart.Name }}-pre-upgrade - namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": pre-upgrade - "helm.sh/hook-weight": "0" - "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded -spec: - template: - spec: - serviceAccountName: {{ .Chart.Name }}-pre-upgrade - {{- if .Values.priorityClassName }} - priorityClassName: "{{ .Values.priorityClassName }}" - {{- end }} - containers: - - name: {{ .Chart.Name }}-pre-upgrade - image: "{{ .Values.kubetools.image.repository | default "mesosphere/kommander2-kubetools" }}:{{ .Values.kubetools.image.tag }}" - command: ["/bin/bash","-c"] - args: ["/bin/scripts/pre_process_kcore.sh"] - volumeMounts: - - name: script - mountPath: /bin/scripts - volumes: - - name: script - configMap: - defaultMode: 0770 - name: {{ .Chart.Name }}-pre-upgrade - restartPolicy: OnFailure ----