Skip to content

Commit 188ab38

Browse files
authored
feat: add chart for pre-upgrade and post-upgrade (#280)
1 parent a23d2ab commit 188ab38

File tree

12 files changed

+462
-0
lines changed

12 files changed

+462
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: release-tag-installer-post-upgrade-2-5-1
2+
3+
on:
4+
push:
5+
tags:
6+
- 'post-upgrade-2-5-1/[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
package:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Authenticate with GitHub App
14+
id: authenticate
15+
uses: tibdex/github-app-token@v1
16+
with:
17+
app_id: ${{ secrets.APP_ID }}
18+
private_key: ${{ secrets.PRIVATE_KEY }}
19+
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Extract version
24+
run: |
25+
CHART_VERSION=${GITHUB_REF#refs/tags/post-upgrade-2-5-1/}
26+
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_ENV
27+
28+
- name: Print Version
29+
run: |
30+
echo CHART_VERSION:${{ env.CHART_VERSION }}
31+
32+
- name: Replace CHART_VERSION in post-upgrade-2-5-1/Chart.yaml
33+
run: sed -i 's/CHART_VERSION/${{ env.CHART_VERSION }}/g' ./post-upgrade-2-5-1/Chart.yaml
34+
35+
# Stage only the chart you want to publish
36+
- name: Prepare charts_dir
37+
run: |
38+
mkdir -p _post-upgrade-2-5-1
39+
cp -R post-upgrade-2-5-1 _post-upgrade-2-5-1/
40+
41+
- name: Publish Helm chart
42+
uses: stefanprodan/helm-gh-pages@master
43+
with:
44+
token: ${{ steps.authenticate.outputs.token }}
45+
charts_dir: _post-upgrade-2-5-1
46+
charts_url: https://charts.krateo.io
47+
owner: krateoplatformops
48+
repository: helm-charts
49+
branch: gh-pages
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: release-tag-installer-pre-upgrade-2-5-0
2+
3+
on:
4+
push:
5+
tags:
6+
- 'pre-upgrade-2-5-0/[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
package:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Authenticate with GitHub App
14+
id: authenticate
15+
uses: tibdex/github-app-token@v1
16+
with:
17+
app_id: ${{ secrets.APP_ID }}
18+
private_key: ${{ secrets.PRIVATE_KEY }}
19+
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Extract version
24+
run: |
25+
CHART_VERSION=${GITHUB_REF#refs/tags/pre-upgrade-2-5-0/}
26+
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_ENV
27+
28+
- name: Print Version
29+
run: |
30+
echo CHART_VERSION:${{ env.CHART_VERSION }}
31+
32+
- name: Replace CHART_VERSION in pre-upgrade-2-5-0/Chart.yaml
33+
run: sed -i 's/CHART_VERSION/${{ env.CHART_VERSION }}/g' ./pre-upgrade-2-5-0/Chart.yaml
34+
35+
# Stage only the chart you want to publish
36+
- name: Prepare charts_dir
37+
run: |
38+
mkdir -p _pre-upgrade-2-5-0
39+
cp -R pre-upgrade-2-5-0 _pre-upgrade-2-5-0/
40+
41+
- name: Publish Helm chart
42+
uses: stefanprodan/helm-gh-pages@master
43+
with:
44+
token: ${{ steps.authenticate.outputs.token }}
45+
charts_dir: _pre-upgrade-2-5-0
46+
charts_url: https://charts.krateo.io
47+
owner: krateoplatformops
48+
repository: helm-charts
49+
branch: gh-pages
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: release-tag-installer-pre-upgrade-2-5-1
2+
3+
on:
4+
push:
5+
tags:
6+
- 'pre-upgrade-2-5-1/[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
package:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Authenticate with GitHub App
14+
id: authenticate
15+
uses: tibdex/github-app-token@v1
16+
with:
17+
app_id: ${{ secrets.APP_ID }}
18+
private_key: ${{ secrets.PRIVATE_KEY }}
19+
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Extract version
24+
run: |
25+
CHART_VERSION=${GITHUB_REF#refs/tags/pre-upgrade-2-5-1/}
26+
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_ENV
27+
28+
- name: Print Version
29+
run: |
30+
echo CHART_VERSION:${{ env.CHART_VERSION }}
31+
32+
- name: Replace CHART_VERSION in pre-upgrade-2-5-1/Chart.yaml
33+
run: sed -i 's/CHART_VERSION/${{ env.CHART_VERSION }}/g' ./pre-upgrade-2-5-1/Chart.yaml
34+
35+
# Stage only the chart you want to publish
36+
- name: Prepare charts_dir
37+
run: |
38+
mkdir -p _pre-upgrade-2-5-1
39+
cp -R pre-upgrade-2-5-1 _pre-upgrade-2-5-1/
40+
41+
- name: Publish Helm chart
42+
uses: stefanprodan/helm-gh-pages@master
43+
with:
44+
token: ${{ steps.authenticate.outputs.token }}
45+
charts_dir: _pre-upgrade-2-5-1
46+
charts_url: https://charts.krateo.io
47+
owner: krateoplatformops
48+
repository: helm-charts
49+
branch: gh-pages
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: installer-post-upgrade-2-5-1
3+
description: Krateo PlatformOps Chart to execute post upgrade to version 2.5.0
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: CHART_VERSION
19+
20+
home: https://krateo.io
21+
icon: "https://github.com/krateoplatformops/krateo/blob/main/docs/media/logo.svg"
22+
23+
sources:
24+
- https://github.com/krateoplatformops/installer-chart
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{{- $sa := lookup "v1" "ServiceAccount" .Release.Namespace "helm-runner" }}
2+
{{- if not $sa }}
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: helm-runner
7+
namespace: {{ .Release.Namespace }}
8+
annotations:
9+
"helm.sh/hook": pre-install,pre-upgrade
10+
"helm.sh/hook-weight": "0"
11+
---
12+
{{- end }}
13+
14+
{{- $crb := lookup "rbac.authorization.k8s.io/v1" "ClusterRoleBinding" "" "helm-runner-cluster-admin" }}
15+
{{- if not $crb }}
16+
# For simplicity, cluster-admin. Tighten later if needed.
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: ClusterRoleBinding
19+
metadata:
20+
name: helm-runner-cluster-admin
21+
annotations:
22+
"helm.sh/hook": pre-install,pre-upgrade
23+
"helm.sh/hook-weight": "1"
24+
roleRef:
25+
apiGroup: rbac.authorization.k8s.io
26+
kind: ClusterRole
27+
name: cluster-admin
28+
subjects:
29+
- kind: ServiceAccount
30+
name: helm-runner
31+
namespace: {{ .Release.Namespace }}
32+
---
33+
{{- end }}
34+
35+
{{- $job := lookup "batch/v1" "Job" .Release.Namespace "krateo-post-upgrade-2-5-1" }}
36+
{{- if not $job }}
37+
apiVersion: batch/v1
38+
kind: Job
39+
metadata:
40+
name: krateo-post-upgrade-2-5-1
41+
namespace: {{ .Release.Namespace }}
42+
annotations:
43+
"helm.sh/hook": pre-install,pre-upgrade
44+
"helm.sh/hook-weight": "2"
45+
spec:
46+
backoffLimit: 4
47+
ttlSecondsAfterFinished: 3600
48+
template:
49+
spec:
50+
serviceAccountName: helm-runner
51+
restartPolicy: OnFailure
52+
containers:
53+
- name: runner
54+
image: dtzar/helm-kubectl:3.14.4
55+
imagePullPolicy: IfNotPresent
56+
command: ["/bin/sh","-lc"]
57+
args:
58+
- |
59+
set -euo pipefail
60+
61+
echo "Step 4) Add & update 'marketplace' repo ..."
62+
helm repo add marketplace https://marketplace.krateo.io
63+
helm repo update marketplace
64+
65+
echo "Step 5) Uninstall old 'portal' release if present ..."
66+
helm uninstall portal -n {{ .Release.Namespace }} || true
67+
68+
echo "Step 6) Install 'portal' from marketplace ..."
69+
helm install portal marketplace/portal \
70+
-n {{ .Release.Namespace }} \
71+
--version 1.0.0 \
72+
--wait
73+
74+
echo "Post-upgrade 2.5.1 job done ✅"
75+
{{- end }}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Default values for crd-chart.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.

pre-upgrade-2-5-0-chart/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: installer-pre-upgrade-2-5-0
3+
description: Krateo PlatformOps Chart to execute pre upgrade to version 2.5.0
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: CHART_VERSION
19+
20+
home: https://krateo.io
21+
icon: "https://github.com/krateoplatformops/krateo/blob/main/docs/media/logo.svg"
22+
23+
sources:
24+
- https://github.com/krateoplatformops/installer-chart
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{- $sa := lookup "v1" "ServiceAccount" .Release.Namespace "helm-runner" }}
2+
{{- if not $sa }}
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: helm-runner
7+
namespace: {{ .Release.Namespace }}
8+
annotations:
9+
"helm.sh/hook": pre-install,pre-upgrade
10+
"helm.sh/hook-weight": "0"
11+
---
12+
{{- end }}
13+
14+
{{- $crb := lookup "rbac.authorization.k8s.io/v1" "ClusterRoleBinding" "" "helm-runner-cluster-admin" }}
15+
{{- if not $crb }}
16+
# For simplicity, cluster-admin. Tighten later if needed.
17+
apiVersion: rbac.authorization.k8s.io/v1
18+
kind: ClusterRoleBinding
19+
metadata:
20+
name: helm-runner-cluster-admin
21+
annotations:
22+
"helm.sh/hook": pre-install,pre-upgrade
23+
"helm.sh/hook-weight": "1"
24+
roleRef:
25+
apiGroup: rbac.authorization.k8s.io
26+
kind: ClusterRole
27+
name: cluster-admin
28+
subjects:
29+
- kind: ServiceAccount
30+
name: helm-runner
31+
namespace: {{ .Release.Namespace }}
32+
---
33+
{{- end }}
34+
35+
{{- $job := lookup "batch/v1" "Job" .Release.Namespace "krateo-pre-upgrade-2-5-0" }}
36+
{{- if not $job }}
37+
apiVersion: batch/v1
38+
kind: Job
39+
metadata:
40+
name: krateo-pre-upgrade-2-5-0
41+
namespace: {{ .Release.Namespace }}
42+
annotations:
43+
"helm.sh/hook": pre-install,pre-upgrade
44+
"helm.sh/hook-weight": "2"
45+
spec:
46+
backoffLimit: 4
47+
ttlSecondsAfterFinished: 3600
48+
template:
49+
spec:
50+
serviceAccountName: helm-runner
51+
restartPolicy: OnFailure
52+
containers:
53+
- name: runner
54+
image: dtzar/helm-kubectl:3.14.4
55+
imagePullPolicy: IfNotPresent
56+
command: ["/bin/sh","-lc"]
57+
args:
58+
- |
59+
set -euo pipefail
60+
61+
echo "Annotate/label CRD compositionreferences.resourcetrees.krateo.io..."
62+
kubectl annotate crd compositionreferences.resourcetrees.krateo.io \
63+
meta.helm.sh/release-name=resource-tree-handler \
64+
meta.helm.sh/release-namespace={{ .Release.Namespace }} \
65+
app.kubernetes.io/managed-by=Helm \
66+
--overwrite
67+
68+
kubectl label crd compositionreferences.resourcetrees.krateo.io \
69+
app.kubernetes.io/managed-by=Helm --overwrite
70+
71+
echo "Annotate secret admin-password in {{ .Release.Namespace }}..."
72+
kubectl annotate secret admin-password -n {{ .Release.Namespace }} \
73+
meta.helm.sh/release-name=composable-portal-starter \
74+
meta.helm.sh/release-namespace={{ .Release.Namespace }} \
75+
app.kubernetes.io/managed-by=Helm \
76+
--overwrite
77+
78+
echo "Annotate user admin in {{ .Release.Namespace }}..."
79+
kubectl annotate user admin -n {{ .Release.Namespace }} \
80+
meta.helm.sh/release-name=composable-portal-starter \
81+
meta.helm.sh/release-namespace={{ .Release.Namespace }} \
82+
app.kubernetes.io/managed-by=Helm \
83+
--overwrite
84+
85+
echo "Pre-upgrade 2.5.0 job done ✅"
86+
{{- end }}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Default values for crd-chart.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.

0 commit comments

Comments
 (0)