Categorygithub.com/mindmain/go-mongo-sidecar
module
0.0.0-20250128175036-99646de54ead
Repository: https://github.com/mindmain/go-mongo-sidecar.git
Documentation: pkg.go.dev

# README

Go mongo sidecar

Go mongo sidecar is an application written in golang, which using the sidecar patter provides for the realignment and configuration of a mongo replicaSet.

How use it

use this images to use go-mongo-sidecar ghcr.io/mindmain/go-mongo-sidecar:0.1.0. You must define follow environment variables:

  • MONGO_REPLICA_SET
  • HEADLESS_SERVICE
  • KUBE_NAMESPACE

see examples to complete example. you can see all go-mongo-sidecar versions releases

How does it work

Each go sidecar has a wait time and a pause time, only the node that is recognized as primary will make reconfiguration changes to the mongo replicaSet. They will be read through the kubernets client through a selector with labels. Then they will be passed to mongo which receives the configuration.

Every cycle check status and the conditions change, the sidecar will report the change in the logs like the following example:

2023/12/31 15:49:39 [INFO]
Detect change status: sidecar mongo-0 i'm primary
replica members: mongo-0 (PRIMARY), mongo-1 (SECONDARY), mongo-2 (SECONDARY)
matched pods: mongo-0, mongo-1, mongo-2

environment variables

MONGO_REPLICA_SET is REQUIRED is the name of replicaset used on command startup mongo.

NameDescriptionDefault value
MONGO_PORTset the mongo will use to connect27017
MONGO_HOSThost used to connect to service mongo managed of sidecarlocalhost
MONGO_USERif connection required authenticationempty
MONGO_PASSWORDif connection required authenticationempty
MONGO_REPLICA_SETname of replica set used into commandline stratup mongodempity
HEADLESS_SERVICEcomplete dns of service clusterIp nonemongo.default.svc.cluster.local
SIDECAR_TIME_TO_WAITtime must wait sidecar before run30
SIDECAR_TIME_SLEEPHow much time must pass between one status request and another5
SIDECAR_SELECTOR_PODselector to localize pods inside cluster (many times it coincides with the match label of the service)app=mongo

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author