Skip to content

Commit

Permalink
CLOUDP-227413: AKO templates (#348)
Browse files Browse the repository at this point in the history
Added atlas basic and atlas-advanced charts
  • Loading branch information
igor-karpukhin authored Oct 11, 2024
1 parent 625a5cc commit 8ca3642
Show file tree
Hide file tree
Showing 20 changed files with 490 additions and 4 deletions.
23 changes: 23 additions & 0 deletions charts/atlas-advanced/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
18 changes: 18 additions & 0 deletions charts/atlas-advanced/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: atlas-advanced
description: This chart showcases Atlas Advanced (dedicated) deployment

type: application

version: 1.0.0

keywords:
- mongodb
- database
- nosql
home: https://github.com/mongodb/mongodb-atlas-kubernetes
icon: https://webimages.mongodb.com/_com_assets/cms/kuyjf3vea2hg34taa-horizontal_default_slate_blue.svg
appVersion: "2.4.1"
maintainers:
- name: MongoDB
email: [email protected]
86 changes: 86 additions & 0 deletions charts/atlas-advanced/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "atlas-advanced.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "atlas-advanced.fullname" -}}
{{- if .Values.deployment.name }}
{{- .Values.deployment.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.deployment.name }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "atlas-advanced.projectfullname" -}}
{{- if .Values.project.name }}
{{- .Values.project.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.project.name }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "atlas-advanced.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "atlas-advanced.labels" -}}
helm.sh/chart: {{ include "atlas-advanced.chart" . }}
{{ include "atlas-advanced.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "atlas-advanced.selectorLabels" -}}
app.kubernetes.io/name: {{ include "atlas-advanced.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "generateRandomString" -}}
{{ randAlphaNum 5 }}
{{- end }}

{{- define "getInstanceSizeOrFail" -}}
{{- $arg := . -}}
{{ $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" }}
{{- if not (has (toString $arg) $instances)}}
{{- fail (printf "Instance size can only be one of: %s " (join "," $instances)) }}
{{- end }}
{{- $arg -}}
{{- end }}

{{- define "getProviderNameOrFail" -}}
{{- $arg := . -}}
{{ $providers := list "AWS" "GCP" "AZURE" }}
{{- if not (has (toString $arg) $providers) }}
{{- fail (printf "Provider name can only be one of: %s. Got %s" (join "," $providers) $arg) }}
{{- end }}
{{- $arg -}}
{{- end }}
33 changes: 33 additions & 0 deletions charts/atlas-advanced/templates/atlas-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: atlas.mongodb.com/v1
kind: AtlasDeployment
metadata:
name: {{ include "atlas-advanced.fullname" $ }}
labels:
{{- include "atlas-advanced.labels" $ | nindent 4 }}
namespace: {{ $.Release.Namespace }}
spec:
projectRef:
name: {{ include "atlas-advanced.projectfullname" $ }}
namespace: {{ $.Release.Namespace }}
deploymentSpec:
name: {{ include "atlas-advanced.fullname" $ }}
clusterType: REPLICASET
replicationSpecs:
- zoneName: Zone 1
regionConfigs:
{{- range $idx, $val := index .Values.deployment.regions }}
- regionName: {{ $val.name }}
electableSpecs:
instanceSize: {{ include "getInstanceSizeOrFail" $val.instanceSize }}
nodeCount: {{ $val.nodeCount }}
providerName: {{ include "getProviderNameOrFail" $val.providerName }}
backingProviderName: {{ include "getProviderNameOrFail" $val.providerName }}
priority: {{ $val.priority }}
{{- if $val.autoscaling.enabled }}
autoScaling:
compute:
enabled: true
minInstanceSize: {{ include "getInstanceSizeOrFail" $val.autoscaling.min }}
maxInstanceSize: {{ include "getInstanceSizeOrFail" $val.autoscaling.max }}
{{- end }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/atlas-advanced/templates/atlas-mongodb-user-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "atlas-advanced.fullname" $ }}-{{ .Values.dbUser.name }}
namespace: {{ $.Release.Namespace }}
labels:
atlas.mongodb.com/type: "credentials"
{{- include "atlas-advanced.labels" $ | nindent 4 }}
type: Opaque
stringData:
password: {{ .Values.dbUser.password | default (randAlphaNum 32 | b64enc)| quote }}
18 changes: 18 additions & 0 deletions charts/atlas-advanced/templates/atlas-mongodb-user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: atlas.mongodb.com/v1
kind: AtlasDatabaseUser
metadata:
name: {{ include "atlas-advanced.fullname" $ }}-{{ .Values.dbUser.name }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "atlas-advanced.labels" $ | nindent 4 }}
spec:
username: {{ .Values.dbUser.name }}
databaseName: {{ .Values.dbUser.databaseName }}
passwordSecretRef:
name: {{ include "atlas-advanced.fullname" $ }}-{{ .Values.dbUser.name }}
projectRef:
name: {{ include "atlas-advanced.projectfullname" $ }}
namespace: {{ $.Release.Namespace }}
roles:
- roleName: "readWriteAnyDatabase"
databaseName: "admin"
15 changes: 15 additions & 0 deletions charts/atlas-advanced/templates/atlas-project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
name: {{ include "atlas-advanced.projectfullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlas-advanced.labels" . | nindent 4 }}
spec:
name: {{ include "atlas-advanced.projectfullname" . }}
connectionSecretRef:
name: {{ include "atlas-advanced.fullname" . }}-secret
namespace: {{ $.Release.Namespace }}
projectIpAccessList:
- comment: "Example"
cidrBlock: {{ .Values.project.cidrEntry }}
12 changes: 12 additions & 0 deletions charts/atlas-advanced/templates/atlas-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: {{ include "atlas-advanced.fullname" . }}-secret
namespace: {{ .Release.Namespace }}
labels:
atlas.mongodb.com/type: "credentials"
data:
orgId: {{ .Values.secret.orgID | b64enc }}
publicApiKey: {{ .Values.secret.publicKey | b64enc }}
privateApiKey: {{ .Values.secret.privateKey | b64enc }}
43 changes: 43 additions & 0 deletions charts/atlas-advanced/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
secret:
orgID: ""
privateKey: ""
publicKey: ""

project:
name: ""
cidrEntry: 0.0.0.0/0

deployment:
regions:
# For AWS: "US_GOV_WEST_1" "US_GOV_EAST_1" "US_EAST_1" "US_EAST_2" "US_WEST_1" "US_WEST_2" "CA_CENTRAL_1" "EU_NORTH_1" "EU_WEST_1" "EU_WEST_2" "EU_WEST_3" "EU_CENTRAL_1" "EU_CENTRAL_2" "AP_EAST_1" "AP_NORTHEAST_1" "AP_NORTHEAST_2" "AP_NORTHEAST_3" "AP_SOUTHEAST_1" "AP_SOUTHEAST_2" "AP_SOUTHEAST_3" "AP_SOUTHEAST_4" "AP_SOUTH_1" "AP_SOUTH_2" "SA_EAST_1" "CN_NORTH_1" "CN_NORTHWEST_1" "ME_SOUTH_1" "ME_CENTRAL_1" "AF_SOUTH_1" "EU_SOUTH_1" "EU_SOUTH_2" "IL_CENTRAL_1" "CA_WEST_1" "GLOBAL"
# For GCP: "EASTERN_US" "EASTERN_US_AW" "US_EAST_4" "US_EAST_4_AW" "US_EAST_5" "US_EAST_5_AW" "US_WEST_2" "US_WEST_2_AW" "US_WEST_3" "US_WEST_3_AW" "US_WEST_4" "US_WEST_4_AW" "US_SOUTH_1" "US_SOUTH_1_AW" "CENTRAL_US" "CENTRAL_US_AW" "WESTERN_US" "WESTERN_US_AW" "NORTH_AMERICA_NORTHEAST_1" "NORTH_AMERICA_NORTHEAST_2" "SOUTH_AMERICA_EAST_1" "SOUTH_AMERICA_WEST_1" "WESTERN_EUROPE" "EUROPE_NORTH_1" "EUROPE_WEST_2" "EUROPE_WEST_3" "EUROPE_WEST_4" "EUROPE_WEST_6" "EUROPE_WEST_8" "EUROPE_WEST_9" "EUROPE_WEST_10" "EUROPE_WEST_12" "EUROPE_SOUTHWEST_1" "EUROPE_CENTRAL_2" "MIDDLE_EAST_CENTRAL_1" "MIDDLE_EAST_CENTRAL_2" "MIDDLE_EAST_WEST_1" "AUSTRALIA_SOUTHEAST_1" "AUSTRALIA_SOUTHEAST_2" "EASTERN_ASIA_PACIFIC" "NORTHEASTERN_ASIA_PACIFIC" "SOUTHEASTERN_ASIA_PACIFIC" "ASIA_EAST_2" "ASIA_NORTHEAST_2" "ASIA_NORTHEAST_3" "ASIA_SOUTH_1" "ASIA_SOUTH_2" "ASIA_SOUTHEAST_2"
# FOR AZURE: "US_CENTRAL" "US_EAST" "US_EAST_2" "US_NORTH_CENTRAL" "US_WEST" "US_SOUTH_CENTRAL" "EUROPE_NORTH" "EUROPE_WEST" "US_WEST_CENTRAL" "US_WEST_2" "US_WEST_3" "CANADA_EAST" "CANADA_CENTRAL" "BRAZIL_SOUTH" "BRAZIL_SOUTHEAST" "AUSTRALIA_CENTRAL" "AUSTRALIA_CENTRAL_2" "AUSTRALIA_EAST" "AUSTRALIA_SOUTH_EAST" "GERMANY_CENTRAL" "GERMANY_NORTH_EAST" "GERMANY_WEST_CENTRAL" "GERMANY_NORTH" "SWEDEN_CENTRAL" "SWEDEN_SOUTH" "SWITZERLAND_NORTH" "SWITZERLAND_WEST" "UK_SOUTH" "UK_WEST" "NORWAY_EAST" "NORWAY_WEST" "INDIA_CENTRAL" "INDIA_SOUTH" "INDIA_WEST" "CHINA_EAST" "CHINA_NORTH" "ASIA_EAST" "JAPAN_EAST" "JAPAN_WEST" "ASIA_SOUTH_EAST" "KOREA_CENTRAL" "KOREA_SOUTH" "FRANCE_CENTRAL" "FRANCE_SOUTH" "SOUTH_AFRICA_NORTH" "SOUTH_AFRICA_WEST" "UAE_CENTRAL" "UAE_NORTH" "QATAR_CENTRAL"
# See the up to date list of regions and providers here: https://www.mongodb.com/docs/atlas/cloud-providers-regions/
- name: US_EAST_1
providerName: AWS
instanceSize: M10
nodeCount: 2
priority: 7
autoscaling:
enabled: true
min: M10
max: M20
# For AWS: "US_GOV_WEST_1" "US_GOV_EAST_1" "US_EAST_1" "US_EAST_2" "US_WEST_1" "US_WEST_2" "CA_CENTRAL_1" "EU_NORTH_1" "EU_WEST_1" "EU_WEST_2" "EU_WEST_3" "EU_CENTRAL_1" "EU_CENTRAL_2" "AP_EAST_1" "AP_NORTHEAST_1" "AP_NORTHEAST_2" "AP_NORTHEAST_3" "AP_SOUTHEAST_1" "AP_SOUTHEAST_2" "AP_SOUTHEAST_3" "AP_SOUTHEAST_4" "AP_SOUTH_1" "AP_SOUTH_2" "SA_EAST_1" "CN_NORTH_1" "CN_NORTHWEST_1" "ME_SOUTH_1" "ME_CENTRAL_1" "AF_SOUTH_1" "EU_SOUTH_1" "EU_SOUTH_2" "IL_CENTRAL_1" "CA_WEST_1" "GLOBAL"
# For GCP: "EASTERN_US" "EASTERN_US_AW" "US_EAST_4" "US_EAST_4_AW" "US_EAST_5" "US_EAST_5_AW" "US_WEST_2" "US_WEST_2_AW" "US_WEST_3" "US_WEST_3_AW" "US_WEST_4" "US_WEST_4_AW" "US_SOUTH_1" "US_SOUTH_1_AW" "CENTRAL_US" "CENTRAL_US_AW" "WESTERN_US" "WESTERN_US_AW" "NORTH_AMERICA_NORTHEAST_1" "NORTH_AMERICA_NORTHEAST_2" "SOUTH_AMERICA_EAST_1" "SOUTH_AMERICA_WEST_1" "WESTERN_EUROPE" "EUROPE_NORTH_1" "EUROPE_WEST_2" "EUROPE_WEST_3" "EUROPE_WEST_4" "EUROPE_WEST_6" "EUROPE_WEST_8" "EUROPE_WEST_9" "EUROPE_WEST_10" "EUROPE_WEST_12" "EUROPE_SOUTHWEST_1" "EUROPE_CENTRAL_2" "MIDDLE_EAST_CENTRAL_1" "MIDDLE_EAST_CENTRAL_2" "MIDDLE_EAST_WEST_1" "AUSTRALIA_SOUTHEAST_1" "AUSTRALIA_SOUTHEAST_2" "EASTERN_ASIA_PACIFIC" "NORTHEASTERN_ASIA_PACIFIC" "SOUTHEASTERN_ASIA_PACIFIC" "ASIA_EAST_2" "ASIA_NORTHEAST_2" "ASIA_NORTHEAST_3" "ASIA_SOUTH_1" "ASIA_SOUTH_2" "ASIA_SOUTHEAST_2"
# FOR AZURE: "US_CENTRAL" "US_EAST" "US_EAST_2" "US_NORTH_CENTRAL" "US_WEST" "US_SOUTH_CENTRAL" "EUROPE_NORTH" "EUROPE_WEST" "US_WEST_CENTRAL" "US_WEST_2" "US_WEST_3" "CANADA_EAST" "CANADA_CENTRAL" "BRAZIL_SOUTH" "BRAZIL_SOUTHEAST" "AUSTRALIA_CENTRAL" "AUSTRALIA_CENTRAL_2" "AUSTRALIA_EAST" "AUSTRALIA_SOUTH_EAST" "GERMANY_CENTRAL" "GERMANY_NORTH_EAST" "GERMANY_WEST_CENTRAL" "GERMANY_NORTH" "SWEDEN_CENTRAL" "SWEDEN_SOUTH" "SWITZERLAND_NORTH" "SWITZERLAND_WEST" "UK_SOUTH" "UK_WEST" "NORWAY_EAST" "NORWAY_WEST" "INDIA_CENTRAL" "INDIA_SOUTH" "INDIA_WEST" "CHINA_EAST" "CHINA_NORTH" "ASIA_EAST" "JAPAN_EAST" "JAPAN_WEST" "ASIA_SOUTH_EAST" "KOREA_CENTRAL" "KOREA_SOUTH" "FRANCE_CENTRAL" "FRANCE_SOUTH" "SOUTH_AFRICA_NORTH" "SOUTH_AFRICA_WEST" "UAE_CENTRAL" "UAE_NORTH" "QATAR_CENTRAL"
# See the up to date list of regions and providers here: https://www.mongodb.com/docs/atlas/cloud-providers-regions/
- name: EUROPE_WEST_2
providerName: GCP
instanceSize: M10
priority: 6
nodeCount: 1
autoscaling:
enabled: true
min: M10
max: M20
name: ""

dbUser:
name: admin
databaseName: admin
password: ""
23 changes: 23 additions & 0 deletions charts/atlas-basic/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
18 changes: 18 additions & 0 deletions charts/atlas-basic/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: atlas-basic
description: This chart showcases Atlas Basic (shared) deployment

type: application

version: 1.0.0

keywords:
- mongodb
- database
- nosql
home: https://github.com/mongodb/mongodb-atlas-kubernetes
icon: https://webimages.mongodb.com/_com_assets/cms/kuyjf3vea2hg34taa-horizontal_default_slate_blue.svg
appVersion: "2.4.1"
maintainers:
- name: MongoDB
email: [email protected]
84 changes: 84 additions & 0 deletions charts/atlas-basic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "atlas-basic.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "atlas-basic.fullname" -}}
{{- if .Values.deployment.name }}
{{- .Values.deployment.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.deployment.name }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "atlas-basic.projectfullname" -}}
{{- if .Values.project.name }}
{{- .Values.project.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.project.name }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "atlas-basic.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "atlas-basic.labels" -}}
helm.sh/chart: {{ include "atlas-basic.chart" . }}
{{ include "atlas-basic.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "atlas-basic.selectorLabels" -}}
app.kubernetes.io/name: {{ include "atlas-basic.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "generateRandomString" -}}
{{ randAlphaNum 5 }}
{{- end }}

{{- define "getInstanceSizeOrFail" -}}
{{ $instances := list "M0" "M2" "M5"}}
{{- if not (has .Values.deployment.instanceSize $instances)}}
{{- fail "Instance size can only be one of M0, M2, M5" }}
{{- end }}
{{- .Values.deployment.instanceSize }}
{{- end }}

{{- define "getProviderNameOrFail" -}}
{{ $providers := list "AWS" "GCP" "AZURE" }}
{{- if not (has .Values.deployment.providerName $providers) }}
{{- fail "Provider name can only be one of AWS, GCP, AZURE" }}
{{- end}}
{{- .Values.deployment.providerName }}
{{- end}}
Loading

0 comments on commit 8ca3642

Please sign in to comment.