Deploy mongoDB (6.0.4) with a helmchart from bitnami.
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install my-release bitnami/mongodb
TEST SUITE: None
NOTES:
CHART NAME: mongodb
CHART VERSION: 13.8.3
APP VERSION: 6.0.4
** Please be patient while the chart is being deployed **
MongoDB® can be accessed on the following DNS name(s) and ports from within your cluster:
my-release-mongodb.default.svc.cluster.local
To get the root password run:
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace default my-release-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 -d)
To connect to your database, create a MongoDB® client container:
kubectl run --namespace default my-release-mongodb-client --rm --tty -i --restart='Never' --env="MONGODB_ROOT_PASSWORD=$MONGODB_ROOT_PASSWORD" --image docker.io/bitnami/mongodb:6.0.4-debian-11-r14 --command -- bash
Then, run the following command:
mongosh admin --host "my-release-mongodb" --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD
To connect to your database from outside the cluster execute the following commands:
kubectl port-forward --namespace default svc/my-release-mongodb 27017:27017 &
mongosh --host 127.0.0.1 --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD
helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
my-release default 1 2023-03-09 17:05:48.296817 +0100 CET deployed mongodb-13.8.3 6.0.4
# pull chart to examine
cd ~/Programming/Helm
helm pull bitnami/mongodb
ls
...
-rw-r--r-- 1 christianhofig staff 75986 9 Mär 17:08 mongodb-13.8.3.tgz
To understand what mongoDB offers, use https://www.mongodb.com/docs/manual/introduction/

