Version: v0.0.1-alpha
- Andaime
Andaime is a command-line tool designed to streamline the management of AWS resources for the Bacalhau deployment. Utilizing the power of the Cobra library, Andaime provides intuitive commands to create, destroy, and list AWS infrastructure components essential for deploying and maintaining Bacalhau nodes across multiple AWS regions.
- Create AWS Resources: Automate the provisioning of VPCs, Subnets, Security Groups, and EC2 Instances tailored for Bacalhau deployment.
- Destroy AWS Resources: Cleanly tear down all AWS resources associated with the Bacalhau project, ensuring no residual infrastructure remains.
- List AWS Resources: Generate comprehensive reports of all AWS resources tagged under the Bacalhau project across all regions.
- Versioning: Easily check the current version of Andaime.
- Flexible Configuration: Configure Andaime using environment variables, configuration files, or command-line flags.
- Verbose Mode: Enable detailed logging for troubleshooting and monitoring purposes.
Before getting started with Andaime, ensure you have the following prerequisites installed and configured:
-
Go Programming Language: Andaime is built using Go. Install Go from here.
-
AWS Account: You need an AWS account with appropriate permissions to create and manage resources.
-
AWS CLI: Install and configure the AWS CLI to manage your AWS credentials and settings.
- Installation: AWS CLI Installation Guide
- Configuration: Run
aws configure
and provide your AWS Access Key, Secret Key, Default Region, and Output Format.
-
Git: To clone the repository.
- Installation: Git Downloads
Follow these steps to install and set up Andaime:
-
Clone the Repository:
git clone https://github.com/yourusername/andaime.git cd andaime
-
Build the Tool:
Ensure you have Go installed and set up in your
PATH
.go build -o andaime
This command compiles the Andaime tool and generates an executable named
andaime
in the current directory. -
(Optional) Install Dependencies:
The project uses Go modules to manage dependencies. Ensure all dependencies are fetched:
go mod download
Andaime can be configured using Environment Variables, a Configuration File, or Command-Line Flags. The precedence of configuration is as follows:
- Command-Line Flags override
- Environment Variables, which in turn override
- Configuration File settings.
Set the following environment variables to configure Andaime:
PROJECT_NAME
: Name of your project. (Default: "bacalhau-by-andaime")TARGET_PLATFORM
: Target platform for deployment. (Default: "aws")NUMBER_OF_ORCHESTRATOR_NODES
: Number of orchestrator nodes. (Default: 1)NUMBER_OF_COMPUTE_NODES
: Number of compute nodes. (Default: 2)
Example:
export PROJECT_NAME="my-bacalhau-project"
export TARGET_PLATFORM="aws"
export NUMBER_OF_ORCHESTRATOR_NODES=2
export NUMBER_OF_COMPUTE_NODES=4
Andaime looks for a config.json
file in the current directory. This file can specify the same settings as environment variables.
Sample config.json
:
{
"PROJECT_NAME": "my-bacalhau-project",
"TARGET_PLATFORM": "aws",
"NUMBER_OF_ORCHESTRATOR_NODES": 2,
"NUMBER_OF_COMPUTE_NODES": 4
}
Notes:
- If
config.json
does not exist, Andaime will skip reading it. - Ensure the JSON structure matches the expected keys.
You can override configuration settings using command-line flags when running Andaime commands.
Available Flags:
--project-name
: Set project name.--target-platform
: Set target platform.--orchestrator-nodes
: Set number of orchestrator nodes.--compute-nodes
: Set number of compute nodes.--target-regions
: Comma-separated list of target AWS regions. (Default: "us-east-1")--orchestrator-ip
: IP address of an existing orchestrator node.--aws-profile
: AWS profile to use for credentials.--instance-type
: Instance type for both compute and orchestrator nodes. (Default: "t2.medium")--compute-instance-type
: Instance type for compute nodes. Overrides--instance-type
for compute nodes.--orchestrator-instance-type
: Instance type for orchestrator nodes. Overrides--instance-type
for orchestrator nodes.--volume-size
: Volume size of each node created in Gigabytes. (Default: 8)--verbose
: Enable verbose output.
Example:
./andaime aws create --project-name "my-project" --orchestrator-nodes 2 --compute-nodes 4 --verbose
Andaime provides several commands to manage AWS resources for your Bacalhau deployment. Below are the primary commands and their descriptions.
Description:
Create AWS resources required for the Bacalhau deployment. This includes VPCs, Subnets, Security Groups, and EC2 Instances.
Usage:
./andaime aws create [flags]
Flags:
--project-name
: Set project name.--target-platform
: Set target platform.--orchestrator-nodes
: Set number of orchestrator nodes.--compute-nodes
: Set number of compute nodes.--target-regions
: Comma-separated list of target AWS regions.--orchestrator-ip
: IP address of an existing orchestrator node.--aws-profile
: AWS profile to use for credentials.--instance-type
: Instance type for both compute and orchestrator nodes.--compute-instance-type
: Instance type for compute nodes.--orchestrator-instance-type
: Instance type for orchestrator nodes.--volume-size
: Volume size of each node created (GB).--verbose
: Enable verbose output.
Example:
./andaime aws create --project-name "my-project" --orchestrator-nodes 2 --compute-nodes 4 --target-regions "us-east-1,us-west-2" --verbose
Description:
Destroy all AWS resources associated with the Bacalhau deployment. This will remove VPCs, Subnets, Security Groups, and EC2 Instances tagged with project: andaime
.
Usage:
./andaime aws destroy [flags]
Flags:
Same as the create
command, excluding some specific to creation.
Example:
./andaime aws destroy --verbose
Description:
List all AWS resources tagged with project: andaime
across all regions. Generates a comprehensive report of VPCs, Subnets, Security Groups, Internet Gateways, Route Tables, and Instances.
Usage:
./andaime aws list [flags]
Flags:
Same as the create
command.
Example:
./andaime aws list --verbose
Description:
Print the current version of Andaime.
Usage:
./andaime aws version
Example:
./andaime aws version
# Output: v0.0.1-alpha
Deploy a Bacalhau project with 2 orchestrator nodes and 4 compute nodes across us-east-1
and us-west-2
regions with verbose output:
./andaime aws create \
--project-name "my-bacalhau-project" \
--orchestrator-nodes 2 \
--compute-nodes 4 \
--target-regions "us-east-1,us-west-2" \
--verbose
Remove all resources associated with the Bacalhau project with verbose output:
./andaime aws destroy --verbose
Generate a report of all resources tagged with project: andaime
:
./andaime aws list --verbose
Display the current version of Andaime:
./andaime aws version
# Output: v0.0.1-alpha
Here's an overview of the main components of the Andaime project:
andaime/
├── cmd/
│ └── aws.go # Core CLI commands and functionality
├── startup_scripts/ # Embedded startup scripts for EC2 instances
├── config.json # Optional configuration file
├── go.mod # Go module file
├── go.sum # Go checksum file
├── README.md # Project documentation
└── ...
cmd/aws.go
: Contains the implementation of the CLI commands (create
,destroy
,list
,version
) using the Cobra library.startup_scripts/
: Directory containing scripts that are executed upon EC2 instance initialization. These scripts are embedded into the binary using Go'sembed
package.config.json
: Optional JSON file for configuring Andaime settings. Overrides default settings but can be overridden by environment variables and flags.go.mod
&go.sum
: Manage Go dependencies.
Contributions are welcome! To contribute to Andaime, follow these steps:
-
Fork the Repository:
Click the "Fork" button at the top right of the repository page to create your own fork.
-
Clone Your Fork:
USERNAME=yourusername git clone https://github.com/$USERNAME/andaime.git cd andaime
-
Create a New Branch:
git checkout -b feature/$USERNAME-your-feature-name
-
Make Your Changes:
Implement your feature or fix the bug.
-
Commit Your Changes:
git commit -m "Add feature: your feature description"
-
Push to Your Fork:
git push origin feature/$USERNAME-your-feature-name
-
Open a Pull Request:
Navigate to the original repository and click on "Compare & pull request" to submit your changes for review.
Please ensure your contributions adhere to the project's coding standards and include appropriate documentation and tests.
This project is licensed under the MIT License.