Skip to content

Commit b500d06

Browse files
CLOUDP-299786: Removed helm-charts as submodule. Added helm-charts as a simple folder (#2209)
* Removed helm-charts as submodule. Added helm-charts as a simple folder * Bumped up helm charts * Added a way to verify if CRDs helm chart is synced with the bundle * Added job to sync helm-charts after every merged PR * Modified commit message
1 parent 194bc76 commit b500d06

File tree

74 files changed

+8271
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+8271
-13
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Sync helm-charts
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
pull_request:
7+
types:
8+
- closed
9+
10+
jobs:
11+
verify-helm-changes:
12+
if: github.event.pull_request.merged == true && !startsWith(github.event.pull_request.title, 'dependabot')
13+
name: Verify if AKO helm charts need updates
14+
runs-on: ubuntu-latest
15+
environment: release
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
steps:
20+
- name: Checkout AKO repo
21+
uses: actions/checkout@v4
22+
23+
- name: Install devbox
24+
uses: jetify-com/[email protected]
25+
with:
26+
enable-cache: "true"
27+
28+
- name: Generate GitHub App Token
29+
id: generate_token
30+
uses: actions/create-github-app-token@v1
31+
with:
32+
app-id: ${{ secrets.AKO_RELEASER_APP_ID }}
33+
private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }}
34+
owner: ${{ github.repository_owner }}
35+
repositories: |
36+
mongodb-atlas-kubernetes
37+
helm-charts
38+
39+
- name: Checkout Helm charts repo
40+
uses: actions/checkout@v4
41+
with:
42+
repository: mongodb/helm-charts
43+
token: ${{ steps.generate_token.outputs.token }}
44+
path: helm-charts-cloned
45+
persist-credentials: true
46+
47+
- name: Patch original AKO chart dependencies
48+
run: |
49+
sed -i 's|repository: "file://../../helm-charts/atlas-operator-crds"|repository: "https://mongodb.github.io/helm-charts"|' helm-charts/atlas-operator/Chart.yaml
50+
51+
- name: Generate AKO bundle
52+
env:
53+
VERSION: "1.0.0"
54+
run: |
55+
devbox run -- "make generate bundle"
56+
57+
- name: Verify if CRDs were changed
58+
id: crd-check
59+
env:
60+
HELM_CRDS_PATH: "./helm-charts-cloned/charts/atlas-operator-crds/templates"
61+
run: |
62+
devbox run -- "make helm-upd-crds"
63+
64+
- name: Verify if RBAC were changed
65+
id: rbac-check
66+
env:
67+
HELM_RBAC_FILE: "./helm-charts-cloned/charts/atlas-operator/rbac.yaml"
68+
run: |
69+
devbox run -- "make helm-upd-rbac"
70+
71+
- name: Verify if helm-charts need to be synced
72+
run: |
73+
for $dir in $(ls ./helm-charts); do
74+
if [[ -d "./helm-charts-cloned/charts/$dir" ]]; then
75+
if [[ -n $(diff -r ./helm-charts/$dir ./helm-charts-cloned/charts/$dir) ]]; then
76+
echo "Changes detected for the Chart: $dir"
77+
cp -r ./helm-charts/$dir ./helm-charts-cloned/charts/$dir
78+
fi
79+
fi
80+
done
81+
82+
- name: Create PR for helm-charts repo
83+
env:
84+
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
85+
run: |
86+
cd ./helm-charts-cloned
87+
88+
if [[ -n $(git status --porcelain) ]]; then
89+
jobname=${{ github.run_id }}
90+
if [[ -n "${{ github.event.pull_request.title }}" ]]; then
91+
jobname=$(echo "${{ github.event.pull_request.title }}" | tr -c '[:alnum:]-_' '_')
92+
fi
93+
94+
BRANCH_NAME=ako-helm-update-"${jobname}"
95+
COMMIT_MSG="[autogenerated] update AKO helm-charts ${jobname}"
96+
echo "Changes detected. Creating PR"
97+
98+
git config --local user.email "[email protected]"
99+
git config --local user.name "ako-releaser"
100+
101+
git checkout -b "${BRANCH_NAME}"
102+
git add .
103+
git commit -m "${COMMIT_MSG}"
104+
105+
git push origin "${BRANCH_NAME}"
106+
107+
gh pr create --base main --head "${BRANCH_NAME}" --title "${COMMIT_MSG}" --body "${COMMIT_MSG}"
108+
fi
109+
echo "Nothing to commit"

