Skip to main content

A CLI for managing MongoDB deployments on Docker

Project description

tomodo logo

Latest Release Unit Tests codecov Python Version License

tomodo

tomodo is a Toolbox for MongoDB on Docker.


Use it to create and manage Docker-based MongoDB community deployments - standalone instances, replica sets, sharded clusters, and local Atlas deployments.


Installation

Install with Homebrew

Homebrew is a popular package manager for macOS. You can install tomodo by running the following commands:

brew tap yuvalherziger/homebrew-tomodo
brew install tomodo

After installing the tool with brew, you can run it the following way:

tomodo --help

Install with pip

To install with pip, run the following command:

pip install tomodo

Install from Source

If you wish to set up a development environment, or if you simply can't use Homebrew or aren't a macOS user, you can install tomodo using Python. The recommended way to perform the Python installation is by using the Poetry Python package manager.

Requirements:

  • Python 3.8 or higher

Install with Poetry Package Manager for Python

If you have the Poetry Python package manager installed locally, you can install the CLI the following way:

git clone https://github.com/yuvalherziger/tomodo.git
cd tomodo
poetry shell
poetry install

After installing the tool with Poetry, you can run it the following way:

tomodo --help

Install from source with pip

You can install the dependencies with pip using the following command:

git clone https://github.com/yuvalherziger/tomodo.git
cd tomodo
pip install .

After installing the dependencies with pip, you can validate the installation by invoking the help page:

python tomodo/cmd.py --help

CLI Usage

Before you begin, make sure you have a Docker daemon running. The most popular platform is Docker Desktop.

Create a Deployment

Create a deployment with the provision command. For example, here's how you create a standalone instance with zero configuration:

tomodo provision standalone

To create a replica set with zero configuration, run the following command:

tomodo provision replica-set

To create a sharded cluster with zero configuration, run the following command:

tomodo provision sharded

To create a local Atlas deployment (a single-node replica set) with zero configuration, run the following command:

tomodo provision atlas

Take a look at each provision command's help page to read the full set of options with tomodo provision --help.

 Usage: tomodo provision [OPTIONS] COMMAND [ARGS]...

 Provision a MongoDB deployment

╭─ Options ──────────────────────────────────────────────────────────────╮
│ --help          Show this message and exit.                            │
╰────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────╮
│ atlas            Provision a local MongoDB Atlas deployment            │
│ replica-set      Provision a MongoDB replica set deployment            │
│ sharded          Provision a MongoDB sharded cluster                   │
│ standalone       Provision a standalone MongoDB deployment             │
╰────────────────────────────────────────────────────────────────────────╯

Describe Deployments

Use the describe command to print the details of one or all deployments:

# Describe all deployments
tomodo describe

# Describe a deployment by name
tomodo describe --name yawning-mole

# Describe only running deployments
tomodo describe --exclude-stopped

List Deployments

Use the list command to list your deployments:

# List all deployments
tomodo list

# List only running deployments
tomodo list --exclude-stopped

Stop Deployments

Use the stop command to stop your deployments:

# Stop all deployments
tomodo stop

# Stop a deployment by name
tomodo stop --name troubled-narwhal

# Stop all deployments without prompting for confirmation
tomodo stop --auto-approve

Start Deployments

Use the start command to start a deployment you previously stopped:

tomodo start --name printed-lemming

Remove Deployments

Use the remove command to permanently remove deployments:

# Remove all deployments
tomodo remove

# Remove a deployment by name
tomodo remove --name troubled-narwhal

# Remove all deployments without prompting for confirmation
tomodo remove --auto-approve

List Tags

Use the tags list command to list the available image tags on Docker Hub.

tomodo tags list --version 7

Sample output:

7.0.6
7.0.6-jammy
7.0.6-nanoserver
7.0.6-nanoserver-1809
7.0.6-nanoserver-ltsc2022
7.0.6-windowsservercore
7.0.6-windowsservercore-1809
7.0.6-windowsservercore-ltsc2022
7.0.5
7.0.5-jammy
7.0.5-nanoserver
7.0.5-nanoserver-1809
7.0.5-nanoserver-ltsc2022
7.0.5-windowsservercore
7.0.5-windowsservercore-1809
7.0.5-windowsservercore-ltsc2022
7.0.4
7.0.4-jammy
7.0.4-nanoserver
7.0.4-nanoserver-1809
7.0.4-nanoserver-ltsc2022
7.0.4-windowsservercore
7.0.4-windowsservercore-1809
7.0.4-windowsservercore-ltsc2022
7.0.3
7.0.3-jammy
7.0.3-nanoserver
7.0.3-nanoserver-1809
7.0.3-nanoserver-ltsc2022
7.0.3-windowsservercore
7.0.3-windowsservercore-1809
7.0.3-windowsservercore-ltsc2022
7.0.2
7.0.2-jammy
7.0.2-nanoserver
7.0.2-nanoserver-1809
7.0.2-nanoserver-ltsc2022
7.0.2-windowsservercore
7.0.2-windowsservercore-1809
7.0.2-windowsservercore-ltsc2022

Programmatic Usage

You can install tomodo in your Python (>=3.8) projects using pip or any other Python package manager, and use it programmatically (you'll still need a Docker daemon running).

from typing import Dict

from tomodo import functional as tfunc
from tomodo.common.errors import DeploymentNotFound
from tomodo.common.models import AtlasDeployment, Deployment, Mongod, ReplicaSet, ShardedCluster

# Create a standalone instance:
mongod: Mongod = tfunc.provision_standalone_instance(port=1000)

# Create an Atlas instance:
atlas_depl: AtlasDeployment = tfunc.provision_atlas_instance(port=2000)

# Create a replica set:
replica_set: ReplicaSet = tfunc.provision_replica_set(port=3000, replicas=3)

# Create a sharded cluster:
sh_cluster: ShardedCluster = tfunc.provision_sharded_cluster(port=4000, shards=2, config_servers=3, mongos=2)

# Stop a deployment:
mongod.stop()

# Start a stopped deployment:
mongod.start()

# Remove a deployment permanently:
mongod.remove()

# Find a deployment by name
try:
    deployment = tfunc.get_deployment(name="elegant-leopard", include_stopped=True)
except DeploymentNotFound:
    print("Deployment not found")

# List all deployments:
deployments: Dict = tfunc.list_deployments(include_stopped=True)
for name in deployments.keys():
    deployment: Deployment = deployments[name]
    print(f"Deployment {name} is {deployment.last_known_state}")

Disclaimer

This software is not supported by MongoDB, Inc. under any of their commercial support subscriptions or otherwise. Any usage of tomodo is at your own risk. Bug reports, feature requests, and questions can be posted in the Issues section of this repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomodo-1.4.3.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tomodo-1.4.3-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

Details for the file tomodo-1.4.3.tar.gz.

File metadata

  • Download URL: tomodo-1.4.3.tar.gz
  • Upload date:
  • Size: 29.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/6.11.0-1018-azure

File hashes

Hashes for tomodo-1.4.3.tar.gz
Algorithm Hash digest
SHA256 4412b4b52942b1b2c6367227f105a1465c2eb0ec65b4e4658eba23b689fc9b7e
MD5 42704516f393accb7b903b22307b9300
BLAKE2b-256 6e9110a8c60112ec3af0e5773475ecc3fbcde8babcc57880cccd3d513e643efb

See more details on using hashes here.

File details

Details for the file tomodo-1.4.3-py3-none-any.whl.

File metadata

  • Download URL: tomodo-1.4.3-py3-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/6.11.0-1018-azure

File hashes

Hashes for tomodo-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b05c578a4750e9e6f56dff636349adcef1a660f08ab630b7c1a62f826abfa514
MD5 ad72e4ffc2c64557f3dd299afb58df4b
BLAKE2b-256 41c1655d6348562ca0e5669d1b4363caf6dee8b9ba15cc98ecbc8d8915781100

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page