Repository navigation
Home
StackOpsys is an infrastructure automation stack that orchestrates the complete creation of Kubernetes clusters from scratch using Packer, Terraform, and Ansible in Proxmox environments.
This solution applies Infrastructure as Code (IaC) best practices to help you reproduce, scale, and maintain your Kubernetes infrastructure reliably.
- βοΈ Packer β Builds base images with Kubeadm pre-installed
- π¦ Terraform β Provisions virtual machines on Proxmox VE
- π§ Ansible β Installs required packages and joins worker nodes to the cluster
- βοΈ Proxmox VE β Local virtualization platform
- π³ Kubernetes (kubeadm) β Container orchestration
stackopsys/
βββ packer/ # Base image construction
β βββ base-images/
β β βββ dev.example.pkrvars.hcl
β β βββ files/
β β βββ http/ # Cloud-init configuration
β β βββ scripts/ # Installation scripts
β β βββ ubuntu-server-noble.pkr.hcl
β βββ README.md # π Detailed Packer guide
βββ terraform/ # Infrastructure provisioning
β βββ environments/ # Environment configurations
β βββ modules/
β β βββ vms_proxmox/ # Main VM module
β β βββ tools_k8s/ # Kubernetes tools
β βββ main.tf
β βββ README.md # π Detailed Terraform guide
βββ ansible/ # Configuration and deployment
β βββ inventory/ # Host inventory
β βββ roles/ # Configuration roles
β β βββ prepare-nodes/
β β βββ configure-master-node/
β β βββ configure-worker-node/
β β βββ kubeconfig/
β βββ site.yaml # Main playbook
β βββ Readme.md # π Detailed Ansible guide
βββ proxmox/ # Proxmox configuration
β βββ README.md # π User and permissions configuration
βββ README-es.md # This file
- A configured and accessible Proxmox VE instance
- Proxmox API token with sufficient permissions
- Packer installed
>= 1.8 - Terraform installed
>= 1.4 - Ansible installed
>= 2.14 - SSH access to VMs
- Internet access from VMs
- Gateway:
192.168.100.1 - IP Range:
192.168.100.220-224 - CIDR:
/24 - DNS: Configure according to your environment
π See detailed guide: promox/README.md
# Create user and role for Terraform
pveum user add terraform@pam -comment "Terraform User"
pveum role add TerraformRole -privs "Datastore.Allocate..."
pveum acl modify / -user terraform@pam -role TerraformRole
pveum user token add terraform@pam provider --privsep=0π See detailed guide: packer/README.md
cd packer/base-images
# Initialize Packer
packer init -upgrade .
# Validate configuration
packer validate -var-file=dev.pkrvars.hcl .
# Build image
PACKER_LOG=1 packer build -on-error=ask -var-file="dev.pkrvars.hcl" .Result: Ubuntu 24.04 LTS base image with kubeadm, containerd, and necessary configurations.
π See detailed guide: terraform/README.md
cd terraform
# Initialize Terraform
terraform init
# Plan deployment
terraform plan -var-file=environments/dev.tfvars
# Apply configuration
terraform apply -var-file=environments/dev.tfvarsResult:
- 1 master node (192.168.100.220)
- 2 worker nodes (192.168.100.223, 192.168.100.224)
- Network and storage configuration
π See detailed guide: ansible/Readme.md
cd ansible
# Install required collections
ansible-galaxy collection install -r collections/requirements.yaml
# Verify connectivity
ansible all -i inventory/hosts.ini -m ping
# Deploy complete cluster
task apply:all
# Or alternatively:
ansible-playbook site.yaml -i inventory/hosts.iniResult: Fully functional Kubernetes cluster with:
- Configured master node
- Worker nodes joined to the cluster
- Kubeconfig available for administration
# Copy kubeconfig
scp rtaparay@192.168.100.220:~/.kube/config ~/.kube/config
# Verify nodes
kubectl get nodes
# Verify system pods
kubectl get pods -A
# Cluster information
kubectl cluster-info- Container Runtime: Containerd
- Kubernetes Version: v1.30+
- Initialization: kubeadm
- Network: Configuration prepared for Istio/Kubeflow
- Storage: Longhorn (distributed)
- Ingress: NGINX Ingress Controller
- Monitoring: Ready for Prometheus/Grafana
- Firewalld enabled by default
- Kubernetes ports configured automatically
- SSH access with keys
- Secure API tokens
- GitHub Actions integrated
- Task runner for simplified commands
- Detailed logs of all operations
- Separate environments (dev, qas, prd)
-
Packer:
packer/base-images/logs/ -
Terraform:
terraform/output/ -
Ansible:
ansible/output/
# Node status
kubectl get nodes -o wide
# Cluster resources
kubectl top nodes
kubectl top pods -A
# Cluster events
kubectl get events --sort-by='.lastTimestamp'-
SSH connectivity error
ansible all -i inventory/hosts.ini -m ping
-
Swap issues
sudo swapoff -a sudo sed -i '/ swap / s/^/#/' /etc/fstab -
Complete cluster reset
# Uncomment reset-vm role in site.yaml ansible-playbook site.yaml -i inventory/hosts.ini --tags reset
# Ansible with maximum verbosity
ansible-playbook site.yaml -i inventory/hosts.ini -vvv
# Terraform with debug
TF_LOG=DEBUG terraform apply -var-file=environments/dev.tfvars
# Packer with logs
PACKER_LOG=1 packer build -var-file="dev.pkrvars.hcl" .# Update base image
cd packer/base-images && packer build -var-file="dev.pkrvars.hcl" .
# Update infrastructure
cd terraform && terraform apply -var-file=environments/dev.tfvars
# Reconfigure nodes
cd ansible && ansible-playbook site.yaml -i inventory/hosts.ini# Add new workers in terraform/environments/dev.tfvars
# Apply changes
terraform apply -var-file=environments/dev.tfvars
# Configure new nodes
ansible-playbook site.yaml -i inventory/hosts.ini --limit k8s_worker# Destroy infrastructure
cd terraform && terraform destroy -var-file=environments/dev.tfvars-
Packer:
packer/README.md- Base image construction -
Terraform:
terraform/README.md- Infrastructure provisioning -
Ansible:
ansible/Readme.md- Configuration and deployment -
Proxmox:
promox/README.md- Permissions configuration -
Ansible Installation:
ansible/install_ansible.md -
Inventory Configuration:
ansible/inventory_ansible.md
- DevOps Engineer pushes to Git repository
- CI/CD pipeline is automatically triggered
- Packer builds optimized VM templates
- Installs base packages, Docker, K8s tools
- Creates template in Proxmox VE
- Terraform reads configuration (terraform.tfvars)
- Creates VMs from Packer template
- Configures network, resources, and storage
- Ansible executes playbooks automatically
- Configures master and worker nodes
- Installs and configures Kubernetes
- Functional Kubernetes cluster
- kubectl for management
- Monitoring and logs configured
Contributions are welcome. Feel free to open issues, submit pull requests, or suggest improvements.
- Fork the repository
- Create feature branch
- Make changes
- Run tests
- Submit pull request
MIT Β© Raul Tapara