0

I am trying to run mongodb via helm. I want to run 1 primary replica and 2 secondary replicas.

I would like to setup the following naming for the 3 mongodb pods once they are created: mongo-0 mongo-1 mongo-2 And lets say that mongo-0 would be primary.

When I run the following command

helm install --name mongo ~/charts/stable/mongodb --set replicaSet.enabled=true,fullnameOverride=mongo

The pods do not have require naming:

kubectl get pods
NAME                      READY   STATUS        RESTARTS   AGE
mongo-arbiter-0           1/1     Running       0          15s
mongo-primary-0           0/1     Running       0          15s
mongo-secondary-0         0/1     Running       0          15s

Please any advice how can I change that ? I tried it also via changing values-production.yml but the same output.

  • Can you post output of kubectl get rs? – Crou Jul 26 at 11:55
0

You need to modify the mongoDB helm chart template.

To be more specific you need to change following files.

charts/stable/mongodb/templates/statefulset-arbiter-rs.yaml

edit lines:

name: {{ template "mongodb.fullname" . }}-arbiter

and

- name: {{ template "mongodb.name" . }}-arbiter

And replace arbiter with the name of ReplicaSet you want.

charts/stable/mongodb/templates/statefulset-primary-rs.yaml

edit lines:

name: {{ template "mongodb.fullname" . }}-primary

and

- name: {{ template "mongodb.name" . }}-primary

And replace primary with the name of ReplicaSet you want.

charts/stable/mongodb/templates/statefulset-secondary-rs.yaml

edit lines:

name: {{ template "mongodb.fullname" . }}-secondary

and

- name: {{ template "mongodb.name" . }}-secondary

And replace secondary with the name of ReplicaSet you want.

  • it is a good idea but not 100% effective. I am running the pods in statefulset so kubectl get rs returns no output. Here is kubectl get ss: kubectl get statefulsets NAME DESIRED CURRENT AGE mongo-0 1 1 93s mongo-1 1 1 93s mongo-2 1 1 93s After changing the configs as Crou suggested I get pods like this: kubectl get pods NAME READY STATUS RESTARTS AGE mongo-0-0 1/1 Running 0 39s mongo-1-0 1/1 Running 0 39s mongo-2-0 1/1 Running 0 39s – Palino1611 Jul 28 at 20:23
  • Check this SO link – Crou Jul 29 at 10:53
0

as my comment does not show in very readable form I ma posting my comment also here:

it is a good idea but not 100% effective. I am running the pods in statefulset so kubectl get rs returns no output. Here is kubectl get ss:

kubectl get statefulsets
NAME      DESIRED   CURRENT   AGE
mongo-0   1         1         93s
mongo-1   1         1         93s
mongo-2   1         1         93s

After changing the configs as Crou suggested I get pods like this:

kubectl get pods
NAME        READY   STATUS    RESTARTS   AGE
mongo-0-0   1/1     Running   0          39s
mongo-1-0   1/1     Running   0          39s
mongo-2-0   1/1     Running   0          39s

Now I would like to delete the -0 in the end so I get:

kubectl get pods
NAME        READY   STATUS    RESTARTS   AGE
mongo-0   1/1     Running   0          39s
mongo-1   1/1     Running   0          39s
mongo-2   1/1     Running   0          39s

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.