How to create kubernetes pod that contains Docker with mongodb

5/8/2019

How to create a pod in Kubernetes that contains an immage Docker that contain mongodb?

-- F. Ziliani
docker
kubernetes
mongodb

2 Answers

5/8/2019

Ziliani, this question is a little unclear. We do not know if your goal is to put mongodb into a Pod or you would like to run mongodb in Kubernetes. In future try to be more clear with what you want to achieve and what have you already tried so we can know how to help you.

If you want to easily deploy Mongodb in Kubernetes you can use helm charts as Vasily mentions or you can also check this guide on mongodb github. Also you could read this article to figure out what you should be taking notice of.

This tutorial on the other hand explains full process of running mongodb in Google Kubernetes Engine using StatefulSet.

If you just want a running Pod with mongodb inside, like you have wrote below:

Because i would an file yaml. That include this instruction of Docker docker run -p 27017:27017 --name mongodb bitnami/mongodb:latest

You can use this pod yaml as a reference:

apiVersion: v1
kind: Pod
metadata:
  name: mongoDB
spec:
  volumes:
  - name: mongodb-pod
    hostPath:
      path: /tmp/mongodb
  containers:
  - image: bitnami/mongodb:latest
    name: mongodb
    volumeMounts:
    - name: mongodb-data
      mountPath: /data/db
    ports:
    - containerPort: 27017
      protocol: TCP
-- aurelius
Source: StackOverflow

5/8/2019

Easiest way to do that is use Helm - package manager for Kubernetes.

How to start using Helm

MongoDB Helm Chart

-- Vasily Angapov
Source: StackOverflow