Sign inSign up

nesze/coco-mongodb

By nesze

•Updated over 5 years ago

upp-mongodb

Image
0

1.5K

nesze/coco-mongodb repository overview

⁠MongoDB wrapper

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.

⁠Mongo configurator

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.

⁠Troubleshooting

⁠Access to the data

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
⁠Access to the data without mongodb running

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:

  1. Stop the mongo instance

    kc scale deployment mongodb-x --replicas 0
    
  2. 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"
    
  3. Deploy the pod:

    kubectl apply -f mongo-debug-x.yaml
    
  4. 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
    

Tag summary

Content type

Image

Digest

Size

127.3 MB

Last updated

over 5 years ago

docker pull nesze/coco-mongodb