Docker Swarm

Automated provisioning and configuration of Docker Swarm clusters.

Commands: swarm config, swarm attach-worker

This feature introduces automated provisioning and configuration of Docker Swarm clusters, including both manager and worker nodes. The setup involves creating EC2 instances, initializing Docker Swarm, and joining worker nodes to the cluster.

Key Highlights:

  1. Swarm Configuration Command
    • Command: dob swarm config
    • Functionality:
      • Reads a YAML configuration file specifying manager and worker nodes.
      • Automatically provisions EC2 instances for the Swarm cluster.
      • Initializes the manager node and retrieves the join token.
      • Joins worker nodes to the cluster using the manager's token.
      • Saves the join token locally for future use.
    • Error Handling:
      • Handles missing or invalid configuration files.
      • Provides detailed error messages if EC2 provisioning or Docker Swarm initialization fails.
  2. Attach New Worker Nodes
    • Command: dob swarm attach-worker
    • Functionality:
      • Allows attaching additional worker nodes to an existing Swarm cluster.
      • Fetches the manager IP from the hosts file.
      • Joins the new worker nodes using the existing manager's join token.
    • Error Handling:
      • Ensures that the manager node is properly detected before attempting to attach workers.
      • Provides clear feedback in case of failures during the join process.
  3. Swarm Task Execution
    • Functionality:
      • Defines default tasks for both manager and worker nodes.
      • Executes tasks with retry logic to handle transient errors.
      • Supports custom tasks by modifying the task definitions.

Example YAML Configuration:


manager:
  name: swarm-manager
  instance_type: t2.medium
  key_name: my-ssh-key
  security_group: my-security-group
workers:
  name: swarm-worker
  instance_type: t2.small
  key_name: my-ssh-key
  security_group: my-security-group
  count: 3
      

Example Usage:


dob swarm config --file-path /path/to/config.yaml
dob swarm attach-worker --file-path /path/to/new-workers-config.yaml