[stable/mongodb] - Allow using custom initialization scripts (#8272)

* [stable/mongodb] - Allow using custom initialization scripts

Signed-off-by: tompizmor <tompizmor@gmail.com>

* Avoid creating config-map if not needed

Signed-off-by: tompizmor <tompizmor@gmail.com>

* Delete blank line

Signed-off-by: tompizmor <tompizmor@gmail.com>

* Add missing conditional blocks

Signed-off-by: tompizmor <tompizmor@gmail.com>
This commit is contained in:
Tomas Pizarro
2018-10-10 00:19:57 -07:00
committed by k8s-ci-robot
parent 95bc9a81d0
commit f2749dde10
6 changed files with 46 additions and 6 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
name: mongodb
version: 4.3.10
version: 4.4.0
appVersion: 4.0.3
description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications.
keywords:
+7 -1
View File
@@ -86,7 +86,7 @@ The following table lists the configurable parameters of the MongoDB chart and t
| `persistence.accessMode` | Use volume as ReadOnly or ReadWrite | `ReadWriteOnce` |
| `persistence.size` | Size of data volume | `8Gi` |
| `persistence.annotations` | Persistent Volume annotations | `{}` |
| `persistence.existingClaim` | Name of an existing PVC to use (avoids creating one if this is given) | `nil` |
| `persistence.existingClaim` | Name of an existing PVC to use (avoids creating one if this is given) | `nil` |
| `livenessProbe.initialDelaySeconds` | Delay before liveness probe is initiated | `30` |
| `livenessProbe.periodSeconds` | How often to perform the probe | `10` |
| `livenessProbe.timeoutSeconds` | When the probe times out | `5` |
@@ -144,6 +144,12 @@ Some characteristics of this chart are:
* The number of secondary and arbiter nodes can be scaled out independently.
* Easy to move an application from using a standalone MongoDB server to use a replica set.
## Initialize a fresh instance
The [Bitnami MongoDB](https://github.com/bitnami/bitnami-docker-mongodb) image allows you to use your custom scripts to initialize a fresh instance. In order to execute the scripts, they must be located inside the chart folder `files/docker-entrypoint-initdb.d` so they can be consumed as a ConfigMap.
The allowed extensions are `.sh`, and `.js`.
## Persistence
The [Bitnami MongoDB](https://github.com/bitnami/bitnami-docker-mongodb) image stores the MongoDB data and configurations at the `/bitnami/mongodb` path of the container.
@@ -0,0 +1,3 @@
You can copy here your custom .sh, or .js file so they are executed during the first boot of the image.
More info in the [bitnami-docker-mongodb](https://github.com/bitnami/bitnami-docker-mongodb#initializing-a-new-instance) repository.
@@ -110,6 +110,10 @@ spec:
volumeMounts:
- name: data
mountPath: /bitnami/mongodb
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }}
- name: custom-init-scripts
mountPath: /docker-entrypoint-initdb.d
{{- end }}
{{- if .Values.configmap }}
- name: config
mountPath: /opt/bitnami/mongodb/conf/mongodb.conf
@@ -118,6 +122,11 @@ spec:
resources:
{{ toYaml .Values.resources | indent 10 }}
volumes:
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }}
- name: custom-init-scripts
configMap:
name: {{ template "mongodb.fullname" . }}-init-scripts
{{- end }}
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
@@ -0,0 +1,13 @@
{{ if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "mongodb.fullname" . }}-init-scripts
labels:
app: {{ template "mongodb.name" . }}
chart: {{ template "mongodb.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
data:
{{ (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]").AsConfig | indent 2 }}
{{ end }}
@@ -124,17 +124,26 @@ spec:
volumeMounts:
- name: datadir
mountPath: /bitnami/mongodb
{{- if .Values.configmap }}
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }}
- name: custom-init-scripts
mountPath: /docker-entrypoint-initdb.d
{{- end }}
{{- if .Values.configmap }}
- name: config
mountPath: /opt/bitnami/mongodb/conf/mongodb.conf
subPath: mongodb.conf
{{- end }}
{{- end }}
volumes:
{{- if .Values.configmap }}
{{- if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js]") }}
- name: custom-init-scripts
configMap:
name: {{ template "mongodb.fullname" . }}-init-scripts
{{- end }}
{{- if .Values.configmap }}
- name: config
configMap:
name: {{ template "mongodb.fullname" . }}
{{- end }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata: