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

CLOUDP-227413: AKO templates #348

Merged
merged 10 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
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: 2.4.1
igor-karpukhin marked this conversation as resolved.
Show resolved Hide resolved

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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think my question still applies: how do we make sure that this does not introduce skew when we move forward with new AKO versions?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the helm chart version does not need to match the version of the image.

These examples are even less tied to the Operator releases, they should just keep working after most releases, unless some breaking changes are released.

I see two ways about this:

  1. Every Operator and Helm release requires a release in these example charts.
  2. These example charts are exercised in a test in the CI and will only get updated as needed, when actual changes makes them somewhat obsolete.

If we do not automate on auto testing these, we will be forced to option 1, at least until we make such investment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to the latest AKO version just in case. As we do the same thing for the AKO chart and the AKO CRDs

Copy link
Collaborator

@s-urbaniak s-urbaniak Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With respect to the appVersion field: https://helm.sh/docs/topics/charts/#the-appversion-field

Note that the appVersion field is not related to the version field. It is a way of specifying the version of the application. For example, the drupal chart may have an appVersion: "8.2.1", indicating that the version of Drupal included in the chart (by default) is 8.2.1. This field is informational, and has no impact on chart version calculations.

With respect to the version field: https://helm.sh/docs/topics/charts/#charts-and-versioning

Every chart must have a version number. A version must follow the SemVer 2 standard. Unlike Helm Classic, Helm v2 and later uses version numbers as release markers. Packages in repositories are identified by name plus version.

My conclusions from the above are the following:

  1. Given appVersion is purely informational I vote for making it clear (as a comment) that this is the version of AKO this helm was created with.

  2. Given version is a semver version of this chart specifically I vote to set it to "1.0" since this is the very first version of this chart

@josvazg @igor-karpukhin thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me.
Also I would avoid having to re-release this with all released of AKO. Releasing only when new versions might force it due to breaking changes or features than need to be showcased.

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"
igor-karpukhin marked this conversation as resolved.
Show resolved Hide resolved
# 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: 2.4.1
igor-karpukhin marked this conversation as resolved.
Show resolved Hide resolved

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
Loading