I’m trying to setup a MongoDB ReplicaSet with Helm Chart. I added the following dependency in my Chart.yaml file:
dependencies:
- name: mongodb
version: "15.3.1"
repository: "https://charts.bitnami.com/bitnami"
And my values.yaml file has this configuration:
mongodb:
architecture: replicaset
replicaCount: 3
externalAccess:
enabled: true
service:
type: LoadBalancer
autoDiscovery:
enabled: true
serviceAccount:
create: true
automountServiceAccountToken: true
rbac:
create: true
auth:
enabled: false
initdbScripts:
setup_replicaset_script.js : |
rs.add("test-mongodb-0-external.default.svc.cluster.local:27017")
rs.add("test-mongodb-1-external.default.svc.cluster.local:27017")
rs.add("test-mongodb-2-external.default.svc.cluster.local:27017")
However, when I do:
helm dependency update test1
helm dependency build test1
helm install test test1
I found two issues:
The first issue is that I’m getting 3 services, which is correct as per my configuration:
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 8m52s
test-mongodb-0-external LoadBalancer 10.107.131.138 127.0.0.1 27017:32498/TCP 8m23s
test-mongodb-1-external LoadBalancer 10.110.127.112 127.0.0.1 27017:32345/TCP 8m23s
test-mongodb-2-external LoadBalancer 10.109.4.225 127.0.0.1 27017:31756/TCP 8m23s
test-mongodb-arbiter-headless ClusterIP None <none> 27017/TCP 8m23s
test-mongodb-headless ClusterIP None <none> 27017/TCP 8m23s
But I’m only getting 2 pods (test-mongodb-2 seems to be missing for some reason)
k8s kubectl get po
NAME READY STATUS RESTARTS AGE
test-mongodb-0 1/1 Running 0 16m
test-mongodb-1 0/1 Running 0 16m
test-mongodb-arbiter-0 1/1 Running 1 (15m ago) 16m
And the second issue is that the ReplicaSet gets initialized on test-mongodb-0 but not in test-mongodb-1
I tried many of the more recent versions of the chart and the issue still persists. I’m not sure if I’m missing some configuration.