.github/workflows/update-helm.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ name: Helm update
33
on:
44
workflow_call:
55
workflow_dispatch:
6-
pull_request:
7-
types:
8-
- closed
6+
# TODO: remove after the job "Sync helm-charts" is applied to the main branch
7+
# pull_request:
8+
# types:
9+
# - closed
910

1011
jobs:
1112
verify-helm-changes:

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "helm-charts"]
2-
path = helm-charts
3-
url = [email protected]:mongodb/helm-charts.git

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,23 @@ endif
287287
validate-manifests: generate manifests
288288
$(MAKE) check-missing-files
289289

290+
.PHONE: sync-crds-chart
291+
sync-crds-chart:
292+
@cp -r bundle/manifests/atlas.mongodb.com_* helm-charts/atlas-operator-crds/templates/
293+
294+
.PHONY: validate-crds-chart
295+
validate-crds-chart: ## Validate the CRDs in the Helm chart
296+
@echo "Validating CRDs in the Helm chart"
297+
@for file in bundle/manifests/atlas.mongodb.com_*.yaml; do \
298+
helm_file=helm-charts/atlas-operator-crds/templates/$$(basename $$file); \
299+
if ! cmp -s $$file $$helm_file; then \
300+
echo "CRD files do not match: $$file and $$helm_file"; \
301+
exit 1; \
302+
fi; \
303+
done
304+
@echo "All CRD files match"
305+
@cd helm-charts/atlas-operator-crds && helm template . > /dev/null
306+
290307
.PHONY: bundle
291308
bundle: manifests ## Generate bundle manifests and metadata, then validate generated files.
292309
@echo "Building bundle $(VERSION)"

helm-charts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

