From 94189945ef68c139cbd232e7f119f32ba0c39456 Mon Sep 17 00:00:00 2001 From: theburi Date: Wed, 24 Mar 2021 17:21:48 +0000 Subject: [PATCH 01/13] First draft of the Atlas chart --- charts/atlas-cluster/.helmignore | 23 +++++++ charts/atlas-cluster/Chart.yaml | 21 +++++++ charts/atlas-cluster/templates/NOTES.txt | 1 + charts/atlas-cluster/templates/_helpers.tpl | 62 +++++++++++++++++++ .../templates/atlas-cluster.yaml | 15 +++++ .../templates/atlas-project.yaml | 14 +++++ .../atlas-cluster/templates/atlas-secret.yaml | 17 +++++ .../templates/tests/test-connection.yaml | 15 +++++ charts/atlas-cluster/values.yaml | 30 +++++++++ 9 files changed, 198 insertions(+) create mode 100644 charts/atlas-cluster/.helmignore create mode 100644 charts/atlas-cluster/Chart.yaml create mode 100644 charts/atlas-cluster/templates/NOTES.txt create mode 100644 charts/atlas-cluster/templates/_helpers.tpl create mode 100644 charts/atlas-cluster/templates/atlas-cluster.yaml create mode 100644 charts/atlas-cluster/templates/atlas-project.yaml create mode 100644 charts/atlas-cluster/templates/atlas-secret.yaml create mode 100644 charts/atlas-cluster/templates/tests/test-connection.yaml create mode 100644 charts/atlas-cluster/values.yaml diff --git a/charts/atlas-cluster/.helmignore b/charts/atlas-cluster/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/atlas-cluster/.helmignore @@ -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/ diff --git a/charts/atlas-cluster/Chart.yaml b/charts/atlas-cluster/Chart.yaml new file mode 100644 index 00000000..cc60be06 --- /dev/null +++ b/charts/atlas-cluster/Chart.yaml @@ -0,0 +1,21 @@ +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: "1.0.0" +dependencies: + - name: mongodb-atlas-operator + version: "0.4.0" + repository: "https://mongodb.github.io/helm-charts" + condition: mongodb-atlas-operator.enabled \ No newline at end of file diff --git a/charts/atlas-cluster/templates/NOTES.txt b/charts/atlas-cluster/templates/NOTES.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/charts/atlas-cluster/templates/NOTES.txt @@ -0,0 +1 @@ + diff --git a/charts/atlas-cluster/templates/_helpers.tpl b/charts/atlas-cluster/templates/_helpers.tpl new file mode 100644 index 00000000..1b159d47 --- /dev/null +++ b/charts/atlas-cluster/templates/_helpers.tpl @@ -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 }} diff --git a/charts/atlas-cluster/templates/atlas-cluster.yaml b/charts/atlas-cluster/templates/atlas-cluster.yaml new file mode 100644 index 00000000..54607cdf --- /dev/null +++ b/charts/atlas-cluster/templates/atlas-cluster.yaml @@ -0,0 +1,15 @@ +apiVersion: atlas.mongodb.com/v1 +kind: AtlasCluster +metadata: + name: {{ include "atlas-cluster.fullname" . }} + labels: + {{- include "atlas-cluster.labels" . | nindent 4 }} + +spec: + name: {{ .Values.mongodb.name }} + projectRef: + name: {{ include "atlas-cluster.fullname" . }}-project + providerSettings: +{{- with .Values.mongodb.providerSettings }} +{{- toYaml . | nindent 4 }} +{{- end }} diff --git a/charts/atlas-cluster/templates/atlas-project.yaml b/charts/atlas-cluster/templates/atlas-project.yaml new file mode 100644 index 00000000..48c7d6e7 --- /dev/null +++ b/charts/atlas-cluster/templates/atlas-project.yaml @@ -0,0 +1,14 @@ +apiVersion: atlas.mongodb.com/v1 +kind: AtlasProject +metadata: + name: {{ include "atlas-cluster.fullname" . }}-project + labels: + {{- include "atlas-cluster.labels" . | nindent 4 }} +spec: + name: {{ .Values.project.atlasTitle }} + connectionSecretRef: + name: {{ .Values.atlas.connectionSecretName }} + projectIpAccessList: + {{- with .Values.project.projectIpAccessList }} + {{- toYaml . | nindent 2 }} + {{- end }} diff --git a/charts/atlas-cluster/templates/atlas-secret.yaml b/charts/atlas-cluster/templates/atlas-secret.yaml new file mode 100644 index 00000000..3004984a --- /dev/null +++ b/charts/atlas-cluster/templates/atlas-secret.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: v1 +kind: Secret +type: Opaque +metadata: +{{ -if .Values.atlas.connectionSecretName }} + name: {{ .Values.atlas.connectionSecretName}} +{{- else }} + name: {{ include "atlas-cluster.fullname" . }}-secret +{{- end }} + labels: + {{- include "atlas-cluster.labels" . | nindent 4 }} +data: + orgid: {{ .Values.atlas.orgid| b64enc }} + publicApiKey: {{ .Values.atlas.publicApiKey| b64enc }} + privateApiKey: {{ .Values.atlas.privateApiKey| b64enc }} + diff --git a/charts/atlas-cluster/templates/tests/test-connection.yaml b/charts/atlas-cluster/templates/tests/test-connection.yaml new file mode 100644 index 00000000..05e97b18 --- /dev/null +++ b/charts/atlas-cluster/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "atlas-cluster.fullname" . }}-test-connection" + labels: + {{- include "atlas-cluster.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "atlas-cluster.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml new file mode 100644 index 00000000..9d52945a --- /dev/null +++ b/charts/atlas-cluster/values.yaml @@ -0,0 +1,30 @@ + +mongodb-atlas-operator: + enabled: true + +# Please provide Atlas API credentials and Organization +atlas: + orgid: "" + publicApiKey: "" + privateApiKey: "" + + connectionSecretName: "" + +project: + name: my-project + atlasTitle: "Test Atlas Operator 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: + name: "Test-cluster" + providerSettings: + instanceSizeName: M10 + providerName: AWS + regionName: US_EAST_1 + +users: From 10aa342ef1ba0d4218278f93fda84fba9aaddbc0 Mon Sep 17 00:00:00 2001 From: theburi Date: Fri, 26 Mar 2021 10:55:08 +0000 Subject: [PATCH 02/13] adding Atlas-cluster --- charts/atlas-cluster/Chart.lock | 9 ++++ charts/atlas-cluster/Chart.yaml | 5 -- charts/atlas-cluster/templates/NOTES.txt | 8 +++ .../templates/atlas-cluster.yaml | 54 ++++++++++++++++++- .../templates/atlas-mongodb-user-secret.yaml | 13 +++++ .../templates/atlas-mongodb-user.yaml | 23 ++++++++ .../templates/atlas-project.yaml | 7 ++- .../atlas-cluster/templates/atlas-secret.yaml | 5 +- .../templates/tests/test-connection.yaml | 15 ------ charts/atlas-cluster/values.yaml | 42 ++++++++++++++- charts/atlas-operator/Chart.yaml | 5 ++ charts/atlas-operator/values.yaml | 3 ++ .../templates/mongodb-user-password.yaml | 3 -- 13 files changed, 162 insertions(+), 30 deletions(-) create mode 100644 charts/atlas-cluster/Chart.lock create mode 100644 charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml create mode 100644 charts/atlas-cluster/templates/atlas-mongodb-user.yaml delete mode 100644 charts/atlas-cluster/templates/tests/test-connection.yaml diff --git a/charts/atlas-cluster/Chart.lock b/charts/atlas-cluster/Chart.lock new file mode 100644 index 00000000..ec373d54 --- /dev/null +++ b/charts/atlas-cluster/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: mongodb-atlas-operator + repository: https://mongodb.github.io/helm-charts + version: 0.1.0 +- name: mongodb-atlas-operator-crds + repository: https://mongodb.github.io/helm-charts + version: 0.1.0 +digest: sha256:108de1ddabb7239b6d6960c3429ca6f939bfe7f62ab4802f3daee4dbf81be879 +generated: "2021-03-25T17:02:00.474307Z" diff --git a/charts/atlas-cluster/Chart.yaml b/charts/atlas-cluster/Chart.yaml index cc60be06..202378d5 100644 --- a/charts/atlas-cluster/Chart.yaml +++ b/charts/atlas-cluster/Chart.yaml @@ -14,8 +14,3 @@ version: 0.1.0 # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. appVersion: "1.0.0" -dependencies: - - name: mongodb-atlas-operator - version: "0.4.0" - repository: "https://mongodb.github.io/helm-charts" - condition: mongodb-atlas-operator.enabled \ No newline at end of file diff --git a/charts/atlas-cluster/templates/NOTES.txt b/charts/atlas-cluster/templates/NOTES.txt index 8b137891..2a18ac5c 100644 --- a/charts/atlas-cluster/templates/NOTES.txt +++ b/charts/atlas-cluster/templates/NOTES.txt @@ -1 +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 }} \ No newline at end of file diff --git a/charts/atlas-cluster/templates/atlas-cluster.yaml b/charts/atlas-cluster/templates/atlas-cluster.yaml index 54607cdf..a285c9ae 100644 --- a/charts/atlas-cluster/templates/atlas-cluster.yaml +++ b/charts/atlas-cluster/templates/atlas-cluster.yaml @@ -4,12 +4,62 @@ metadata: name: {{ include "atlas-cluster.fullname" . }} labels: {{- include "atlas-cluster.labels" . | nindent 4 }} - + namespace: {{ .Release.Namespace }} spec: - name: {{ .Values.mongodb.name }} + name: {{ include "atlas-cluster.fullname" . }} projectRef: name: {{ include "atlas-cluster.fullname" . }}-project 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 }} \ No newline at end of file diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml new file mode 100644 index 00000000..48e14859 --- /dev/null +++ b/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml @@ -0,0 +1,13 @@ +{{- range .Values.users }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-secret + namespace: {{ $.Release.Namespace }} + labels: + {{- include "atlas-cluster.labels" $ | nindent 4 }} +type: Opaque +stringData: + password: {{ .password | quote}} +{{- end }} \ No newline at end of file diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml new file mode 100644 index 00000000..9f8d6528 --- /dev/null +++ b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml @@ -0,0 +1,23 @@ + +{{- range .Values.users }} +apiVersion: atlas.mongodb.com/v1 +kind: AtlasDatabaseUser +metadata: + name: {{ include "atlas-cluster.fullname" $ }}-project + 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" $ }}-project + roles: + {{- toYaml .roles | nindent 4 }} + deleteAfterDate: {{ .deleteAfterDate }} + labels: + {{- toYaml .labels | nindent 4 }} + scopes: {{ .scopes }} +{{- end }} \ No newline at end of file diff --git a/charts/atlas-cluster/templates/atlas-project.yaml b/charts/atlas-cluster/templates/atlas-project.yaml index 48c7d6e7..46135fe1 100644 --- a/charts/atlas-cluster/templates/atlas-project.yaml +++ b/charts/atlas-cluster/templates/atlas-project.yaml @@ -2,12 +2,17 @@ apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: {{ include "atlas-cluster.fullname" . }}-project + namespace: {{ .Release.Namespace }} labels: {{- include "atlas-cluster.labels" . | nindent 4 }} spec: name: {{ .Values.project.atlasTitle }} connectionSecretRef: - name: {{ .Values.atlas.connectionSecretName }} +{{- if .Values.atlas.connectionSecretName }} + name: {{ .Values.atlas.connectionSecretName}} +{{- else }} + name: {{ include "atlas-cluster.fullname" . }}-secret +{{- end }} projectIpAccessList: {{- with .Values.project.projectIpAccessList }} {{- toYaml . | nindent 2 }} diff --git a/charts/atlas-cluster/templates/atlas-secret.yaml b/charts/atlas-cluster/templates/atlas-secret.yaml index 3004984a..74c75ecd 100644 --- a/charts/atlas-cluster/templates/atlas-secret.yaml +++ b/charts/atlas-cluster/templates/atlas-secret.yaml @@ -3,15 +3,16 @@ apiVersion: v1 kind: Secret type: Opaque metadata: -{{ -if .Values.atlas.connectionSecretName }} +{{- 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 }} data: - orgid: {{ .Values.atlas.orgid| b64enc }} + orgId: {{ .Values.atlas.orgId| b64enc }} publicApiKey: {{ .Values.atlas.publicApiKey| b64enc }} privateApiKey: {{ .Values.atlas.privateApiKey| b64enc }} diff --git a/charts/atlas-cluster/templates/tests/test-connection.yaml b/charts/atlas-cluster/templates/tests/test-connection.yaml deleted file mode 100644 index 05e97b18..00000000 --- a/charts/atlas-cluster/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "atlas-cluster.fullname" . }}-test-connection" - labels: - {{- include "atlas-cluster.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "atlas-cluster.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index 9d52945a..af552ec9 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -4,7 +4,7 @@ mongodb-atlas-operator: # Please provide Atlas API credentials and Organization atlas: - orgid: "" + orgId: "" publicApiKey: "" privateApiKey: "" @@ -21,10 +21,48 @@ project: comment: "CIDR block for Application Server B - D" mongodb: - name: "Test-cluster" 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: + - db: admin + name: clusterAdmin + - db: admin + name: userAdminAnyDatabase + - db: admin + name: readWrite + - db: admin + name: userAdminAnyDatabase + # deleteAfterDate: + # labels: + # scopes: \ No newline at end of file diff --git a/charts/atlas-operator/Chart.yaml b/charts/atlas-operator/Chart.yaml index 1a5cee70..f37cefde 100644 --- a/charts/atlas-operator/Chart.yaml +++ b/charts/atlas-operator/Chart.yaml @@ -16,3 +16,8 @@ home: https://github.com/mongodb/mongodb-atlas-kubernetes maintainers: - name: MongoDB email: support@mongodb.com +dependencies: + - name: mongodb-atlas-operator-crd + version: "0.1.0" + repository: "https://mongodb.github.io/helm-charts" + condition: mongodb-enterprise-operator-crd.enabled \ No newline at end of file diff --git a/charts/atlas-operator/values.yaml b/charts/atlas-operator/values.yaml index 42ee5ad4..c18e312f 100644 --- a/charts/atlas-operator/values.yaml +++ b/charts/atlas-operator/values.yaml @@ -1,3 +1,6 @@ +mongodb-enterprise-operator-crd: + enabled: true + # atlasURI is the URI of the MongoDB Atlas atlasURI: https://cloud.mongodb.com diff --git a/charts/ent-operator-database/templates/mongodb-user-password.yaml b/charts/ent-operator-database/templates/mongodb-user-password.yaml index 2334d318..29049bfa 100644 --- a/charts/ent-operator-database/templates/mongodb-user-password.yaml +++ b/charts/ent-operator-database/templates/mongodb-user-password.yaml @@ -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 }} From 560db1306615b535938e3e7bfc8e1e5b76a9f683 Mon Sep 17 00:00:00 2001 From: theburi Date: Fri, 26 Mar 2021 11:02:38 +0000 Subject: [PATCH 03/13] fixing user files --- charts/atlas-cluster/templates/atlas-mongodb-user.yaml | 8 +++++++- charts/atlas-cluster/values.yaml | 10 ++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml index 9f8d6528..d0ca8bd7 100644 --- a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml +++ b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml @@ -3,7 +3,7 @@ apiVersion: atlas.mongodb.com/v1 kind: AtlasDatabaseUser metadata: - name: {{ include "atlas-cluster.fullname" $ }}-project + name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-user namespace: {{ $.Release.Namespace }} labels: {{- include "atlas-cluster.labels" $ | nindent 4 }} @@ -16,8 +16,14 @@ spec: name: {{ include "atlas-cluster.fullname" $ }}-project roles: {{- toYaml .roles | nindent 4 }} + {{- if .deleteAfterDate }} deleteAfterDate: {{ .deleteAfterDate }} + {{- end }} + {{- if .labels }} labels: {{- toYaml .labels | nindent 4 }} + {{- end }} + {{- if .scopes }} scopes: {{ .scopes }} + {{- end }} {{- end }} \ No newline at end of file diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index af552ec9..35191979 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -55,14 +55,8 @@ users: databaseName: admin password: "%SomeLong%password$foradmin" roles: - - db: admin - name: clusterAdmin - - db: admin - name: userAdminAnyDatabase - - db: admin - name: readWrite - - db: admin - name: userAdminAnyDatabase + - databaseName: admin + roleName: atlasAdmin # deleteAfterDate: # labels: # scopes: \ No newline at end of file From 109fbef87752f33176a070006676173361e6f443 Mon Sep 17 00:00:00 2001 From: theburi Date: Fri, 26 Mar 2021 11:11:22 +0000 Subject: [PATCH 04/13] adding project options --- charts/atlas-cluster/templates/atlas-cluster.yaml | 2 +- charts/atlas-cluster/templates/atlas-project.yaml | 4 +++- charts/atlas-cluster/values.yaml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/charts/atlas-cluster/templates/atlas-cluster.yaml b/charts/atlas-cluster/templates/atlas-cluster.yaml index a285c9ae..aa790d3b 100644 --- a/charts/atlas-cluster/templates/atlas-cluster.yaml +++ b/charts/atlas-cluster/templates/atlas-cluster.yaml @@ -8,7 +8,7 @@ metadata: spec: name: {{ include "atlas-cluster.fullname" . }} projectRef: - name: {{ include "atlas-cluster.fullname" . }}-project + name: {{ .Values.project.name }}-project providerSettings: {{- with .Values.mongodb.providerSettings }} {{- toYaml . | nindent 4 }} diff --git a/charts/atlas-cluster/templates/atlas-project.yaml b/charts/atlas-cluster/templates/atlas-project.yaml index 46135fe1..08213378 100644 --- a/charts/atlas-cluster/templates/atlas-project.yaml +++ b/charts/atlas-cluster/templates/atlas-project.yaml @@ -1,7 +1,8 @@ +{{- if .Values.project.enable }} apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: - name: {{ include "atlas-cluster.fullname" . }}-project + name: {{ .Values.project.name }}-project namespace: {{ .Release.Namespace }} labels: {{- include "atlas-cluster.labels" . | nindent 4 }} @@ -17,3 +18,4 @@ spec: {{- with .Values.project.projectIpAccessList }} {{- toYaml . | nindent 2 }} {{- end }} +{{- end } \ No newline at end of file diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index 35191979..cc3d4c01 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -11,6 +11,7 @@ atlas: connectionSecretName: "" project: + enable: true name: my-project atlasTitle: "Test Atlas Operator Project" From 44a5b847f0e099de941a652ef905c986cc248661 Mon Sep 17 00:00:00 2001 From: theburi Date: Fri, 26 Mar 2021 12:10:03 +0000 Subject: [PATCH 05/13] Adding dependency hooks --- charts/atlas-cluster/templates/atlas-cluster.yaml | 2 +- charts/atlas-cluster/templates/atlas-mongodb-user.yaml | 2 +- charts/atlas-cluster/templates/atlas-project.yaml | 10 ++++++---- charts/atlas-cluster/templates/atlas-secret.yaml | 2 ++ charts/atlas-cluster/values.yaml | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/charts/atlas-cluster/templates/atlas-cluster.yaml b/charts/atlas-cluster/templates/atlas-cluster.yaml index aa790d3b..0be6c4e5 100644 --- a/charts/atlas-cluster/templates/atlas-cluster.yaml +++ b/charts/atlas-cluster/templates/atlas-cluster.yaml @@ -8,7 +8,7 @@ metadata: spec: name: {{ include "atlas-cluster.fullname" . }} projectRef: - name: {{ .Values.project.name }}-project + name: {{ .Values.project.name }} providerSettings: {{- with .Values.mongodb.providerSettings }} {{- toYaml . | nindent 4 }} diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml index d0ca8bd7..abd0cb59 100644 --- a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml +++ b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml @@ -13,7 +13,7 @@ spec: passwordSecretRef: name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-secret projectRef: - name: {{ include "atlas-cluster.fullname" $ }}-project + name: {{ $.Values.project.name }} roles: {{- toYaml .roles | nindent 4 }} {{- if .deleteAfterDate }} diff --git a/charts/atlas-cluster/templates/atlas-project.yaml b/charts/atlas-cluster/templates/atlas-project.yaml index 08213378..728b71ad 100644 --- a/charts/atlas-cluster/templates/atlas-project.yaml +++ b/charts/atlas-cluster/templates/atlas-project.yaml @@ -1,13 +1,15 @@ -{{- if .Values.project.enable }} +# {{- if .Values.project.enable }} apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: - name: {{ .Values.project.name }}-project + name: {{ .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.atlasTitle }} + name: {{ .Values.project.atlasProjectName }} connectionSecretRef: {{- if .Values.atlas.connectionSecretName }} name: {{ .Values.atlas.connectionSecretName}} @@ -18,4 +20,4 @@ spec: {{- with .Values.project.projectIpAccessList }} {{- toYaml . | nindent 2 }} {{- end }} -{{- end } \ No newline at end of file +# {{- end }} \ No newline at end of file diff --git a/charts/atlas-cluster/templates/atlas-secret.yaml b/charts/atlas-cluster/templates/atlas-secret.yaml index 74c75ecd..5ee34860 100644 --- a/charts/atlas-cluster/templates/atlas-secret.yaml +++ b/charts/atlas-cluster/templates/atlas-secret.yaml @@ -11,6 +11,8 @@ metadata: 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 }} diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index cc3d4c01..55b7054c 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -13,7 +13,7 @@ atlas: project: enable: true name: my-project - atlasTitle: "Test Atlas Operator Project" + atlasProjectName: "AndreyB" projectIpAccessList: - ipAddress: "192.0.2.15" From b88c11f40e4aa2ada272e3bda20699d0a5696839 Mon Sep 17 00:00:00 2001 From: theburi Date: Fri, 26 Mar 2021 14:21:07 +0000 Subject: [PATCH 06/13] removing dependencies --- charts/atlas-cluster/Chart.lock | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 charts/atlas-cluster/Chart.lock diff --git a/charts/atlas-cluster/Chart.lock b/charts/atlas-cluster/Chart.lock deleted file mode 100644 index ec373d54..00000000 --- a/charts/atlas-cluster/Chart.lock +++ /dev/null @@ -1,9 +0,0 @@ -dependencies: -- name: mongodb-atlas-operator - repository: https://mongodb.github.io/helm-charts - version: 0.1.0 -- name: mongodb-atlas-operator-crds - repository: https://mongodb.github.io/helm-charts - version: 0.1.0 -digest: sha256:108de1ddabb7239b6d6960c3429ca6f939bfe7f62ab4802f3daee4dbf81be879 -generated: "2021-03-25T17:02:00.474307Z" From 378a0d269209e43cd5af4b14b35e9a1eabe3e863 Mon Sep 17 00:00:00 2001 From: theburi Date: Fri, 26 Mar 2021 16:18:38 +0000 Subject: [PATCH 07/13] Fixing lint errors --- charts/atlas-cluster/Chart.yaml | 3 +++ charts/atlas-cluster/values.yaml | 13 ++++++------- charts/atlas-operator/Chart.lock | 6 ++++++ charts/atlas-operator/Chart.yaml | 4 ++-- charts/atlas-operator/values.yaml | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 charts/atlas-operator/Chart.lock diff --git a/charts/atlas-cluster/Chart.yaml b/charts/atlas-cluster/Chart.yaml index 202378d5..32e1ee22 100644 --- a/charts/atlas-cluster/Chart.yaml +++ b/charts/atlas-cluster/Chart.yaml @@ -14,3 +14,6 @@ version: 0.1.0 # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. appVersion: "1.0.0" +maintainers: + - name: MongoDB + email: support@mongodb.com diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index 55b7054c..bbc87b01 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -1,8 +1,7 @@ - mongodb-atlas-operator: enabled: true -# Please provide Atlas API credentials and Organization +# Please provide Atlas API credentials and Organization atlas: orgId: "" publicApiKey: "" @@ -14,7 +13,7 @@ project: enable: true name: my-project atlasProjectName: "AndreyB" - + projectIpAccessList: - ipAddress: "192.0.2.15" comment: "IP address for Application Server A" @@ -29,7 +28,7 @@ mongodb: # Optional section. for more information visit # https://docs.atlas.mongodb.com/reference/api/clusters-create-one/ -# # +# # # autoScaling: # autoIndexingEnabled: false # compute: @@ -44,7 +43,7 @@ mongodb: # clusterType: 'REPLICASET' # diskSizeGB: '50' # encryptionAtRestProvider: 'AWS' -# labels: +# labels: # mongoDBMajorVersion: '4.4' # numShards: 2 # paused: false @@ -59,5 +58,5 @@ users: - databaseName: admin roleName: atlasAdmin # deleteAfterDate: - # labels: - # scopes: \ No newline at end of file + # labels: + # scopes: diff --git a/charts/atlas-operator/Chart.lock b/charts/atlas-operator/Chart.lock new file mode 100644 index 00000000..08bbd9b3 --- /dev/null +++ b/charts/atlas-operator/Chart.lock @@ -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" diff --git a/charts/atlas-operator/Chart.yaml b/charts/atlas-operator/Chart.yaml index f37cefde..3367ec0a 100644 --- a/charts/atlas-operator/Chart.yaml +++ b/charts/atlas-operator/Chart.yaml @@ -17,7 +17,7 @@ maintainers: - name: MongoDB email: support@mongodb.com dependencies: - - name: mongodb-atlas-operator-crd + - name: mongodb-atlas-operator-crds version: "0.1.0" repository: "https://mongodb.github.io/helm-charts" - condition: mongodb-enterprise-operator-crd.enabled \ No newline at end of file + condition: mongodb-enterprise-operator-crds.enabled diff --git a/charts/atlas-operator/values.yaml b/charts/atlas-operator/values.yaml index c18e312f..2d3c3d3f 100644 --- a/charts/atlas-operator/values.yaml +++ b/charts/atlas-operator/values.yaml @@ -1,4 +1,4 @@ -mongodb-enterprise-operator-crd: +mongodb-enterprise-operator-crds: enabled: true # atlasURI is the URI of the MongoDB Atlas From 6c28ce7d333e8ac34ac6b9af34da311b14d676ac Mon Sep 17 00:00:00 2001 From: theburi Date: Fri, 26 Mar 2021 16:20:44 +0000 Subject: [PATCH 08/13] addign home link --- charts/atlas-cluster/Chart.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/charts/atlas-cluster/Chart.yaml b/charts/atlas-cluster/Chart.yaml index 32e1ee22..78e2693c 100644 --- a/charts/atlas-cluster/Chart.yaml +++ b/charts/atlas-cluster/Chart.yaml @@ -17,3 +17,4 @@ appVersion: "1.0.0" maintainers: - name: MongoDB email: support@mongodb.com +home: https://github.com/mongodb/mongodb-atlas-kubernetes From ecdb3e2ac3ed8c0da35e91825d6de22977443f65 Mon Sep 17 00:00:00 2001 From: theburi Date: Mon, 29 Mar 2021 10:41:28 +0100 Subject: [PATCH 09/13] adding correct app version --- charts/atlas-cluster/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/atlas-cluster/Chart.yaml b/charts/atlas-cluster/Chart.yaml index 78e2693c..fdb3d369 100644 --- a/charts/atlas-cluster/Chart.yaml +++ b/charts/atlas-cluster/Chart.yaml @@ -13,7 +13,7 @@ version: 0.1.0 # 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: "1.0.0" +appVersion: "0.4.0" maintainers: - name: MongoDB email: support@mongodb.com From a9e09e7452be8d904ba2f027953b251139de5e0f Mon Sep 17 00:00:00 2001 From: theburi Date: Mon, 29 Mar 2021 15:14:49 +0100 Subject: [PATCH 10/13] adding correct project names --- charts/atlas-cluster/templates/atlas-cluster.yaml | 2 +- charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml | 2 +- charts/atlas-cluster/templates/atlas-mongodb-user.yaml | 2 +- charts/atlas-cluster/templates/atlas-project.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/atlas-cluster/templates/atlas-cluster.yaml b/charts/atlas-cluster/templates/atlas-cluster.yaml index 0be6c4e5..ad110bd5 100644 --- a/charts/atlas-cluster/templates/atlas-cluster.yaml +++ b/charts/atlas-cluster/templates/atlas-cluster.yaml @@ -8,7 +8,7 @@ metadata: spec: name: {{ include "atlas-cluster.fullname" . }} projectRef: - name: {{ .Values.project.name }} + name: {{ include "atlas-cluster.fullname" . }}-{{ .Values.project.name }} providerSettings: {{- with .Values.mongodb.providerSettings }} {{- toYaml . | nindent 4 }} diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml index 48e14859..2f52a20a 100644 --- a/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml +++ b/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml @@ -9,5 +9,5 @@ metadata: {{- include "atlas-cluster.labels" $ | nindent 4 }} type: Opaque stringData: - password: {{ .password | quote}} + password: {{ .password | quote }} {{- end }} \ No newline at end of file diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml index abd0cb59..d970cbb1 100644 --- a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml +++ b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml @@ -13,7 +13,7 @@ spec: passwordSecretRef: name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-secret projectRef: - name: {{ $.Values.project.name }} + name: {{ include "atlas-cluster.fullname" $ }}{{ $.Values.project.name }} roles: {{- toYaml .roles | nindent 4 }} {{- if .deleteAfterDate }} diff --git a/charts/atlas-cluster/templates/atlas-project.yaml b/charts/atlas-cluster/templates/atlas-project.yaml index 728b71ad..1cd24aef 100644 --- a/charts/atlas-cluster/templates/atlas-project.yaml +++ b/charts/atlas-cluster/templates/atlas-project.yaml @@ -2,7 +2,7 @@ apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: - name: {{ .Values.project.name }} + name: {{ include "atlas-cluster.fullname" . }}-{{ .Values.project.name }} namespace: {{ .Release.Namespace }} labels: {{- include "atlas-cluster.labels" . | nindent 4 }} From 4f75d5e97ada8cff6417fbb271d1bfcf06a0ff81 Mon Sep 17 00:00:00 2001 From: theburi Date: Wed, 31 Mar 2021 10:35:06 +0100 Subject: [PATCH 11/13] few little fixes --- charts/atlas-cluster/templates/atlas-mongodb-user.yaml | 2 +- charts/atlas-cluster/values.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml index d970cbb1..96a4edee 100644 --- a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml +++ b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml @@ -13,7 +13,7 @@ spec: passwordSecretRef: name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-secret projectRef: - name: {{ include "atlas-cluster.fullname" $ }}{{ $.Values.project.name }} + name: {{ include "atlas-cluster.fullname" $ }}-{{ $.Values.project.name }} roles: {{- toYaml .roles | nindent 4 }} {{- if .deleteAfterDate }} diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index bbc87b01..b585de9c 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -12,7 +12,7 @@ atlas: project: enable: true name: my-project - atlasProjectName: "AndreyB" + atlasProjectName: "Test Project" projectIpAccessList: - ipAddress: "192.0.2.15" @@ -22,7 +22,7 @@ project: mongodb: providerSettings: - instanceSizeName: M10 + instanceSizeName: M2 providerName: AWS regionName: US_EAST_1 From 3a2de3f3ff68d1abadbe45245bf932c8499f05b6 Mon Sep 17 00:00:00 2001 From: theburi Date: Wed, 31 Mar 2021 11:47:02 +0100 Subject: [PATCH 12/13] Removing project fields --- charts/atlas-cluster/templates/atlas-project.yaml | 2 -- charts/atlas-cluster/values.yaml | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/charts/atlas-cluster/templates/atlas-project.yaml b/charts/atlas-cluster/templates/atlas-project.yaml index 1cd24aef..e64bd2d7 100644 --- a/charts/atlas-cluster/templates/atlas-project.yaml +++ b/charts/atlas-cluster/templates/atlas-project.yaml @@ -1,4 +1,3 @@ -# {{- if .Values.project.enable }} apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: @@ -20,4 +19,3 @@ spec: {{- with .Values.project.projectIpAccessList }} {{- toYaml . | nindent 2 }} {{- end }} -# {{- end }} \ No newline at end of file diff --git a/charts/atlas-cluster/values.yaml b/charts/atlas-cluster/values.yaml index b585de9c..335dc871 100644 --- a/charts/atlas-cluster/values.yaml +++ b/charts/atlas-cluster/values.yaml @@ -10,7 +10,6 @@ atlas: connectionSecretName: "" project: - enable: true name: my-project atlasProjectName: "Test Project" @@ -22,7 +21,7 @@ project: mongodb: providerSettings: - instanceSizeName: M2 + instanceSizeName: M10 providerName: AWS regionName: US_EAST_1 From 5c940c485d9d9502ee63ddf6c0b670ca2fb59f59 Mon Sep 17 00:00:00 2001 From: theburi Date: Wed, 31 Mar 2021 11:48:11 +0100 Subject: [PATCH 13/13] removed suffixes --- charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml | 2 +- charts/atlas-cluster/templates/atlas-mongodb-user.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml index 2f52a20a..f1d76621 100644 --- a/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml +++ b/charts/atlas-cluster/templates/atlas-mongodb-user-secret.yaml @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: - name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-secret + name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }} namespace: {{ $.Release.Namespace }} labels: {{- include "atlas-cluster.labels" $ | nindent 4 }} diff --git a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml index 96a4edee..2026a6eb 100644 --- a/charts/atlas-cluster/templates/atlas-mongodb-user.yaml +++ b/charts/atlas-cluster/templates/atlas-mongodb-user.yaml @@ -3,7 +3,7 @@ apiVersion: atlas.mongodb.com/v1 kind: AtlasDatabaseUser metadata: - name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }}-user + name: {{ include "atlas-cluster.fullname" $ }}-{{ .username }} namespace: {{ $.Release.Namespace }} labels: {{- include "atlas-cluster.labels" $ | nindent 4 }}