CLI tool for bootstrapping and managing Docker Swarm clusters
Project description
mkswarm
CLI tool for bootstrapping and managing Docker Swarm clusters.
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 swarmrun- Join pending nodes via Docker SDKstatus- Show swarm statelist- List all swarmsreemit- Regenerate join script from DBdestroy- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
744fd00c64ec968b49001cc070759d831e264e567ff36dfd78d3bcb7c49a4f7b
|
|
| MD5 |
a518d1edaf786f063d1fc0b9b5f97711
|
|
| BLAKE2b-256 |
e1ca31881f6bf1190ec08813391a9974f32d66bcae9b1fcb14a9f1e1338d4445
|
Provenance
The following attestation bundles were made for mkswarm-0.1.0.tar.gz:
Publisher:
pypi-publish.yml on daedalus/mkswarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkswarm-0.1.0.tar.gz -
Subject digest:
744fd00c64ec968b49001cc070759d831e264e567ff36dfd78d3bcb7c49a4f7b - Sigstore transparency entry: 1277037259
- Sigstore integration time:
-
Permalink:
daedalus/mkswarm@c419c17cdfc16d800c54ca2eb8d9ab357b28956c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@c419c17cdfc16d800c54ca2eb8d9ab357b28956c -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0a15143fd54427b6d01fc742888544f6eb06b8851844b7fd4feba28fb26d70b
|
|
| MD5 |
641837520d6ad9e0bbfc166bc9a938ca
|
|
| BLAKE2b-256 |
baa32accb4a0bc7f508eec07daf0d389aa28e20125423ef70ac5915cddbc20ea
|
Provenance
The following attestation bundles were made for mkswarm-0.1.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on daedalus/mkswarm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mkswarm-0.1.0-py3-none-any.whl -
Subject digest:
a0a15143fd54427b6d01fc742888544f6eb06b8851844b7fd4feba28fb26d70b - Sigstore transparency entry: 1277037280
- Sigstore integration time:
-
Permalink:
daedalus/mkswarm@c419c17cdfc16d800c54ca2eb8d9ab357b28956c -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/daedalus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@c419c17cdfc16d800c54ca2eb8d9ab357b28956c -
Trigger Event:
release
-
Statement type: