Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVEREST-1512 | Support for running pre-upgrade checks #404

Merged
merged 11 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions charts/everest/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dependencies:
- name: common
repository: file://charts/common
version: 0.0.3
version: 0.0.4
- name: everest-db-namespace
repository: file://charts/everest-db-namespace
version: 0.0.0
digest: sha256:99b7426a3f8df9d34dbdc6be2934e6bbde5351b5aa8f0ce4ce78ec18451c8b55
generated: "2024-10-31T16:32:12.88258+05:30"
digest: sha256:2b5ec4cba791a9062cafe0a4eced850516b1f28b53b32a2f4a6787e9c941cbee
generated: "2024-11-05T14:31:28.077684+05:30"
5 changes: 5 additions & 0 deletions charts/everest/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ release: prepare-chart
release-dev: IMAGE_PREFIX=perconalab
release-dev: prepare-chart

deps:
helm dependency update .
helm dependency update ./charts/everest-db-namespace

docs-gen:
docker run --rm -v "$(PWD)/:/helm-docs" -u $(shell id -u) jnorwood/helm-docs:v1.9.1

2 changes: 2 additions & 0 deletions charts/everest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ The following table shows the configurable parameters of the Percona Everest cha
| server.rbac | string | `"g, admin, role:admin\n"` | RBAC policy for Everest. |
| server.resources | object | `{"limits":{"cpu":"200m","memory":"500Mi"},"requests":{"cpu":"100m","memory":"20Mi"}}` | Resources to allocate for the server container. |
| telemetry | bool | `true` | If set, enabled sending telemetry information. |
| upgrade.preflightChecks | bool | `true` | If set, run preliminary checks before upgrading. It is strongly recommended to enable this setting. |
| versionMetadataURL | string | `"https://check.percona.com"` | URL of the Version Metadata Service. |
4 changes: 2 additions & 2 deletions charts/everest/charts/common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: common
description: A library chart for Everest containing common resources.
type: library
version: 0.0.3
appVersion: "0.0.2"
version: 0.0.4
appVersion: "0.0.3"
maintainers:
- name: mayankshah1607
email: [email protected]
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.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.0.2](https://img.shields.io/badge/AppVersion-0.0.2-informational?style=flat-square)
![Version: 0.0.4](https://img.shields.io/badge/Version-0.0.4-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
11 changes: 7 additions & 4 deletions charts/everest/charts/common/templates/_csv_cleanup.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook": pre-delete
"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-delete-policy": hook-succeeded
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
rules:
- apiGroups:
- operators.coreos.com
Expand All @@ -33,7 +35,8 @@ metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -50,7 +53,7 @@ metadata:
namespace: {{ .namespace }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
template:
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook": pre-delete
"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-delete-policy": hook-succeeded
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
rules:
- apiGroups:
- everest.percona.com
Expand All @@ -35,7 +37,8 @@ metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -52,7 +55,7 @@ metadata:
namespace: {{ .namespace }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
template:
spec:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# @param .namespace The namespace where the operator is installed
# @param .namespace The namespace where the operators are installed
#
{{- define "everest.installplanApprover" }}
{{- $hookName := "everest-helm-post-install-hook" }}
Expand All @@ -9,15 +9,17 @@ metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook": post-install
"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-delete-policy": hook-succeeded
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
rules:
- apiGroups:
- operators.coreos.com
Expand Down Expand Up @@ -45,7 +47,8 @@ metadata:
name: {{ $hookName }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand All @@ -61,8 +64,8 @@ metadata:
name: {{ $hookName }}-{{ randNumeric 6 }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": hook-succeeded
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
template:
spec:
Expand Down
38 changes: 38 additions & 0 deletions charts/everest/charts/common/templates/_upgrade_checks.yaml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# @param .namespace The namespace where the operator is installed
# @param .version Version to upgrade to
# @param .versionMetadataURL The URL of the version metadata service
#
{{- define "everest.preUpgradeChecks" }}
{{- $hookName := printf "everest-helm-pre-upgrade-hook" }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ $hookName }}-{{ randNumeric 6 }}
namespace: {{ .namespace }}
annotations:
"helm.sh/hook": pre-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
template:
spec:
containers:
- image: alpine:3.20
name: {{ $hookName }}
command:
- /bin/sh
- -c
- |
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
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 }}
mayankshah1607 marked this conversation as resolved.
Show resolved Hide resolved
dnsPolicy: ClusterFirst
restartPolicy: OnFailure
terminationGracePeriodSeconds: 30
{{- 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.3
digest: sha256:9c473ddc333f399701ca42304b7c24defb59270a6e04d75254be0ccf6eec438a
generated: "2024-10-31T16:32:16.267628+05:30"
version: 0.0.4
digest: sha256:d4b492b530b0ae0b3234a3d287a2d3873c99d3dd273c569e82e6eeb83380abc9
generated: "2024-11-05T14:31:44.457971+05:30"
1 change: 1 addition & 0 deletions charts/everest/charts/everest-db-namespace/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: A sub-chart for provisioning Everest DB namespaces.
type: application
version: 0.0.0
appVersion: 0.0.0
kubeVersion: '>= 1.27.0'
dependencies:
- name: common
version: 0.0.*
Expand Down
2 changes: 2 additions & 0 deletions charts/everest/charts/everest-db-namespace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ A sub-chart for provisioning Everest DB namespaces.

## Requirements

Kubernetes: `>= 1.27.0`

| Repository | Name | Version |
|------------|------|---------|
| file://../common | common | 0.0.* |
Expand Down
1 change: 1 addition & 0 deletions charts/everest/templates/everest-monitoring/hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: We will remove the below hooks once we use the VictoriaMetrics Helm chart directly as a dependency.
{{- include "everest.csvCleanup" (dict "namespace" .Values.monitoring.namespace) }}
---
{{- include "everest.installplanApprover" (dict "namespace" .Values.monitoring.namespace) }}
Expand Down
3 changes: 3 additions & 0 deletions charts/everest/templates/hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if .Values.upgrade.preflightChecks }}
{{- include "everest.preUpgradeChecks" (dict "namespace" (include "everest.namespace" .) "version" .Chart.Version "versionMetadataURL" .Values.versionMetadataURL) }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/everest/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ operator:
requests:
cpu: 5m
memory: 64Mi
# -- URL of the Version Metadata Service.
versionMetadataURL: "https://check.percona.com"
upgrade:
# -- If set, run preliminary checks before upgrading.
# It is strongly recommended to enable this setting.
preflightChecks: true
olm:
# -- Namespace where OLM is installed. Do no change unless you know what you are doing.
namespace: everest-olm
Expand Down
Loading