Skip to content

Commit

Permalink
Merge pull request #27 from mongodb/atlas-cluster
Browse files Browse the repository at this point in the history
Atlas cluster
  • Loading branch information
theburi authored Mar 31, 2021
2 parents 618188e + 5c940c4 commit e0a1237
Show file tree
Hide file tree
Showing 14 changed files with 337 additions and 3 deletions.
23 changes: 23 additions & 0 deletions charts/atlas-cluster/.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/
20 changes: 20 additions & 0 deletions charts/atlas-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v2
name: atlas-cluster
description: A Helm chart to manage Atlas resources with Atlas operator

type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.4.0"
maintainers:
- name: MongoDB
email: support@mongodb.com
home: https://github.com/mongodb/mongodb-atlas-kubernetes
9 changes: 9 additions & 0 deletions charts/atlas-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

To learn more about the release, try:

$ helm status {{ .Release.Name }}
$ helm get all {{ .Release.Name }}
62 changes: 62 additions & 0 deletions charts/atlas-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "atlas-cluster.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-cluster.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- 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-cluster.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "atlas-cluster.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "atlas-cluster.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
65 changes: 65 additions & 0 deletions charts/atlas-cluster/templates/atlas-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: atlas.mongodb.com/v1
kind: AtlasCluster
metadata:
name: {{ include "atlas-cluster.fullname" . }}
labels:
{{- include "atlas-cluster.labels" . | nindent 4 }}
namespace: {{ .Release.Namespace }}
spec:
name: {{ include "atlas-cluster.fullname" . }}
projectRef:
name: {{ include "atlas-cluster.fullname" . }}-{{ .Values.project.name }}
providerSettings:
{{- with .Values.mongodb.providerSettings }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.mongodb.autoScaling }}
autoScaling:
{{- with .Values.mongodb.autoScaling }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if .Values.mongodb.autoIndexingEnabled }}
autoIndexingEnabled: false
{{- end }}
{{- if .Values.mongodb.biConnector }}
biConnector:
enabled: {{ .Values.mongodb.biConnector.enabled }}
readPreference: {{ .Values.mongodb.biConnector.readPreference }}
{{- end }}
{{- if .Values.mongodb.clusterType }}
clusterType: {{ .Values.mongodb.clusterType }}
{{- end }}
{{- if .Values.mongodb.diskSizeGB }}
diskSizeGB: {{ .Values.mongodb.diskSizeGB }}
{{- end }}
{{- if .Values.mongodb.encryptionAtRestProvider }}
encryptionAtRestProvider: {{ .Values.mongodb.encryptionAtRestProvider }}
{{- end }}
{{- if .Values.mongodb.labels }}
labels:
{{- with .Values.mongodb.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if .Values.mongodb.mongoDBMajorVersion }}
mongoDBMajorVersion: {{ .Values.mongodb.mongoDBMajorVersion }}
{{- end }}
{{- if .Values.mongodb.numShards }}
numShards: {{ .Values.mongodb.numShards }}
{{- end }}
{{- if .Values.mongodb.paused }}
paused: {{ .Values.mongodb.paused }}
{{- end }}
{{- if .Values.mongodb.pitEnabled }}
pitEnabled: {{ .Values.mongodb.pitEnabled }}
{{- end }}
{{- if .Values.mongodb.providerBackupEnabled }}
providerBackupEnabled: {{ .Values.mongodb.providerBackupEnabled }}
{{- end }}
{{- if .Values.mongodb.replicationSpecs }}
replicationSpecs:
{{- with .Values.mongodb.replicationSpecs }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- range .Values.users }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "atlas-cluster.labels" $ | nindent 4 }}
type: Opaque
stringData:
password: {{ .password | quote }}
{{- end }}
29 changes: 29 additions & 0 deletions charts/atlas-cluster/templates/atlas-mongodb-user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

