Skip to content

Commit

Permalink
Added atlas-advanced chart
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-karpukhin committed Oct 4, 2024
1 parent 42993b4 commit 8114637
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 0 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://camo.githubusercontent.com/d473c25e361fb2206f06bdcf24028e8d52bc30d1/68747470733a2f2f6d6f6e676f64622d6b756265726e657465732d6f70657261746f722e73332e616d617a6f6e6177732e636f6d2f696d672f4c6561662d466f7265737425343032782e706e67
appVersion: "1.0.0"
maintainers:
- name: MongoDB
email: [email protected]
88 changes: 88 additions & 0 deletions charts/atlas-advanced/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{/*
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 $arg $instances)}}
{{ $str := join "," $instances }}
{{- fail "Instance size can only be one of " print $str }}
{{- end }}
{{- $arg -}}
{{- end }}

{{- define "getProviderNameOrFail" -}}
{{- $arg := . -}}
{{ $providers := list "AWS" "GCP" "AZURE" }}
{{- if not (has $arg $providers) }}
{{ $str := join "," $providers }}
{{- fail "Provider name can only be one of " print $str }}
{{- 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 }}
41 changes: 41 additions & 0 deletions charts/atlas-advanced/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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"
- 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"
- 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: ""

0 comments on commit 8114637

Please sign in to comment.