https://github.com/markpeterfejes/mongo-repl-init-container
A simple init-container for setting up replication in a kubernetes Stateful-set
https://github.com/markpeterfejes/mongo-repl-init-container
database docker init-containers kubernetes mongodb nodejs statefulsets
Last synced: 3 months ago
JSON representation
A simple init-container for setting up replication in a kubernetes Stateful-set
- Host: GitHub
- URL: https://github.com/markpeterfejes/mongo-repl-init-container
- Owner: markpeterfejes
- License: mit
- Created: 2017-07-28T09:10:03.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-11T14:06:10.000Z (over 8 years ago)
- Last Synced: 2026-02-18T01:41:10.443Z (4 months ago)
- Topics: database, docker, init-containers, kubernetes, mongodb, nodejs, statefulsets
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongo-repl-init-container
This 'small' container let's your use mongodb as a Stateful Set in your kubernetes cluster. It will automatically find any other instances in the same namespace, if you have a headless service specified.
### Example kubernetes headless Service:
```json
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"name": "mongo",
"annotations": {
"service.alpha.kubernetes.io/tolerate-unready-endpoints": "true"
},
"labels": {
"app": "mongo"
}
},
"spec": {
"ports": [
{
"port": 27017,
"name": "mongo-port"
}
],
"type": "ClusterIP",
"clusterIP": "None",
"selector": {
"app": "mongo"
}
}
}
```
### Example kubernetes StatefulSet:
```json
{
"apiVersion": "apps/v1beta1",
"kind": "StatefulSet",
"metadata": {
"name": "mongodb"
},
"spec": {
"serviceName": "mongo",
"replicas": 3,
"template": {
"metadata": {
"labels": {
"app": "mongo"
}
},
"spec": {
"initContainers": [
{
"name": "mongo-init",
"image": "markpeterfejes/mongo-repl-init-container:latest",
"volumeMounts": [
{
"name": "mongo",
"mountPath": "/data/db"
},
{
"name": "mongod-config",
"mountPath": "/mongod-config"
},
{
"name": "workdir",
"mountPath": "/workdir"
}
]
}
],
"containers": [
{
"name": "mongo",
"image": "mongo:3.4.9",
"command": [
"mongod",
"--config",
"/mongod-config/mongod.conf"
],
"ports": [
{
"containerPort": 27017,
"name": "mongo"
}
],
"volumeMounts": [
{
"name": "mongo",
"mountPath": "/data/db"
},
{
"name": "mongod-config",
"mountPath": "/mongod-config"
},
{
"name": "workdir",
"mountPath": "/workdir"
}
],
"readinessProbe": {
"exec": {
"command": [
"bash",
"/workdir/health-check.sh"
]
},
"initialDelaySeconds": 5,
"timeoutSeconds": 1
},
"livenessProbe": {
"exec": {
"command": [
"bash",
"/workdir/health-check.sh"
]
},
"initialDelaySeconds": 30,
"periodSeconds": 10,
"timeoutSeconds": 2
}
}
],
"volumes": [
{
"name": "mongod-config",
"configMap": {
"name": "mongodb-config"
}
},
{
"name": "workdir",
"emptyDir": {
"medium": "Memory"
}
}
]
}
},
"volumeClaimTemplates": [
{
"metadata": {
"name": "mongo"
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "50Gi"
}
}
}
}
]
}
}
```