When to use a document database instead of relational databases?
A document database is a great choice for content management applications such as blogs and video platforms. With a document database, each entity that the application tracks can be stored as a single document. The document database is more intuitive for a developer to update an application as the requirements evolve.
Google Search
More in depth here: https://www.prisma.io/dataguide/types/relational-vs-document-databases
MongoDB not starting properly, watch deployment logs:
kubectl run –namespace default my-release-mongodb-client –rm –tty -i –restart=’Never‘ –env=“MONGODB_ROOT_PASSWORD=$MONGODB_ROOT_PASSWORD“ –image docker.io/bitnami/mongodb:6.0.4-debian-11-r14 –command — bash
If you don’t see a command prompt, try pressing enter.
I have no name!@my-release-mongodb-client:/$
mongosh –verbose admin –host „my-release-mongodb“ –authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD
Current Mongosh Log ID: 640af7914281bfbb2d4cb564
Connecting to: mongodb://
MongoNetworkError: connect ECONNREFUSED 10.96.40.89:27017 <------------- ups
# not running yet:
luftichris:mongodb christianhofig$ k get pods
NAME READY STATUS RESTARTS AGE
knative-operator-6f555755b6-hnwbk 1/1 Running 0 21h
my-release-mongodb-6bf67ccb56-sspn6 0/1 Running 30 (2m18s ago) 17h
k logs -f deploy/my-release-mongodb
Found 2 pods, using pod/my-release-mongodb-6bf67ccb56-sspn6
mongodb 09:23:41.35
mongodb 09:23:41.36 Welcome to the Bitnami mongodb container
mongodb 09:23:41.37 Subscribe to project updates by watching https://github.com/bitnami/containers
mongodb 09:23:41.38 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mongodb 09:23:41.38
mongodb 09:23:41.38 INFO ==> ** Starting MongoDB setup **
mongodb 09:23:41.46 INFO ==> Validating settings in MONGODB_* env vars…
mongodb 09:23:41.70 INFO ==> Initializing MongoDB…
mongodb 09:23:41.97 INFO ==> Enabling authentication…
mongodb 09:23:42.00 INFO ==> Deploying MongoDB with persisted data…
mongodb 09:23:42.14 INFO ==> ** MongoDB setup finished! **
mongodb 09:23:42.24 INFO ==> ** Starting MongoDB **
{„t“:{„$date“:“2023-03-10T09:23:42.347Z“},“s“:“I“, „c“:“CONTROL“, „id“:5760901, „ctx“:“-„,“msg“:“Applied –setParameter options“,“attr“:{„serverParameters“:{„enableLocalhostAuthBypass“:{„default“:true,“value“:false}}}}
…
{„t“:{„$date“:“2023-03-10T09:23:42.348+00:00″},“s“:“I“, „c“:“CONTROL“, „id“:20698, „ctx“:“-„,“msg“:“***** SERVER RESTARTED *****“}
…
{„t“:{„$date“:“2023-03-10T09:23:51.527+00:00″},“s“:“I“, „c“:“NETWORK“, „id“:22943, „ctx“:“listener“,“msg“:“Connection accepted“,“attr“:{„remote“:“127.0.0.1:49212″,“uuid“:“c452fdd2-4c1e-4c9c-b5c7-4c463d09681a“,“connectionId“:1,“connectionCount“:1}}
…
{„t“:{„$date“:“2023-03-10T09:24:26.127+00:00″},“s“:“I“, „c“:“NETWORK“, „id“:22944, „ctx“:“conn19″,“msg“:“Connection ended“,“attr“:{„remote“:“127.0.0.1:49970″,“uuid“:“01db1547-e0ef-44e8-b627-ec0c432c30ed“,“connectionId“:19,“connectionCount“:4}}
{„t“:{„$date“:“2023-03-10T09:26:24.070+00:00″},“s“:“I“, „c“:“CONTROL“, „id“:23377, „ctx“:“SignalHandler“,“msg“:“Received signal“,“attr“:{„signal“:15,“error“:“Terminated“}}
{„t“:{„$date“:“2023-03-10T09:26:24.070+00:00″},“s“:“I“, „c“:“CONTROL“, „id“:23378, „ctx“:“SignalHandler“,“msg“:“Signal was sent by kill(2)“,“attr“:{„pid“:0,“uid“:0}}
{„t“:{„$date“:“2023-03-10T09:26:24.070+00:00″},“s“:“I“, „c“:“CONTROL“, „id“:23381, „ctx“:“SignalHandler“,“msg“:“will terminate after current cmd ends“}
{„t“:{„$date“:“2023-03-10T09:26:24.070+00:00″},“s“:“I“, „c“:“REPL“, „id“:4784900, „ctx“:“SignalHandler“,“msg“:“Stepping down the ReplicationCoordinator for shutdown“,“attr“:{„waitTimeMillis“:15000}}
{„t“:{„$date“:“2023-03-10T09:26:24.318+00:00″},“s“:“I“, „c“:“CONTROL“, „id“:20565, „ctx“:“SignalHandler“,“msg“:“Now exiting“}
{„t“:{„$date“:“2023-03-10T09:26:24.324+00:00″},“s“:“I“, „c“:“CONTROL“, „id“:23138, „ctx“:“SignalHandler“,“msg“:“Shutting down“,“attr“:{„exitCode“:0}}
# pods not running
k get all
NAME READY STATUS RESTARTS AGE
pod/knative-operator-6f555755b6-hnwbk 1/1 Running 0 21h
pod/my-release-mongodb-5bf9945cc5-kx64g 0/1 Running 2 (2m ago) 7m20s
pod/my-release-mongodb-6bf67ccb56-sspn6 0/1 CrashLoopBackOff 32 (16s ago) 17h
# pod logs
{„t“:{„$date“:“2023-03-10T09:38:49.534+00:00″},“s“:“E“, „c“:“CONTROL“, „id“:20557, „ctx“:“initandlisten“,“msg“:“DBException in initAndListen, terminating“,“attr“:{„error“:“DBPathInUse: Unable to lock the lock file: /bitnami/mongodb/data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /bitnami/mongodb/data/db directory“}}
# remove the helm chart, install again
# pod log
…
{„t“:{„$date“:“2023-03-10T09:45:56.182+00:00″},“s“:“I“, „c“:“NETWORK“, „id“:51800, „ctx“:“conn62″,“msg“:“client metadata“,“attr“:{„remote“:“127.0.0.1:52192″,“client“:“conn62″,“doc“:{„driver“:{„name“:“nodejs|mongosh“,“version“:“4.13.0″},“os“:{„type“:“Linux“,“name“:“linux“,“architecture“:“x64″,“version“:“5.10.76-linuxkit“},“platform“:“Node.js v16.19.0, LE (unified)“,“version“:“4.13.0|1.7.1″,“application“:{„name“:“mongosh 1.7.1″}}}}
…
{„t“:{„$date“:“2023-03-10T09:46:37.031+00:00″},“s“:“I“, „c“:“NETWORK“, „id“:23016, „ctx“:“listener“,“msg“:“Waiting for connections“,“attr“:{„port“:27017,“ssl“:“off“}}
Need to continue with https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/
MongoDB in docker container:
docker run -d -p 27017:27017 --name test-mongo mongo:latest
docker exec -it $(docker ps | grep mongo:latest | cut -f1 -d' ') bash
mongosh admin
Current Mongosh Log ID: 640aff6cb69a831f951831f4
Connecting to: mongodb://127.0.0.1:27017/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.8.0
Using MongoDB: 6.0.4
Using Mongosh: 1.8.0
For mongosh info see: https://docs.mongodb.com/mongodb-shell/
To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.
------
The server generated these startup warnings when booting
2023-03-10T09:54:28.022+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
2023-03-10T09:54:31.407+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2023-03-10T09:54:31.408+00:00: vm.max_map_count is too low
------
------
Enable MongoDB's free cloud-based monitoring service, which will then receive and display
metrics about your deployment (disk utilization, CPU, operation statistics, etc).
The monitoring data will be available on a MongoDB website with a unique URL accessible to you
and anyone you share the URL with. MongoDB may use this information to make product
improvements and to suggest MongoDB products and deployment options to you.
To enable free monitoring, run the following command: db.enableFreeMonitoring()
To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
------
admin> db
admin
admin> use examples
switched to db examples
examples> db.myNewCollection1.insertOne( { x: 1 } )
{
acknowledged: true,
insertedId: ObjectId("640affe0a4cb910eedf6de1a")
}