MongoDB Installation with Helm
This document outlines the fundamental steps for deploying MongoDB on a Kubernetes cluster using Helm.
This installation method is not recommended for production environments.
MongoDB is installed as a single replica, and data is stored on the first suitable worker node that does not have the control-plane role, using hostPath.
If the cluster has only one node, the control-plane label and taint on that node must be removed with the following commands to allow pods to run on it:
kubectl label node <node-name> node-role.kubernetes.io/control-plane-
kubectl taint nodes <node-name> node-role.kubernetes.io/control-plane:NoSchedule-
To enable data storage independent of nodes, it is recommended to use NFS, Ceph, Longhorn, or a cloud-based storage solution.
Prerequisites
Your Kubernetes cluster must be up and accessible.
Helm must be installed in your environment.
If Helm is not installed, you can refer to the Installation with Helm.
1) Adding the Repository
helm repo add mongodb-charts https://apinizer1.github.io/mongodb-charts
helm repo update
2) Mongo Installation
You can install MongoDB without any custom configuration by running the following command:
helm install mongodb-charts mongodb-charts/mongo
Note: The current installation uses the mongo:8.0 image. If you prefer a more recent version, you can replace it with a newer one. You can browse all available MongoDB versions on Docker Hub.
Optional Parameters
Option | Default Value | Description |
---|---|---|
image.mongo | mongo:8.0 | Specifies the version of the MongoDB image. |
If you want to use a different MongoDB version, you can specify it by adding the optional parameter to your Helm installation command as shown in the example below:
helm install mongo-charts mongo-charts/mongo --set image.mongo=mongo:latest
3) Installation Details
Field | Description |
---|---|
TZ (Time Zone) | Europe/Istanbul – Set via the TZ environment variable inside the container. This ensures that the application and MongoDB logs operate according to Turkey's local time. |
Database | apinizerdb |
User Name | kubectl get secret -n mongo mongodb-secret -o jsonpath="{.data.MONGO_ROOT_USERNAME}" | base64 --decode; echo |
Passwords | kubectl get secret -n mongo mongodb-secret -o jsonpath="{.data.MONGO_ROOT_PASSWORD}" | base64 --decode; echo |
Port | 25080 |
Data dizini | /mnt/data bu dizin, host makinenizdeki path ile eşleştirilir (hostPath). Böylece veriler host üzerinde tutulur ve kalıcı olur. |