Charmed Operator for MongoDB

Channel Revision Published Runs on
6/stable 61 15 Nov 2024
Ubuntu 22.04
6/candidate 61 15 Nov 2024
Ubuntu 22.04
6/beta 61 15 Nov 2024
Ubuntu 22.04
6/edge 61 15 Nov 2024
Ubuntu 22.04
5/edge 39 14 Dec 2023
Ubuntu 22.04
juju deploy mongodb-k8s --channel 6/stable
Show information

Platform:

Charmed MongoDB K8s Tutorials > 1. Set up the environment

Set up the environment

Charmed MongoDB K8s is operated via Juju, a charm orchestration engine that makes them easy to operate. For this tutorial, we will set up the tools needed to deploy and use Charmed MongoDB K8s.

Summary


Minimum requirements

Before we start, make sure your machine meets the following requirements:

  • Ubuntu 22.04 (Jammy)
  • 8GB of RAM
  • 2 CPU threads
  • At least 20GB of available storage
  • Access to the internet for downloading the required snaps and charms

Set up MicroK8s

MicroK8s is a lightweight Kubernetes for automating deployment, scaling, and management of containerised applications. Charmed MongoDB K8s will be run in Kubernetes pods and managed by Juju.

Install

Because we will use juju 3.x which is a strictly confined snap, we also need to install strict MicroK8s:

sudo snap install microk8s --channel=1.27-strict

Configure

Add your user to the microk8s group:

sudo usermod -a -G snap_microk8s $(whoami)

Create a ~/.kube folder and set permissions:

mkdir ~/.kube
sudo chown -R $(whoami) ~/.kube

Reload the user groups either via a reboot or by running the following command:

newgrp snap_microk8s

Check the status of Kubernetes:

microk8s status --wait-ready

Enable some required plugins:

sudo microk8s enable dns storage ingress

Create an alias for microk8s.kubectl:

sudo snap alias microk8s.kubectl kubectl

This alias is optional but recommended for this tutorial, since future kubectl commands will use this alias.

Set up juju

Juju is an Operator Lifecycle Manager (OLM) for clouds, bare metal, LXD or Kubernetes. We will be using it to deploy and manage Charmed MongoDB K8s.

Install

As with MicroK8s, Juju is installed from a snap package:

sudo snap install juju --classic --channel=3.1

Juju already has a built-in knowledge of Kubernetes and how it works, so there is no additional setup or configuration needed. A controller will be used to deploy and control Charmed MongoDB K8s.

Configure

Because Juju v3.x is a strictly confined snap, it is not allowed to create ~/.local/share automatically. We must create it manually:

mkdir -p $HOME/.local/share/juju

Bootstrap a juju controller

A Juju controller will be used to deploy and control Charmed MongoDB K8s. All we need to do is run the following command to bootstrap a controller named ‘overlord’ to MicroK8s. This bootstrapping processes can take several minutes depending on how provisioned (RAM, CPU, etc.) your machine is:

juju bootstrap microk8s overlord 

The Juju controller should exist within a Kubernetes namespace. Verify this by displaying the namespaces and pods via kubectl.

To see the namespaces, run

kubectl get namespaces

Output:

NAME                  STATUS   AGE
kube-system           Active   <age>
kube-public           Active   <age>
kube-node-lease       Active   <age>
default               Active   <age>
ingress               Active   <age>
controller-overlord   Active   <age>

To see the pods in our controller, run

kubectl get pods --namespace=controller-overlord

Output:

NAME                             READY   STATUS    RESTARTS      AGE
controller-0                     2/2     Running   1 (<restarted> ago)   <age>
modeloperator-6c58d95cfb-ktts7   1/1     Running   0             <age>

<age> shows how long ago a namespace was created and <restarted> shows when the pod was last restarted.

Add a model

The controller can work with different juju models. Models host charmed applications such as Charmed MongoDB K8s.

Set up a specific model for our MongoDB K8s deployment named ‘tutorial’:

juju add-model tutorial

You can now view the model you created above by entering the command juju status into the command line. You should see the following:

Model     Controller  Cloud/Region        Version  SLA          Timestamp
tutorial  overlord    microk8s/localhost  3.1.5   unsupported  11:35:46Z

Model "admin/tutorial" is empty.

Next step: 2. Deploy MongoDB


Help improve this document in the forum (guidelines). Last updated 2 months ago.