Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit 528a7ae

Browse files
committed
add authSource param and mongosh example
1 parent b96d719 commit 528a7ae

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

charts/mongodb/templates/NOTES.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{{- $fullname := include "library-chart.fullname" . }}
44
{{- $user := .Values.mongodb.auth.username }}
55
{{- $password := .Values.mongodb.auth.password }}
6+
{{- $rootPassword := .Values.mongodb.auth.rootPassword }}
67
{{- $db := .Values.mongodb.auth.database }}
78
{{- $pvcList := list }}
89
{{- $mongoList := list }}
@@ -11,14 +12,21 @@
1112
{{- $mongoList = append $mongoList (printf "%s-%d.%s-headless:%d" $fullname $i $fullname $portNumber) }}
1213
{{- end }}
1314
- the connection string is :
14-
**`mongodb://{{ $user }}:{{ $password }}@{{ (include "mongoList" .)}}/{{ $db }}`**
15+
16+
**`mongodb://{{ $user }}:{{ $password }}@{{ (include "mongoList" .)}}/{{ $db }}?authSource{{ $db }}`**
1517
- example for python :
1618

1719
```
1820
from pymongo import MongoClient
19-
client = MongoClient('mongodb://{{ $user }}:{{ $password }}@{{ (include "mongoList" .) }}/{{ $db }}')
21+
client = MongoClient('mongodb://{{ $user }}:{{ $password }}@{{ (include "mongoList" .) }}/{{ $db }}?authSource{{ $db }}')
2022
db=client.{{ $db }}
2123
```
24+
- example for mongosh :
25+
26+
* as user in {{ $db }}
27+
`mongo -u {{ $user }} -p {{ $password }} --authenticationDatabase {{ $db }}`
28+
* as root
29+
`mongo -u root -p {{ $rootPassword }}`
2230

2331
*NOTES about deletion :*
2432

0 commit comments

Comments
 (0)