Skip to content

Commit

Permalink
Merge pull request #444 from percona/EVEREST-1746
Browse files Browse the repository at this point in the history
EVEREST-1746 | Fix broken script in pre-upgrade hook
  • Loading branch information
mayankshah1607 authored Dec 12, 2024
2 parents 15af000 + 98643ab commit b299aa7
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 10 deletions.
6 changes: 3 additions & 3 deletions charts/everest/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies:
- name: common
repository: file://charts/common
version: 0.0.9
version: 0.0.10
- name: everest-db-namespace
repository: file://charts/everest-db-namespace
version: 0.0.0
Expand All @@ -11,5 +11,5 @@ dependencies:
- name: victoria-metrics-operator
repository: https://victoriametrics.github.io/helm-charts
version: 0.37.0
digest: sha256:8a1adcd2e53bc836e6a7a238a85abb4e751de72dc83eef33829c8a1bc548c7af
generated: "2024-12-09T21:17:34.358806+05:30"
digest: sha256:7ff4b6b7298b24aa96d2bf73cb3ce3c891997f016815e18acaaf326c603621e1
generated: "2024-12-12T18:45:12.381768+05:30"
2 changes: 1 addition & 1 deletion charts/everest/charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: common
description: A library chart for Everest containing common resources.
type: library
version: 0.0.9
version: 0.0.10
appVersion: "0.0.3"
maintainers:
- name: mayankshah1607
Expand Down
2 changes: 1 addition & 1 deletion charts/everest/charts/common/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# common

![Version: 0.0.9](https://img.shields.io/badge/Version-0.0.9-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.0.3](https://img.shields.io/badge/AppVersion-0.0.3-informational?style=flat-square)
![Version: 0.0.10](https://img.shields.io/badge/Version-0.0.10-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.0.3](https://img.shields.io/badge/AppVersion-0.0.3-informational?style=flat-square)

A library chart for Everest containing common resources.

Expand Down
59 changes: 57 additions & 2 deletions charts/everest/charts/common/templates/_upgrade_checks.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,48 @@
#
{{- define "everest.preUpgradeChecks" }}
{{- $hookName := printf "everest-helm-pre-upgrade-hook" }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ $hookName }}
subjects:
- kind: ServiceAccount
name: {{ $hookName }}
namespace: {{ .namespace }}
---
apiVersion: batch/v1
kind: Job
metadata:
Expand All @@ -21,18 +63,31 @@ spec:
name: {{ $hookName }}
command:
- /bin/sh
- -c
- -ec
- |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

# Map ARCH to match available builds
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "aarch64" ]; then
ARCH="arm64"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi

VERSION={{ .version }}
apk add --no-cache --quiet curl
curl -sSL -o everestctl https://github.com/percona/everest/releases/download/v${VERSION}/everestctl-${OS}-${ARCH}
chmod -R 777 ./everestctl

echo "Checking requirements for upgrade to version ${VERSION}"
./everestctl upgrade --dry-run --version-metadata-url={{ .versionMetadataURL }}
./everestctl upgrade --in-cluster --dry-run --version-metadata-url={{ .versionMetadataURL }} --kubeconfig=""
dnsPolicy: ClusterFirst
restartPolicy: OnFailure
terminationGracePeriodSeconds: 30
serviceAccount: {{ $hookName }}
serviceAccountName: {{ $hookName }}
{{- end }}
6 changes: 3 additions & 3 deletions charts/everest/charts/everest-db-namespace/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: common
repository: file://../common
version: 0.0.9
digest: sha256:9556a266d6497f3284b4df070b840145be1bff3c5ee235f81bf4a7973780e0d0
generated: "2024-12-09T21:17:37.704211+05:30"
version: 0.0.10
digest: sha256:d4cac358be2d69d442c3ab82ce0945f65ea1101909b3ec3a22202cc19dbcdae9
generated: "2024-12-12T18:45:16.470721+05:30"

0 comments on commit b299aa7

Please sign in to comment.