Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
39 changes: 39 additions & 0 deletions charts/mongodb/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: v2
name: mongodb
description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas.
icon: https://minio.lab.sspcloud.fr/projet-onyxia/assets/servicesImg/mongodb.png
keywords:
- nosql
- Database
- json
home: https://www.mongodb.com/
sources:
- https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/mongodb
- https://github.com/bitnami/charts/tree/master/bitnami/mongodb
- https://github.com/bitnami/bitnami-docker-mongodb
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
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.2.3

# 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.
appVersion: "1"
dependencies:
- name: mongodb
version: 14.12.3
repository: https://charts.bitnami.com/bitnami
- name: library-chart
version: 1.5.21
repository: https://inseefrlab.github.io/helm-charts-interactive-services
40 changes: 40 additions & 0 deletions charts/mongodb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# mongodb

![Version: 0.2.3](https://img.shields.io/badge/Version-0.2.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1](https://img.shields.io/badge/AppVersion-1-informational?style=flat-square)

NoSQL document-oriented database that stores JSON-like documents with dynamic schemas.

**Homepage:** <https://www.mongodb.com/>

## Source Code

* <https://github.com/InseeFrLab/helm-charts-datascience/tree/master/charts/mongodb>
* <https://github.com/bitnami/charts/tree/master/bitnami/mongodb>
* <https://github.com/bitnami/bitnami-docker-mongodb>

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | mongodb | 13.18.5 |
| https://inseefrlab.github.io/helm-charts-interactive-services | library-chart | 1.5.18 |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| fullnameOverride | string | `"mongodb"` | |
| mongodb.architecture | string | `"replicaset"` | |
| mongodb.auth.database | string | `"defaultdb"` | |
| mongodb.auth.password | string | `"changeme"` | |
| mongodb.auth.rootPassword | string | `"changeme"` | |
| mongodb.auth.username | string | `"username"` | |
| mongodb.discoverable.allow | bool | `true` | |
| mongodb.fullnameOverride | string | `"mongodb"` | |
| mongodb.image.tag | string | `"4.4"` | |
| mongodb.replicaCount | int | `2` | |
| mongodb.resources | object | `{}` | |
| security.networkPolicy.enabled | bool | `true` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
36 changes: 36 additions & 0 deletions charts/mongodb/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- $replicaCount := int .Values.mongodb.replicaCount }}
{{- $portNumber := int .Values.mongodb.service.ports.mongodb }}
{{- $fullname := include "library-chart.fullname" . }}
{{- $user := .Values.mongodb.auth.username }}
{{- $password := .Values.mongodb.auth.password }}
{{- $rootPassword := .Values.mongodb.auth.rootPassword }}
{{- $db := .Values.mongodb.auth.database }}
{{- $pvcList := list }}
{{- $mongoList := list }}
{{- range $e, $i := until $replicaCount }}
{{- $pvcList = append $pvcList (printf "datadir-%s-%d" $fullname $i) }}
{{- $mongoList = append $mongoList (printf "%s-%d.%s-headless:%d" $fullname $i $fullname $portNumber) }}
{{- end }}
- the connection string is :

**`mongodb://{{ $user }}:{{ $password }}@{{ (include "mongoList" .)}}/{{ $db }}?authSource={{ $db }}`**
- example for python :

```
from pymongo import MongoClient
client = MongoClient('mongodb://{{ $user }}:{{ $password }}@{{ (include "mongoList" .) }}/{{ $db }}')
db=client.{{ $db }}
```
- example for mongosh :

* as user in {{ $db }}
`mongo -u {{ $user }} -p {{ $password }} --authenticationDatabase {{ $db }}`
* as root
`mongo -u root -p {{ $rootPassword }}`

*NOTES about deletion :*

- **You can safely delete this chart and recreate one later**
- Data volumes will not be deleted
- If you start a new {{ .Chart.Name }}, it will reuse those volumes silently.
- If you want to delete those volume definitily : `kubectl delete pvc {{ join " " $pvcList }}`
10 changes: 10 additions & 0 deletions charts/mongodb/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- define "mongoList" -}}
{{- $replicaCount := int .Values.mongodb.replicaCount }}
{{- $portNumber := int .Values.mongodb.service.ports.mongodb }}
{{- $fullname := include "library-chart.fullname" . }}
{{- $mongoList := list }}
{{- range $e, $i := until $replicaCount }}
{{- $mongoList = append $mongoList (printf "%s-%d.%s-headless:%d" $fullname $i $fullname $portNumber) }}
{{- end }}
{{- printf "%s" (join "," $mongoList) -}}
{{- end }}
27 changes: 27 additions & 0 deletions charts/mongodb/templates/discovery-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.mongodb.discoverable.allow }}
{{- $fullname := include "library-chart.fullname" . }}
{{- $secretName := printf "%s-%s" "discoverable" $fullname -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ $secretName }}
annotations:
onyxia/discovery: "mongodb"
type: Opaque
data:
mongodb-service: {{ (include "mongoList" .) | b64enc | quote }}
mongodb-name: {{ printf "%s" $fullname | b64enc | quote }}
{{- if .Values.mongodb.auth.password }}
mongodb-password: {{ .Values.mongodb.auth.password | b64enc | quote }}
{{- end }}
{{- if .Values.mongodb.auth.username }}
mongodb-username: {{ .Values.mongodb.auth.username | b64enc | quote }}
{{- end }}
{{- if .Values.mongodb.auth.database }}
mongodb-database: {{ .Values.mongodb.auth.database | b64enc | quote }}
{{- end }}
{{- if .Values.mongodb.auth.rootPassword }}
mongodb-rootPassword: {{ .Values.mongodb.auth.rootPassword | b64enc | quote }}
{{- end }}

{{- end -}}
28 changes: 28 additions & 0 deletions charts/mongodb/templates/tests/test-db-connection-custom-user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.mongodb.auth.enabled }}
{{- if not (empty .Values.mongodb.auth.username) }}
{{- if not (empty .Values.mongodb.auth.password) }}
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "library-chart.fullname" . }}-test-db-connection-custom-user"
labels:
{{- include "library-chart.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": hook-succeeded
spec:
containers:
- name: {{ include "library-chart.fullname" . }}-test-connection-custom-user
image: "bitnami/mongodb:7.0.2"
env:
- name: DATABASE_NAME
value: {{ .Values.mongodb.auth.database }}
- name: USER
value: {{ .Values.mongodb.auth.username }}
- name: PASSWORD
value: {{ .Values.mongodb.auth.password }}
command: ["sh", "-c", " mongosh mongodb://$USER:$PASSWORD@{{ include "mongoList" . }}/$DATABASE_NAME?authSource=$DATABASE_NAME" ]
restartPolicy: Never
{{- end }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/mongodb/templates/tests/test-db-connection-root-user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if .Values.mongodb.auth.enabled }}
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "library-chart.fullname" . }}-test-db-connection-root-user"
labels:
{{- include "library-chart.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": hook-succeeded
spec:
containers:
- name: {{ include "library-chart.fullname" . }}-test-connection-root-user
image: "bitnami/mongodb:7.0.2"
env:
- name: ROOT_USER
value: {{ .Values.mongodb.auth.rootUser }}
- name: PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "library-chart.fullname" . }}
key: mongodb-root-password
command: ["sh", "-c", " mongosh mongodb://$ROOT_USER:$PASSWORD@{{ include "mongoList" . }}/?authSource=admin "]
restartPolicy: Never
{{- end }}
Loading