β οΈ DEPRECATED: This project has evolved into platform-iacCPC has been superseded by platform-iac - a more modular, enterprise-ready Infrastructure as Code solution. All active development has moved to the new repository.
Key improvements in platform-iac:
- 35+ modular Ansible roles vs monolithic single role in CPC
- Molecule testing framework for Ansible roles
- Native OpenTofu tests (tftest.hcl)
- iac-wrapper.sh - unified CLI for all operations
- Cleaner architecture with separated concerns
- Full English documentation and comments
β‘οΈ Please use platform-iac for new deployments
Complete Kubernetes cluster deployment and management system using Proxmox VE, Terraform/OpenTofu, and Ansible automation.
- π Security & Secrets
- π― Overview
- β¨ Key Features
- π Quick Start
- π Documentation
- π οΈ Installation & Setup
- π» Usage Examples
- ποΈ Architecture
- π§ Configuration
- π Workspace System
- π§ͺ Testing & Validation
- π€ Contributing
- π License
- DO NOT commit files containing real secrets to version control
- Use
secrets.sops.yaml(encrypted with SOPS) for sensitive data - Temporary files like
secrets_temp.yamlare automatically ignored - Always run
gitleaks detectbefore pushing to check for exposed secrets
- Use SOPS for encrypting secrets
- Store encrypted secrets in
secrets.sops.yaml - Decrypt only when needed:
sops decrypt secrets.sops.yaml - Never store decrypted secrets in the repository
- Run
gitleaks detectregularly to scan for exposed secrets - Use
.gitignoreto prevent accidental commits of sensitive files - Rotate compromised credentials immediately
CPC (Cluster Provisioning Control) is a comprehensive, production-ready solution for deploying and managing Kubernetes clusters on Proxmox Virtual Environment. Built with infrastructure as code principles, it provides:
- π Complete Lifecycle Management: From VM template creation to cluster operations
- ποΈ Infrastructure as Code: Terraform/OpenTofu-based provisioning
- βοΈ Configuration Management: Ansible-powered cluster configuration
- π Multi-Distribution Support: Ubuntu, Debian, Rocky Linux, SUSE
- π¦ Rich Addon Ecosystem: Calico CNI, MetalLB, cert-manager, ArgoCD, and more
- π Security-First: Production-ready configurations with best practices
- π Home Lab Clusters: Perfect for personal Kubernetes experimentation
- π’ Development Environments: Isolated development and testing clusters
- π Production Deployments: Enterprise-grade cluster management
- π Learning Platform: Educational Kubernetes deployments
- β Automated VM Template Creation - Optimized templates for multiple OS distributions
- β Dynamic IP Management - Smart IP allocation with conflict prevention
- β Multi-Workspace Support - Isolated environments for different projects
- β Cloud-Init Integration - Automated VM provisioning and configuration
- β High-Availability Clusters - Production-ready control plane setup
- β Automated Bootstrap - One-command cluster deployment
- β Node Scaling - Add/remove nodes dynamically
- β Certificate Management - Automated SSL certificate handling
- β Calico CNI - Advanced networking with IPAM
- β MetalLB - Load balancer for bare-metal deployments
- β cert-manager - Automated certificate management
- β ArgoCD - GitOps continuous delivery
- β ingress-nginx - Kubernetes ingress controller
- β Metrics Server - Resource monitoring and metrics
- β CoreDNS - DNS service with local domain forwarding
- β Modular Architecture - Clean, maintainable codebase
- β Comprehensive CLI - Intuitive command-line interface
- β Rich Documentation - Extensive guides and troubleshooting
- β Error Handling - Robust error detection and recovery
- Proxmox VE 8.0+ server with API access
- Terraform/OpenTofu installed on management machine
- Ansible installed on management machine
- SSH key pair configured for passwordless access
# 1. Clone and configure
git clone <repository-url>
cd CreatePersonalCluster
cp cpc.env.example cpc.env
# Edit cpc.env with your Proxmox details
# 2. Initial setup
./cpc setup-cpc
# 3. Create your workspace
./cpc clone-workspace ubuntu my-cluster
./cpc ctx my-cluster
# 4. Create VM template
./cpc template
# 5. Deploy and bootstrap
./cpc deploy apply
./cpc bootstrap
# 6. Install addons
./cpc upgrade-addonsπ Your cluster is ready! Access it with:
./cpc get-kubeconfig
kubectl get nodes- π Complete Cluster Creation Guide - Step-by-step deployment
- π Complete Workflow Guide - Full workflow walkthrough
- ποΈ Architecture Overview - System design and principles
- βοΈ Project Setup Guide - Detailed setup instructions
- π CPC Commands Reference - Complete command reference
- π§ CPC Template Variables Guide - Configuration variables
- π Modular Workspace System - Workspace management
- π‘ Static IP Configuration - IP management guide
- π SSH Key Troubleshooting - SSH authentication issues
- π DNS Certificate Solution - DNS/certificates
- π Cluster Troubleshooting - Common issues
- π Project Status Report - Current development status
Management Machine:
# Required packages
sudo apt update
sudo apt install -y ansible terraform python3-pip jq curl
# Install OpenTofu (alternative to Terraform)
curl -fsSL https://get.opentofu.org/install-opentofu.sh | shProxmox Server:
- Proxmox VE 8.0 or higher
- API access enabled
- SSH access configured
- Sufficient resources (CPU, RAM, Storage)
# Clone repository
git clone <repository-url>
cd CreatePersonalCluster
# Configure environment
cp cpc.env.example cpc.env
nano cpc.env # Edit with your Proxmox details
# Initial setup
./cpc setup-cpcRequired Settings in cpc.env:
# Proxmox connection
PROXMOX_HOST="192.168.1.100"
PROXMOX_USERNAME="root@pam"
PROXMOX_PASSWORD="your-password"
# Network configuration
NETWORK_CIDR="192.168.1.0/24"
NETWORK_GATEWAY="192.168.1.1"
STATIC_IP_START="110"
# DNS settings
PRIMARY_DNS_SERVER="192.168.1.10"
SECONDARY_DNS_SERVER="8.8.8.8"# Create and switch to workspace
./cpc clone-workspace ubuntu production
./cpc ctx production
# Deploy infrastructure
./cpc deploy plan # Review changes
./cpc deploy apply # Deploy VMs
# Bootstrap Kubernetes
./cpc bootstrap
# Verify cluster
./cpc status
kubectl get nodes# Add worker node
./cpc add-vm
# Follow interactive prompts
# Remove node
./cpc remove-vm
# Select node to remove
# Check cluster health
./cpc cluster-info# Interactive addon installation
./cpc upgrade-addons
# Install specific addon
./cpc upgrade-addons --addon metallb
# Install all addons
./cpc upgrade-addons --addon allCPC supports debug mode for troubleshooting and development:
# Enable debug output for any command
./cpc --debug deploy plan
./cpc --debug ctx
./cpc --debug bootstrap
# Short form
./cpc -d deploy apply
# Debug shows:
# - Secret loading details
# - Template variable processing
# - Command execution steps
# - Detailed error informationWhen to use debug mode:
- Troubleshooting deployment issues
- Understanding command execution flow
- Development and testing
- Investigating configuration problems
Note: Debug mode displays sensitive information like secrets and credentials. Use only when necessary and avoid in production environments.
# Configure CoreDNS for local domains
./cpc configure-coredns
# Test DNS resolution
./cpc test-dns example.local
# Verify certificates
./cpc verify-certificates# List available workspaces
./cpc list-workspaces
# Create development environment
./cpc clone-workspace ubuntu dev
./cpc ctx dev
# Switch between environments
./cpc ctx production
./cpc ctx staging
./cpc ctx devβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CPC Management Layer β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Main CPC Script β β
β β β β
β β β’ Command parsing & routing β β
β β β’ Configuration management β β
β β β’ Module orchestration β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Modular Architecture Layer β
β βββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ¬ββββββββββββββ β
β β 00_core.sh β 20_ansible β 30_k8s β 40_k8s β β
β β β .sh β _cluster.sh β _nodes.sh β β
β β β’ Workspace β β’ Playbook β β’ Bootstrap β β’ Scaling β β
β β β’ Context β β’ Secrets β β’ K8s init β β’ Node mgmt β β
β β β’ Utilities β β’ Inventory β β’ Addons β β’ Health β β
β βββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ΄ββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Infrastructure Layer β
β βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β Terraform/ β Ansible β β
β β OpenTofu β Playbooks β β
β β β β β
β β β’ VM provisioning β β’ K8s installation β β
β β β’ Network config β β’ Addon deployment β β
β β β’ Resource mgmt β β’ Configuration management β β
β βββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Proxmox VE Infrastructure β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Kubernetes Cluster β β
β β β β
β β Control Plane Nodes Worker Nodes β β
β β βββββββββββ¬ββββββββββ βββββββββββ¬ββββββββββ¬ββββββββββ β
β β β CP-1 β CP-2 β β W-1 β W-2 β W-3 β β
β β β Ubuntu β Ubuntu β β Ubuntu β Ubuntu β Ubuntu β β
β β β K8s β K8s β β K8s β K8s β K8s β β
β β β v1.31 β v1.31 β β v1.31 β v1.31 β v1.31 β β
β β βββββββββββ΄ββββββββββ βββββββββββ΄ββββββββββ΄ββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- CPC Script: Main orchestration tool
- Modules: Specialized functionality (core, ansible, k8s, etc.)
- Terraform: Infrastructure provisioning
- Ansible: Configuration management
- Proxmox VE: Virtualization platform
- Kubernetes: Container orchestration
CreatePersonalCluster/
βββ cpc # Main CPC script
βββ cpc.env # Global configuration
βββ cpc.env.example # Configuration template
βββ modules/ # Core functionality modules
β βββ 00_core.sh # Workspace & context management
β βββ 20_ansible.sh # Ansible integration
β βββ 30_k8s_cluster.sh # K8s bootstrap & addons
β βββ 40_k8s_nodes.sh # Node management
β βββ 50_cluster_ops.sh # Cluster operations
β βββ 60_tofu.sh # Terraform/OpenTofu integration
β βββ 80_ssh.sh # SSH management
βββ envs/ # Workspace configurations
β βββ ubuntu.env # Ubuntu workspace
β βββ debian.env # Debian workspace
β βββ rocky.env # Rocky Linux workspace
β βββ suse.env # SUSE workspace
βββ ansible/ # Ansible automation
β βββ ansible.cfg # Ansible configuration
β βββ inventory/ # Dynamic inventory
β βββ playbooks/ # Ansible playbooks
β βββ roles/ # Ansible roles
βββ terraform/ # Infrastructure as code
β βββ main.tf # Main configuration
β βββ variables.tf # Variable definitions
β βββ outputs.tf # Output definitions
β βββ locals.tf # Local values
βββ bashtest/ # Bash unit tests
β βββ run_all_tests.sh # Master test runner
β βββ bash_test_framework.sh # Testing framework
β βββ test_*.sh # Module-specific tests
βββ tests/ # Python integration tests
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
βββ scripts/ # Utility scripts
βββ docs/ # Documentation
βββ lib/ # Shared libraries
# Proxmox Connection
PROXMOX_HOST="192.168.1.100"
PROXMOX_USERNAME="root@pam"
PROXMOX_PASSWORD="your-secure-password"
# Network Settings
NETWORK_CIDR="192.168.1.0/24"
NETWORK_GATEWAY="192.168.1.1"
STATIC_IP_START="110"
WORKSPACE_IP_BLOCK_SIZE="10"
# DNS Configuration
PRIMARY_DNS_SERVER="192.168.1.10"
SECONDARY_DNS_SERVER="8.8.8.8"
# Kubernetes Settings
KUBERNETES_VERSION="v1.31"
CALICO_VERSION="v3.28.0"
# VM Template Settings
TEMPLATE_VM_ID="9000"
TEMPLATE_VM_NAME="k8s-template"# Ubuntu-specific settings
TEMPLATE_VM_ID="9420"
TEMPLATE_VM_NAME="tpl-ubuntu-2404-k8s"
KUBERNETES_VERSION="v1.31"
CALICO_VERSION="v3.28.0"
RELEASE_LETTER="u"
VM_USERNAME="ubuntu"CPC uses Mozilla SOPS for secure secret management. All sensitive data is encrypted and stored in terraform/secrets.sops.yaml.
π For detailed secrets configuration, see: Secrets Management Guide
- π Encrypted Storage: AES256-GCM encryption with Age keys
- π« No Plaintext: Secrets never stored in plaintext files
- π Automatic Decryption: On-demand decryption during execution
- π Audit Trail: Track changes and modifications
- π Key Rotation: Support for encryption key rotation
global: # VM credentials, SSH keys, Docker Hub, Cloudflare
default: # Infrastructure-specific configs
proxmox: # Proxmox VE connection settings
s3_backend: # MinIO/S3 backend for Terraform state
pihole: # DNS server configuration
harbor: # Container registry settingsCPC uses a sophisticated workspace system that allows you to:
- Maintain multiple environments (dev, staging, production)
- Use different OS distributions per workspace
- Customize Kubernetes versions per environment
- Isolate configurations between projects
| Workspace | Status | Description |
|---|---|---|
ubuntu |
β Production Ready | Ubuntu 24.04 LTS with full feature support |
debian |
π§ In Development | Debian support with basic functionality |
rocky |
π§ In Development | Rocky Linux support with basic functionality |
suse |
β Production Ready | SUSE Linux with full feature support |
k8s129 |
β Production Ready | Specialized Kubernetes 1.29 environment |
# List all workspaces
./cpc list-workspaces
# Create custom workspace
./cpc clone-workspace ubuntu my-project
# Switch workspace context
./cpc ctx my-project
# Delete custom workspace
./cpc delete-workspace my-projectEach workspace has its own environment file in envs/:
# Example: envs/my-project.env
TEMPLATE_VM_ID="9500"
TEMPLATE_VM_NAME="tpl-my-project"
KUBERNETES_VERSION="v1.30"
CALICO_VERSION="v3.27.0"
RELEASE_LETTER="p"
VM_USERNAME="ubuntu"π Detailed Testing Guide: See Testing Documentation for comprehensive testing instructions, examples, and best practices.
# Run all bash unit tests
./bashtest/run_all_tests.sh
# Run Python integration tests
python -m pytest tests/
# Run specific test modules
./bashtest/test_core_module.sh
./bashtest/test_k8s_cluster_module.sh# Comprehensive cluster status
./cpc status
# DNS functionality test
./cpc check-cluster-dns
# Certificate validation
./cpc verify-certificates
# Network connectivity test
./cpc test-dns example.local# SSH connection management
./cpc clear-ssh-hosts
./cpc clear-ssh-maps
# VM status and information
./cpc cluster-info
# Ansible inventory update
./cpc update-inventory# View cluster events
kubectl get events --sort-by=.metadata.creationTimestamp
# Check pod status
kubectl get pods -A
# View logs
kubectl logs -n kube-system deployment/calico-kube-controllers- π§ͺ Testing Guide - Comprehensive testing documentation with examples
- ποΈ Architecture - System architecture and design
- π Project Setup - Development environment setup
# Fork and clone
git clone https://github.com/your-username/CreatePersonalCluster.git
cd CreatePersonalCluster
# Create development workspace
./cpc clone-workspace ubuntu dev
./cpc ctx dev
# Make changes and test
# ... development work ...
# Submit pull request- Follow the modular architecture - Keep code organized in appropriate modules
- Update documentation - Document any new features or changes
- Test thoroughly - Validate changes across different workspaces
- Use English comments - All code comments must be in English
- Follow naming conventions - Use consistent naming patterns
When reporting issues, please include:
- CPC version:
./cpc --version - Workspace:
./cpc ctx - Error logs: Relevant error messages
- System info: Proxmox version, OS details
- Steps to reproduce: Clear reproduction steps
This project is provided as-is for educational and production use. While every effort has been made to ensure reliability and security, users are responsible for their own deployments and configurations.
- Educational Use: Free for learning and experimentation
- Production Use: Use at your own risk with proper testing
- Commercial Use: Contact maintainers for commercial licensing
- Modifications: Feel free to modify and distribute
- Inspired by: ClusterCreator by Jairus Christensen
- Community: Thanks to all contributors and users
- Open Source: Built on Terraform, Ansible, Kubernetes, and Proxmox
- π Complete Guides - Comprehensive documentation
- π§ Troubleshooting - Problem resolution guides
- π Command Reference - Complete command documentation
- Check Documentation: Review the extensive docs in the
docs/directory - Search Issues: Look for similar problems in existing issues
- Create Issue: Open a new issue with detailed information
- Community: Join discussions and share solutions
π Happy Clustering! Deploy your Kubernetes clusters with confidence using CPC.
Last updated: September 2025 | CPC v2.0 | Kubernetes 1.31+ Support