{{- range .Values.users }}
apiVersion: atlas.mongodb.com/v1
kind: AtlasDatabaseUser
metadata:
name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "atlas-cluster.labels" $ | nindent 4 }}
spec:
username: {{ .username }}
databaseName: {{ .databaseName }}
passwordSecretRef:
name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-secret
projectRef:
name: {{ include "atlas-cluster.fullname" $ }}-{{ $.Values.project.name }}
roles:
{{- toYaml .roles | nindent 4 }}
{{- if .deleteAfterDate }}
deleteAfterDate: {{ .deleteAfterDate }}
{{- end }}
{{- if .labels }}
labels:
{{- toYaml .labels | nindent 4 }}
{{- end }}
{{- if .scopes }}
scopes: {{ .scopes }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/atlas-cluster/templates/atlas-project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: atlas.mongodb.com/v1
kind: AtlasProject
metadata:
name: {{ include "atlas-cluster.fullname" . }}-{{ .Values.project.name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlas-cluster.labels" . | nindent 4 }}
annotations:
'helm.sh/hook': post-delete,pre-install,pre-upgrade
spec:
name: {{ .Values.project.atlasProjectName }}
connectionSecretRef:
{{- if .Values.atlas.connectionSecretName }}
name: {{ .Values.atlas.connectionSecretName}}
{{- else }}
name: {{ include "atlas-cluster.fullname" . }}-secret
{{- end }}
projectIpAccessList:
{{- with .Values.project.projectIpAccessList }}
{{- toYaml . | nindent 2 }}
{{- end }}
20 changes: 20 additions & 0 deletions charts/atlas-cluster/templates/atlas-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
{{- if .Values.atlas.connectionSecretName }}
name: {{ .Values.atlas.connectionSecretName}}
{{- else }}
name: {{ include "atlas-cluster.fullname" . }}-secret
{{- end }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "atlas-cluster.labels" . | nindent 4 }}
annotations:
'helm.sh/hook': post-delete,pre-install,pre-upgrade
data:
orgId: {{ .Values.atlas.orgId| b64enc }}
publicApiKey: {{ .Values.atlas.publicApiKey| b64enc }}
privateApiKey: {{ .Values.atlas.privateApiKey| b64enc }}

61 changes: 61 additions & 0 deletions charts/atlas-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
mongodb-atlas-operator:
enabled: true

# Please provide Atlas API credentials and Organization
atlas:
orgId: "<Atlas Organization ID>"
publicApiKey: "<Atlas_api_public_key>"
privateApiKey: "<Atlas_api_private_key>"

connectionSecretName: ""

project:
name: my-project
atlasProjectName: "Test Project"

projectIpAccessList:
- ipAddress: "192.0.2.15"
comment: "IP address for Application Server A"
- ipAddress: "203.0.113.0/24"
comment: "CIDR block for Application Server B - D"

mongodb:
providerSettings:
instanceSizeName: M10
providerName: AWS
regionName: US_EAST_1

# Optional section. for more information visit
# https://docs.atlas.mongodb.com/reference/api/clusters-create-one/
# #
# autoScaling:
# autoIndexingEnabled: false
# compute:
# enabled: false
# maxInstanceSize: 'M40'
# minInstanceSize: 'M10'
# scaleDownEnabled: false
# diskGBEnabled: false
# biConnector:
# enabled: false
# readPreference: 'primary'
# clusterType: 'REPLICASET'
# diskSizeGB: '50'
# encryptionAtRestProvider: 'AWS'
# labels:
# mongoDBMajorVersion: '4.4'
# numShards: 2
# paused: false
# pitEnabled: false
# providerBackupEnabled: false
# replicationSpecs:
users:
- username: admin-user
databaseName: admin
password: "%SomeLong%password$foradmin"
roles:
- databaseName: admin
roleName: atlasAdmin
# deleteAfterDate:
# labels:
# scopes:
6 changes: 6 additions & 0 deletions charts/atlas-operator/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: mongodb-atlas-operator-crds
repository: https://mongodb.github.io/helm-charts
version: 0.1.0
digest: sha256:a4ca57ea55097c76e2940b2b4146ad672fd093a5b97822bcc5f39c1b2fa536e8
generated: "2021-03-26T16:16:28.459076Z"
5 changes: 5 additions & 0 deletions charts/atlas-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ home: https://github.com/mongodb/mongodb-atlas-kubernetes
maintainers:
- name: MongoDB
email: support@mongodb.com
dependencies:
- name: mongodb-atlas-operator-crds
version: "0.1.0"
repository: "https://mongodb.github.io/helm-charts"
condition: mongodb-enterprise-operator-crds.enabled
3 changes: 3 additions & 0 deletions charts/atlas-operator/values.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
mongodb-enterprise-operator-crds:
enabled: true

# atlasURI is the URI of the MongoDB Atlas
atlasURI: https://cloud.mongodb.com

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ kind: Secret
metadata:
name: {{ $.Values.name }}-{{ .username }}-secret
namespace: {{ $.Release.Namespace }}
annotations:
"meta.helm.sh/release-name": {{ $.Release.Name }}
"meta.helm.sh/release-namespace": {{ $.Release.Namespace }}
labels:
"helm.sh/chart": {{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}
"app.kubernetes.io/managed-by": {{ $.Release.Service }}
Expand Down

0 comments on commit e0a1237

Please sign in to comment.