Skip to main content

CLI tool for bootstrapping and managing Docker Swarm clusters

Project description

mkswarm

CLI tool for bootstrapping and managing Docker Swarm clusters.

PyPI Python Ruff

Install

pip install mkswarm

Usage

# Initialize a new Docker Swarm
mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh

# Run pending node joins via Docker SDK
mkswarm run 1

# Show swarm state
mkswarm status 1

# List all swarms
mkswarm list

# Regenerate join script from database
mkswarm reemit 1 -o new_join.sh

# Force-leave all nodes and destroy swarm
mkswarm destroy 1

IP File Format

Create a text file with one IPv4 address per line:

# Manager node
192.168.1.1

# Worker nodes
192.168.1.2
192.168.1.3
192.168.1.4

Token Encryption

Encrypt tokens at rest using Fernet:

# Generate a key
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

# Use with mkswarm
export MKSWARM_KEY="your-generated-key"
mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh -k "$MKSWARM_KEY"

Proxy Support

Use SOCKS4, SOCKS5, or HTTP proxy:

mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh -p socks5://proxy:1080

TLS Support

Configure mutual TLS for Docker TCP connections:

mkswarm init -i ips.txt -m 192.168.1.1 -r 0.2 -o join.sh \
  --tls-cert client-cert.pem \
  --tls-key client-key.pem \
  --tls-ca ca.pem

CLI Options

Global Options

  • --db FILE - SQLite database path (default: swarm.db)
  • --verbose - Enable debug logging
  • --quiet - Suppress warnings
  • --log-file FILE - Append logs to file
  • --dry-run - Preview actions without contacting Docker or writing files

Subcommands

  • init - Bootstrap a new swarm
  • run - Join pending nodes via Docker SDK
  • status - Show swarm state
  • list - List all swarms
  • reemit - Regenerate join script from DB
  • destroy - Force-leave all nodes

API

from mkswarm import SwarmDB, encrypt_token, decrypt_token, load_ips

# Database operations
db = SwarmDB("swarm.db")
swarm_id = db.create_swarm("192.168.1.1", "worker_token", "manager_token", 0.2, "192.168.1.1:2377", "join.sh")
swarm = db.get_swarm(swarm_id)
db.close()

# Token encryption
key = generate_key()  # Generate new key
encrypted = encrypt_token(token, key)
decrypted = decrypt_token(encrypted, key)

# IP validation
ip = parse_ipv4("192.168.1.1")
ips = load_ips("ips.txt")

Development

git clone https://github.com/daedalus/mkswarm.git
cd mkswarm
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/

License

MIT License - see LICENSE file for details.

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

mkswarm-0.1.1.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

mkswarm-0.1.1-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file mkswarm-0.1.1.tar.gz.

File metadata

  • Download URL: mkswarm-0.1.1.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mkswarm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 331ffd414ff3d2c1cae0cacfab432f735714f9a4f1da9a2419cb4c5a2f08d8c7
MD5 c7d78e3c6a042e7723eaba65bd72627a
BLAKE2b-256 2c54aab2dabe00f98339f022ea0d5096762b55669cad6f6f4fa44b7605d53939

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkswarm-0.1.1.tar.gz:

Publisher: pypi-publish.yml on daedalus/mkswarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mkswarm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mkswarm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mkswarm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7ea86b46e1aa5d6442f67a5145870cd2442fb814e727626c383a1ac4a844483
MD5 af113854f02c73851575a456c1aca5b2
BLAKE2b-256 d1dd5a37c807346f75542348d7dbc2dbd7c0979c5521d5e54eda9735ce9336a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkswarm-0.1.1-py3-none-any.whl:

Publisher: pypi-publish.yml on daedalus/mkswarm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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