DEV Community

RAUL TAPARA YANGALI
RAUL TAPARA YANGALI

Posted on

πŸš€ StackOpsys: Part 1-Automating Kubernetes Infrastructure on Proxmox with Packer, Terraform and Ansible

✨ What is StackOpsys?

StackOpsys is a personal project I'm building to automate the end-to-end deployment of Kubernetes clusters on Proxmox VE using key Infrastructure as Code (IaC) tools:

  • πŸ”§ Packer β†’ builds custom base images
  • βš™οΈ Terraform β†’ provisions virtual machines on Proxmox
  • πŸ“¦ Ansible β†’ installs packages and connects the nodes to the cluster
  • ☸️ Kubeadm β†’ orchestrates the Kubernetes cluster
  • πŸ–₯️ Proxmox VE β†’ local virtualization environment

πŸ› οΈ Project Status

So far, I’ve completed the Packer phase by creating a secure base image with Ubuntu Server 24.04 LTS that includes system configurations to run Kubernetes properly:

  • Swap disabled
  • Kernel modules loaded (br_netfilter, overlay)
  • sysctl network parameters applied
  • Firewall configured with firewalld and required ports open

This forms a solid base for a fully reproducible cluster deployment.


πŸ“¦ Using Packer in StackOpsys

What does this module do?

It creates a custom image in Proxmox VE, ideal for Terraform use. It’s also prepared for integration with Ansible and Kubeadm.

Requirements:

  • A working Proxmox VE setup
  • API Token with permissions to create VMs
  • Packer version β‰₯ 1.8

πŸ§ͺ Installing Packer

πŸ”Ή On Ubuntu

sudo apt-get update
sudo apt-get install -y unzip
curl -fsSL https://releases.hashicorp.com/packer/1.9.4/packer_1.9.4_linux_amd64.zip -o packer.zip
unzip packer.zip
sudo mv packer /usr/local/bin/
packer --version
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή On macOS

brew tap hashicorp/tap
brew install hashicorp/tap/packer
packer --version
Enter fullscreen mode Exit fullscreen mode

πŸš€ How to Use Packer in StackOpsys

1️⃣ Initialize the environment

git clone https://github.com/rtaparay/StackOpsys.git
cd packer/base-images
packer init -upgrade .
Enter fullscreen mode Exit fullscreen mode

βœ… Validate the template with custom variables

packer validate -var-file=dev.pkrvars.hcl .
Enter fullscreen mode Exit fullscreen mode

πŸ—οΈ Build the image (interactive mode if errors occur)

packer build -on-error=ask -var-file="dev.pkrvars.hcl" .
Enter fullscreen mode Exit fullscreen mode

πŸ” Detailed build with logs

PACKER_LOG=1 packer build -on-error=ask -var-file="dev.pkrvars.hcl" . 2>&1 | tee logs/packer-build-$(date +"%Y-%m-%d_%H:%M:%S").log
Enter fullscreen mode Exit fullscreen mode

1

2

3

4


πŸ“ Project Structure (so far)

packer
β”œβ”€β”€ base-images
β”‚   β”œβ”€β”€ files
β”‚   β”‚   └── 99-pve.cfg
β”‚   β”œβ”€β”€ http
β”‚   β”‚   β”œβ”€β”€ meta-data
β”‚   β”‚   └── user-data
β”‚   β”œβ”€β”€ logs
β”‚   β”œβ”€β”€ dev.pkrvars.hcl
β”‚   β”œβ”€β”€ scripts
β”‚   β”‚   └── install-kubeadm.sh
β”‚   β”œβ”€β”€ ubuntu-server-noble.pkr.hcl
β”‚   └── variables.pkr.hcl
Enter fullscreen mode Exit fullscreen mode

πŸ” Preconfigured Network Security

The image enables firewalld and opens the required ports for Kubernetes:

Port/Range Protocol Function Used By
6443 TCP Kubernetes API kube-apiserver
2379-2380 TCP etcd etcd
10250 TCP Kubelet API kubelet
10251 TCP kube-scheduler kube-scheduler
10252 TCP kube-controller-manager kube-controller-manager

πŸ“ What's Next?

Next phases include:

  1. Terraform for automatic VM creation in Proxmox using this image
  2. Ansible for installing packages and joining nodes to the cluster
  3. Kubeadm for control-plane initialization and networking

All under a clean, modular and fully repeatable flow.


🀝 Want to follow or contribute?

πŸ“ Project in progress. You can follow it or drop suggestions here:

πŸ‘‰ github.com/rtaparay/stackopsys


🧠 Final Thoughts

StackOpsys is more than a script or templateβ€”it's a complete approach to building infrastructure from scratch, with full control, best practices, and freedom to scale.

If you're into DevOps, Kubernetes, IaC or building your own Proxmox lab, this might be useful to you!

Thanks for reading πŸ’»βš™οΈ

Top comments (0)