helm-charts/atlas-advanced/Chart.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: atlas-advanced
3+
description: This chart showcases Atlas Advanced (dedicated) deployment
4+
5+
type: application
6+
7+
version: 1.0.0
8+
9+
keywords:
10+
- mongodb
11+
- database
12+
- nosql
13+
home: https://github.com/mongodb/mongodb-atlas-kubernetes
14+
icon: https://webimages.mongodb.com/_com_assets/cms/kuyjf3vea2hg34taa-horizontal_default_slate_blue.svg
15+
appVersion: "2.4.1"
16+
maintainers:
17+
- name: MongoDB
18+
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "atlas-advanced.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "atlas-advanced.fullname" -}}
14+
{{- if .Values.deployment.name }}
15+
{{- .Values.deployment.name | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.deployment.name }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{- define "atlas-advanced.projectfullname" -}}
27+
{{- if .Values.project.name }}
28+
{{- .Values.project.name | trunc 63 | trimSuffix "-" }}
29+
{{- else }}
30+
{{- $name := default .Chart.Name .Values.project.name }}
31+
{{- if contains $name .Release.Name }}
32+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
33+
{{- else }}
34+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
35+
{{- end }}
36+
{{- end }}
37+
{{- end }}
38+
39+
{{/*
40+
Create chart name and version as used by the chart label.
41+
*/}}
42+
{{- define "atlas-advanced.chart" -}}
43+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
44+
{{- end }}
45+
46+
{{/*
47+
Common labels
48+
*/}}
49+
{{- define "atlas-advanced.labels" -}}
50+
helm.sh/chart: {{ include "atlas-advanced.chart" . }}
51+
{{ include "atlas-advanced.selectorLabels" . }}
52+
{{- if .Chart.AppVersion }}
53+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
54+
{{- end }}
55+
app.kubernetes.io/managed-by: {{ .Release.Service }}
56+
{{- end }}
57+
58+
{{/*
59+
Selector labels
60+
*/}}
61+
{{- define "atlas-advanced.selectorLabels" -}}
62+
app.kubernetes.io/name: {{ include "atlas-advanced.name" . }}
63+
app.kubernetes.io/instance: {{ .Release.Name }}
64+
{{- end }}
65+
66+
{{- define "generateRandomString" -}}
67+
{{ randAlphaNum 5 }}
68+
{{- end }}
69+
70+
{{- define "getInstanceSizeOrFail" -}}
71+
{{- $arg := . -}}
72+
{{ $instances := list "M10" "M20" "M30" "M40" "M50" "M60" "M80" "M100" "M140" "M200" "M300" "R40" "R50" "R60" "R80" "R200" "R300" "R400" "R700" "M40_NVME" "M50_NVME" "M60_NVME" "M80_NVME" "M200_NVME" "M400_NVME" }}
73+
{{- if not (has (toString $arg) $instances)}}
74+
{{- fail (printf "Instance size can only be one of: %s " (join "," $instances)) }}
75+
{{- end }}
76+
{{- $arg -}}
77+
{{- end }}
78+
79+
{{- define "getProviderNameOrFail" -}}
80+
{{- $arg := . -}}
81+
{{ $providers := list "AWS" "GCP" "AZURE" }}
82+
{{- if not (has (toString $arg) $providers) }}
83+
{{- fail (printf "Provider name can only be one of: %s. Got %s" (join "," $providers) $arg) }}
84+
{{- end }}
85+
{{- $arg -}}
86+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apiVersion: atlas.mongodb.com/v1
2+
kind: AtlasDeployment
3+
metadata:
4+
name: {{ include "atlas-advanced.fullname" $ }}
5+
labels:
6+
{{- include "atlas-advanced.labels" $ | nindent 4 }}
7+
namespace: {{ $.Release.Namespace }}
8+
spec:
9+
projectRef:
10+
name: {{ include "atlas-advanced.projectfullname" $ }}
11+
namespace: {{ $.Release.Namespace }}
12+
deploymentSpec:
13+
name: {{ include "atlas-advanced.fullname" $ }}
14+
clusterType: REPLICASET
15+
replicationSpecs:
16+
- zoneName: Zone 1
17+
regionConfigs:
18+
{{- range $idx, $val := index .Values.deployment.regions }}
19+
- regionName: {{ $val.name }}
20+
electableSpecs:
21+
instanceSize: {{ include "getInstanceSizeOrFail" $val.instanceSize }}
22+
nodeCount: {{ $val.nodeCount }}
23+
providerName: {{ include "getProviderNameOrFail" $val.providerName }}
24+
backingProviderName: {{ include "getProviderNameOrFail" $val.providerName }}
25+
priority: {{ $val.priority }}
26+
{{- if $val.autoscaling.enabled }}
27+
autoScaling:
28+
compute:
29+
enabled: true
30+
minInstanceSize: {{ include "getInstanceSizeOrFail" $val.autoscaling.min }}
31+
maxInstanceSize: {{ include "getInstanceSizeOrFail" $val.autoscaling.max }}
32+
{{- end }}
33+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "atlas-advanced.fullname" $ }}-{{ .Values.dbUser.name }}
5+
namespace: {{ $.Release.Namespace }}
6+
labels:
7+
atlas.mongodb.com/type: "credentials"
8+
{{- include "atlas-advanced.labels" $ | nindent 4 }}
9+
type: Opaque
10+
stringData:
11+
password: {{ .Values.dbUser.password | default (randAlphaNum 32 | b64enc)| quote }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: atlas.mongodb.com/v1
2+
kind: AtlasDatabaseUser
3+
metadata:
4+
name: {{ include "atlas-advanced.fullname" $ }}-{{ .Values.dbUser.name }}
5+
namespace: {{ $.Release.Namespace }}
6+
labels:
7+
{{- include "atlas-advanced.labels" $ | nindent 4 }}
8+
spec:
9+
username: {{ .Values.dbUser.name }}
10+
databaseName: {{ .Values.dbUser.databaseName }}
11+
passwordSecretRef:
12+
name: {{ include "atlas-advanced.fullname" $ }}-{{ .Values.dbUser.name }}
13+
projectRef:
14+
name: {{ include "atlas-advanced.projectfullname" $ }}
15+
namespace: {{ $.Release.Namespace }}
16+
roles:
17+
- roleName: "readWriteAnyDatabase"
18+
databaseName: "admin"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: atlas.mongodb.com/v1
2+
kind: AtlasProject
3+
metadata:
4+
name: {{ include "atlas-advanced.projectfullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "atlas-advanced.labels" . | nindent 4 }}
8+
spec:
9+
name: {{ include "atlas-advanced.projectfullname" . }}
10+
connectionSecretRef:
11+
name: {{ include "atlas-advanced.fullname" . }}-secret
12+
namespace: {{ $.Release.Namespace }}
13+
projectIpAccessList:
14+
- comment: "Example"
15+
cidrBlock: {{ .Values.project.cidrEntry }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
type: Opaque
4+
metadata:
5+
name: {{ include "atlas-advanced.fullname" . }}-secret
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
atlas.mongodb.com/type: "credentials"
9+
data:
10+
orgId: {{ .Values.secret.orgID | b64enc }}
11+
publicApiKey: {{ .Values.secret.publicKey | b64enc }}
12+
privateApiKey: {{ .Values.secret.privateKey | b64enc }}

0 commit comments

Comments
 (0)