MongoDB installation on IKS (IBM Kubernetes Service) and OpenShift on IBM Cloud


MongoDB is a cross-platform document-oriented database. Classified as a NoSQL database, MongoDB eschews the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making the integration of data in certain types of applications easier and faster.

In IBM Cloud™ you can configure your installation from the Create tab, and then install it with a single click instead of executing the Helm installation directly. Your Helm Chart is installed by using IBM Cloud Schematics, and after the installation is complete, you can view the Chart instance, update the version, or uninstall from your Schematics workspace. Using Schematics you can enable Infrastructure as Code (IaC) by codifying your IBM Cloud resources with Terraform and use Schematics workspaces to start automating the provisioning and management of your resources. If you are installing an instance for a production configuration, review the considerations for adjusting the configuration parameters.


  1. Before starting, you need to have IKS clusters on IBM cloud.

If you don’t have the cluster, provisioning it first at IBM cloud portal . IKS support 2 types of infrastructure, Classic and VPC. Classic is general one but IBM Cloud Virtual Servers for VPC offer agile scalability for easy business growth, high availability for better customer satisfaction, security for your workloads and lower total cost of ownership. It provides high speed network interface and large amount of cores.

2. Create namespace for mongodb like “mongodb”, but you can use existing one.

The easiest way to create namespace is using Web Terminal on cluster overview screen. The shell has authority already, you don’t need to login with user and password.

$ kubectl get ns
default Active 21h
ibm-cert-store Active 21h
ibm-observe Active 20h
ibm-operators Active 21h
ibm-system Active 21h
kube-node-lease Active 21h
kube-public Active 21h
kube-system Active 21h
$ kubectl create ns mongodb
namespace/mongodb created

3. Install “IBM Cloud Block storage plug-in” from the catalog. It support dynamic creation of PV with “ibm-block-storage-driver”.

Provisioning MongoDB

From the catalog of IBM cloud portal, you can see 3 kinds of MongoDB. You will work with MongoDB, which is first one.

Click the tile “MongoDB” and then you go to the Helm chart configuration screen. Select the target IKS, not VMware vCenter server.

And then select your cluster and namespace, which are created previously.

There are several values, you need to update at “Set the deployment values” as below. It’s just example, you can change it with yours.

auth.username : admin
auth.password : admxx
auth.rootPassword : passxx
auth.database : sample

When all configurations are setup and then Click “Install” button at right-bottom of the screen. You can check the installation progress and logs from the “Schematics” workspace for MongoDB.

How to Access MongoDB for manipulating

Option 1) Web terminal

I explained it previously for creating namespace. When you log in to Web terminal, you have to go in to the container, MongoDB

$ kubectl get pods -n mongodb
mongodb4b-0bf5–4c-96c489bd9–4zt7c 1/1 Running 0 13h
$ kubectl -n mongodb exec -it mongodb4b-0bf5–4c-96c489bd9–4zt7c bash
mongodb4b-0bf5–4c-96c489bd9:/$ echo "you are in container shell"

Option 2) Kubernetes portal

Playing with MongoDB inside container

  1. check the parameters, which are defined when you install the MongoDB
$ env | grep MONGO

2. running MongoDB cli

$ mongo admin -u root -p passxx
$ mongo sampledb -u admin -p admin

3. sample SQL command

> show dbs 
> use admin
> show tables
> db.mytable.insertOne({ item: "canvas", qty: 100, tags: ["cotton"], size: { h: 28, w: 35.5, uom: "cm" } })
> db.mytable.find()
> db.mytable.count()
> use admin
> db.system.users.find({"user":"admin"})
> use mytable
> db.createUser(
{user: "user02",
pwd: passwordPrompt(), // or cleartext password
roles: [
{ role: "read", db: "admin" },
{ role: "readWrite", db: "sampledb" }

PART 2. OpenShift

At IKS case, we install it from the catalog of IBM Cloud, but for OpenShift we need can use 2 options, OperatorHub and Template from OpenShift web portal. Two options support different docker images of MongoDB. In my test, I choose the Template, which is easier than OperatorHub’s. Because it requires more prerequisite.

  1. OperatorHub

2. Template

Developer Catalog at above screen capture is Template catalog support as below.

There are several values, you need to update at “Set the deployment values” as below. It’s just example, you can change it with yours.

MongoDB connection username : admin
MongoDB connection password : admxx
MongoDB database name : sampledb
MongoDB admin password : passxx

Playing with MongoDB inside container

After install the Template, You need to check the POD and go into the terminal to manipulate MongoDB data.

Database operation is same with IKS case above, but different one is root user id, which is admin.

sh-4.2$ env | grep MONGODB      
sh-4.2$ mongo admin -u admin -p passxx
sh-4.2$ mongo sampledb -u admin -p admin

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store