Files
bare-metal-kubernetes-provi…/cli/README.md
T
2025-03-02 21:32:16 +00:00

3.1 KiB

Infrastructure CLI Tool

A user-friendly CLI tool for provisioning and managing infrastructure components, with a focus on Kubernetes clusters.

Installation

Important

: This tool has only been tested on Ubuntu 24.04 and WSL Ubuntu 24.04. There is no guarantee it will work on other operating systems.

Quick Install (Ubuntu)

./install.sh

# Make sure ~/.local/bin is in your PATH
export PATH="$PATH:$HOME/.local/bin"

This installs the CLI tool to ~/.local/bin. You may need to add this directory to your PATH if it's not already there. To make this change permanent, add the export line to your ~/.bashrc or ~/.profile.

Manual Install

Find the appropriate binary for your platform in the bin directory:

# Create ~/.local/bin directory if it doesn't exist
mkdir -p ~/.local/bin

# Example for Linux/AMD64
cp bin/linux_amd64/provision ~/.local/bin/
chmod +x ~/.local/bin/provision

# Add to PATH if needed
export PATH="$PATH:$HOME/.local/bin"

Available binaries:

  • Linux: bin/linux_amd64/provision or bin/linux_arm64/provision
  • macOS: bin/darwin_amd64/provision or bin/darwin_arm64/provision
  • Windows: bin/windows_amd64/provision.exe

Usage

Run the command to start the interactive CLI:

provision

The tool will guide you through:

  1. Choosing an operation (provision or cleanup)
  2. Selecting what to provision/cleanup (Kubernetes or PostgreSQL)
  3. Configuring settings or using defaults
  4. Confirming and executing the operation

Example: Provision Kubernetes

$ provision

? What would you like to do? provision
? What would you like to provision? Kubernetes Cluster

Current default settings:
Kubernetes Version: 1.32
Pod CIDR: 192.168.0.0/16
Service CIDR: 10.96.0.0/16
CNI Plugin: calico
Control Plane: 4 CPUs, 8G Memory, 40G Disk
Worker Nodes: 4 CPUs, 8G Memory, 40G Disk

? Do you want to use these default settings? Yes
? Do you want to proceed? Yes

Running provisioning script...

Example: Clean Up

$ provision

? What would you like to do? cleanup
? What would you like to clean up? Kubernetes Cluster
? Are you sure you want to clean up Kubernetes Cluster? Yes

Starting Kubernetes cluster cleanup...
Cleanup completed successfully

Requirements

  • Host OS: Ubuntu 24.04 or WSL Ubuntu 24.04 (tool has only been tested on these platforms)
  • Ansible (for provisioning operations)
  • Multipass (for VM creation)
  • SSH client tools

Development

Project Structure

  • cmd/provision/ - Main CLI code
    • cmd/ - Command definitions using Cobra
    • kubernetes/ - Kubernetes-specific functionality
    • interactive/ - User interaction utilities
    • ansible/ - Ansible wrapper functions
    • config/ - Configuration management

Building the CLI

To modify or extend the CLI tool:

  1. Make changes to the Go code
  2. Build binaries for all platforms:
    ./scripts/build-release.sh
    

Adding New Commands

  1. Create a new command file in cmd/provision/cmd/
  2. Register the command in cmd/provision/cmd/root.go
  3. Implement the command functionality

Testing

Run the tests with:

cd cli
go test ./...