Skip to main content
This installation method is not recommended for production environments.MongoDB is installed as only a single replica and data is stored on the first suitable worker node that does not have control-plane role using hostPath.If there is only one node in the cluster, the control-plane label and taint on the node must be removed with the following commands so that the pod can run on this node:
kubectl label node <node-name> node-role.kubernetes.io/control-plane-
kubectl taint nodes <node-name> node-role.kubernetes.io/control-plane:NoSchedule-
It is recommended to use NFS, Ceph, Longhorn or a cloud-based storage solution so that data can be stored independently of nodes.

Prerequisites

Before starting the installation, make sure the following requirements are met:
  • Kubernetes cluster is ready and accessible
  • Helm is installed in your environment
If Helm is not installed, you can review the Helm Installation Document page.

1) Adding Repository

helm repo add mongodb-charts https://apinizer1.github.io/mongodb-charts
helm repo update

2) Mongo Installation

You can perform MongoDB installation without any special settings by running the following command:
helm install mongodb-charts mongodb-charts/mongo
Note: Version mongo:8.0 is used in the current installation. If you want to prefer a more up-to-date version, you can use version mongo:8.0. You can review all Mongodb versions on Docker Hub.

Optional Parameters

OptionDefault ValueDescription
image.mongomongo:8.0Specifies the version of MongoDB image.
If you want to use a different MongoDB version, you can specify the version by adding the optional parameter as in the example below in your Helm installation command:
helm install mongo-charts mongo-charts/mongo --set image.mongo=mongo:latest

3) Installation Information

FieldDescription
TZ (Time Zone)Europe/Istanbul – Set with TZ environment variable inside the container. Thus, application and MongoDB logs work according to Turkey time.
Databaseapinizerdb
Usernamekubectl get secret -n mongo mongodb-secret -o jsonpath="{.data.MONGO_ROOT_USERNAME}" &#124; base64 --decode; echo
Passwordkubectl get secret -n mongo mongodb-secret -o jsonpath="{.data.MONGO_ROOT_PASSWORD}" &#124; base64 --decode; echo
Port25080
Data directory/mnt/data this directory is mapped with the path on your host machine (hostPath). Thus, data is kept on the host and is persistent.