big-c-note / mongodb-operator

Operator charm for MongoDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MongoDB Operator

Description

The MongoDB operator provides a general purpose distributed document database. This repository contains a Juju Charm for deploying MongoDB on Kubernetes clusters.

Setup

A typical setup using snaps, for deployments to a microk8s cluster can be done using the following commands

sudo snap install microk8s --classic
microk8s.enable dns storage registry dashboard
sudo snap install juju --classic
juju bootstrap microk8s microk8s
juju create-storage-pool operator-storage kubernetes storage-class=microk8s-hostpath

Build

Install the charmcraft tool

sudo snap install charmcraft

Build the charm in this git repository

charmcraft build

Usage

Create a Juju model for your operators, say "lma"

juju add-model lma

Deploy a single unit of MongoDB using its default configuration

juju deploy ./mongodb.charm --resource mongodb-image=mongo:4.4.1

It is customary to use MongoDB with replication. Hence usually more than one unit (preferably and odd number) is deployed. Additionally units (say two more) may be deployed using

juju add-unit -n 2 mongodb

Alternatively multiple MongoDB units may be deployed at the outset. This is usually faster

juju deploy -n 3 ./mongodb.charm

If required, remove the deployed monitoring model completely

juju destroy-model -y lma --no-wait --force --destroy-storage

Note the --destroy-storage will delete any data stored by MongoDB in its persistent store.

Relations

Currently supported relations are

  • Peer relations for replication
  • Provides a mongodb database interface.

Developing

Use your existing Python 3 development environment or create and activate a Python 3 virtualenv

virtualenv -p python3 venv
source venv/bin/activate

Install the development requirements

pip install -r requirements-dev.txt

Testing

Just run run_tests:

./run_tests

About

Operator charm for MongoDB

License:GNU General Public License v3.0


Languages

Language:Python 99.3%Language:Shell 0.7%