PoC: MongoDB ReplicaSet without Sidecar

Asking for help? Comment out what you need so we can get more information to help you!

Cluster information:

Kubernetes version: 1.18.3
Cloud being used: bare-metal
Installation method: native yaml /kubectl
Host OS: Minikube
REPO: (https://github.com/noelmcloughlin/k8s-statefulsets/blob/master/mongo-set.yaml )

I’m very close to getting MongoDB Statefulset without sidecar working. One last problem - I need hostnames, i.e. mongo-n.mongo.default.svc.cluster.local resolvable between ReplicaSet members. I followed docs for headless service without luck. The use case is fewer containers.

If anyone can help I would appreciate this. I’m stuck.

curl -LO https://github.com/noelmcloughlin/k8s-statefulsets/blob/master/mongo-set.yaml
kubectl apply -f mongo-set.yaml

Got headless service working. I could use this for Replicset initialisation but that implies a static configuration. Maybe leveraging script for livenessProbe is an option for dynamic configuration.

% kubectl exec -it mongo-0 -- bash
root@mongo-0:/# nslookup mongo

Name:	mongo.default.svc.cluster.local
Name:	mongo.default.svc.cluster.local
Name:	mongo.default.svc.cluster.local

root@mongo-0:/# host mongo-0.mongo
mongo-0.mongo.default.svc.cluster.local has address
root@mongo-0:/# host mongo-1.mongo
mongo-1.mongo.default.svc.cluster.local has address
root@mongo-0:/# host mongo-2.mongo
mongo-2.mongo.default.svc.cluster.local has address