K8S MongoDB Operator and Statfulsets
Mostly the same as recent Minio Statefulsets notes.
Good reads as follow.
https://www.mongodb.com/docs/kubernetes-operator/master/tutorial/om-arch
First, Set up NFS Server from my link below.
Then, Set up the folder for MongoDB. Navigate to folder /mnt/nfs_share and create folder mongodb, mongodb0, mongodb1, log0, log1
cd /mnt/nfs_share
mkdir mongodb
cd mongodb
mkdir mongodb0
mkdir mongodb1
mkdir log0
mkdir log1
chmod and chown to nobody:nogroup
chmod 777 mongodb0
chmod 777 mongodb1
chmod 777 log0
chmod 777 log1
sudo chown nobody:nogroup mongodb0
sudo chown nobody:nogroup mongodb1
sudo chown nobody:nogroup log0
sudo chown nobody:nogroup log1
This is my repo.
Next, apply yml file to deploy MongoDB Operator and StatefulSets. You must change NFS Server IP to yours (in pv.yml). You must change External IP to yours(in statefulsets-template.yml). You can change the port number if you like(in service.yml). This is for example only.
Next, Config traefik to expose MongoDB to outside world.
From my traefik repo.
After Deploy MongoDB and Traefik, You can access MongoDB at your ip:port from your client like Robo3T
My mongodb-0 is primary that can read/write and mongodb-1 is read only.