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.0.tar.gz (12.2 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.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mkswarm-0.1.0.tar.gz
  • Upload date:
  • Size: 12.2 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.0.tar.gz
Algorithm Hash digest
SHA256 744fd00c64ec968b49001cc070759d831e264e567ff36dfd78d3bcb7c49a4f7b
MD5 a518d1edaf786f063d1fc0b9b5f97711
BLAKE2b-256 e1ca31881f6bf1190ec08813391a9974f32d66bcae9b1fcb14a9f1e1338d4445

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkswarm-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: mkswarm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0a15143fd54427b6d01fc742888544f6eb06b8851844b7fd4feba28fb26d70b
MD5 641837520d6ad9e0bbfc166bc9a938ca
BLAKE2b-256 baa32accb4a0bc7f508eec07daf0d389aa28e20125423ef70ac5915cddbc20ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for mkswarm-0.1.0-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