MongoDB wrapper that runs in a 3 node replicaset.
For keeping the persistent data it uses 3 k8s Persistent Volumes, one for each replicaset. The PVs (EBS volumes) are managed manually.
On the first start with empty data, MongoDB needs configuration to run in a
replica set. On a Kubernetes cluster this is achieved automatically by a mongo
configurator job
that runs only on the first helm install in a cluster.
You can have access to the data by entering the pod and looking into /data/db
kubectl exec -it mongodb-x-...... /bin/bash
#inside the pod
cd /data/db
If, for some reason (like restore debug) you need access to the data, but without the instance running you can use a temporary pod to mount mongo's persistent volume.
Here are the steps for it:
Stop the mongo instance
kc scale deployment mongodb-x --replicas 0
Create a file mongo-debug-x.yaml with the following contents:
apiVersion: v1
kind: Pod
metadata:
name: mongo-x-debug
spec:
tolerations:
- key: "dedicated"
operator: "Equal"
value: "mongo"
effect: "NoSchedule"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kube-aws.coreos.com/role
operator: In
values:
- mongo-worker
containers:
- name: debug
image: alpine
# Just spin & wait forever
command: [ "/bin/sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
volumeMounts:
- name: mongo-x-data
mountPath: /data/db
volumes:
- name: mongo-x-data
persistentVolumeClaim:
claimName: "mongodb-pvc-x"
Deploy the pod:
kubectl apply -f mongo-debug-x.yaml
Enter the pod and find the volume mounted in /data/db
kubectl exec -it mongo-x-debug /bin/bash
#inside the pod
cd /data/db
Content type
Image
Digest
Size
127.3 MB
Last updated
over 5 years ago
docker pull nesze/coco-mongodb