Phase 1: Rocky Linux and network foundation¶
Purpose¶
Prepare three Rocky Linux 9 minimal VMs and the surrounding OPNsense services before installing Kubernetes. Doing the network work first kept DNS, routing, firewall, and Kubernetes problems separate.
All IP addresses on this page are public-safe examples. The private IPAM holds the live DHCP reservations and MAC addresses.
1. Check Proxmox capacity¶
Before creating the VMs, I checked both memory and storage in Proxmox. The host had about 31 GiB usable RAM and enough guest-storage capacity for three small VMs. The root filesystem figure alone is not a reliable measure of the LVM-thin guest-storage pool, so I checked the storage view as well.
The selected layout was:
| Name | Role | vCPU | Memory | Disk | VLAN |
|---|---|---|---|---|---|
k8s-cp-01 |
K3s server and control plane | 2 | 4 GiB | 20 GiB | 20 |
k8s-worker-01 |
K3s agent and worker | 2 | 3 GiB | 16 GiB | 20 |
k8s-worker-02 |
K3s agent and worker | 2 | 3 GiB | 16 GiB | 20 |
Two workers let me see replica placement, rolling updates, and the effect of a worker outage. A single worker would run the application, but it would hide the scheduling and availability behaviour I wanted to learn. I did not build three control-plane nodes because all VMs still share one physical host; that would consume more storage without removing the main failure domain.
2. Create the three VMs¶
For each VM in the Proxmox UI:
- Create a VM from the Rocky Linux 9 minimal ISO.
- Set the VM name from the table above.
- Use VirtIO SCSI storage and enable discard/TRIM.
- Set the CPU type to
host. - Allocate the listed fixed memory; memory ballooning was not used.
- Add a VirtIO network adapter on
vmbr1with VLAN tag20. - Enable the QEMU Guest Agent option.
- Leave the VM disconnected from
vmbr0; Kubernetes belongs behind OPNsense. - Install Rocky Linux 9 Minimal and create the administrative account.
No Kubernetes package was installed during the OS installer.
3. Prepare Rocky Linux¶
Run this on every node:
sudo dnf upgrade -y
sudo dnf install -y \
qemu-guest-agent \
curl \
git \
vim-enhanced \
bash-completion \
container-selinux \
selinux-policy-base
sudo systemctl enable --now qemu-guest-agent
sudo reboot
After the reboot, set one unique hostname on each matching VM:
# Control plane only
sudo hostnamectl set-hostname k8s-cp-01
# First worker only
sudo hostnamectl set-hostname k8s-worker-01
# Second worker only
sudo hostnamectl set-hostname k8s-worker-02
Reboot each VM once more, then verify:
The hostname must be correct before K3s is installed. My first server
installation registered as localhost.localdomain, which later required a
clean K3s reinstall.
4. Create OPNsense DHCP reservations¶
I used DHCP reservations rather than configuring addresses independently in the guests. This keeps the gateway, DNS server, and address ownership in one place.
In the DHCP service already serving VLAN 20, create one reservation per VM. Depending on the OPNsense DHCP backend, this is under the Dnsmasq, Kea, or legacy DHCPv4 page. Each reservation needs:
| Field | Control plane | Worker 1 | Worker 2 |
|---|---|---|---|
| Hostname | k8s-cp-01 |
k8s-worker-01 |
k8s-worker-02 |
| Address | 10.42.20.31 |
10.42.20.32 |
10.42.20.33 |
| Identifier | Private VM MAC/client ID | Private VM MAC/client ID | Private VM MAC/client ID |
| Description | K3s control plane | K3s worker 1 | K3s worker 2 |
These addresses are documentation examples, not the live leases. The reservation location relative to the dynamic pool depends on the DHCP backend: Dnsmasq permits reservations inside its pool, while OPNsense recommends keeping Kea and ISC reservations outside their dynamic pools.
After applying the reservations, renew the leases or reboot the guests and confirm that every node received its intended address:
The gateway should be the VLAN 20 OPNsense interface.
5. Add Unbound DNS overrides¶
Under Services > Unbound DNS > Overrides, add A-record host overrides for
the three nodes. With the public example domain home, the records are:
| Host | Domain | Type | Address |
|---|---|---|---|
k8s-cp-01 |
home |
A | 10.42.20.31 |
k8s-worker-01 |
home |
A | 10.42.20.32 |
k8s-worker-02 |
home |
A | 10.42.20.33 |
Save and apply the Unbound change. VLAN 20 DHCP should hand out OPNsense as the DNS server and provide the internal search domain if short-name lookups are required.
Test from every node:
getent hosts k8s-cp-01
getent hosts k8s-worker-01
getent hosts k8s-worker-02
getent hosts k8s-cp-01.home
getent hosts k8s-worker-01.home
getent hosts k8s-worker-02.home
The control plane should resolve both workers, and both workers should resolve
the control plane. getent is useful here because it exercises the Linux name
service path the K3s installer will use rather than testing only raw DNS.
6. Add OPNsense aliases and access rules¶
I kept the Kubernetes nodes internal. No Kubernetes, SSH, HTTP, or Argo CD port was forwarded from the WAN.
The following aliases make the cross-VLAN policy readable. If an equivalent alias already exists, reuse it instead of creating a duplicate:
| Alias | Type | Members using public examples |
|---|---|---|
K8S_NODES |
Hosts | 10.42.20.31, 10.42.20.32, 10.42.20.33 |
K8S_CONTROL_PLANE |
Host | 10.42.20.31 |
K8S_INGRESS_NODES |
Hosts | the node addresses allowed to receive internal HTTP |
MGMT_HOSTS |
Host/network | Debian management VM or the existing management alias |
OPNsense filters traffic as it enters an interface. Add or confirm these rules above broader block rules:
| Incoming interface | Source | Destination | Port | Reason |
|---|---|---|---|---|
| Management/VLAN 10 | Debian management VM | K8S_NODES |
TCP 22 | SSH administration |
| Management/VLAN 10 | Debian management VM | K8S_INGRESS_NODES |
TCP 80 | Test the application |
| Management/VLAN 10 | Debian management VM | K8S_CONTROL_PLANE |
TCP 6443, only if remote kubectl is used |
Kubernetes API access |
| WireGuard | WireGuard client alias | K8S_INGRESS_NODES |
TCP 80 | Browser access to the demo site over VPN |
| WireGuard | WireGuard client alias | OPNsense DNS address | TCP/UDP 53 | Resolve internal names over VPN |
| Infrastructure/VLAN 20 | K8S_NODES |
approved internet destinations or the existing outbound policy | TCP 443, DNS, NTP as required | Download K3s and pull images |
Log the narrow allow rules while testing. Confirm hits in Firewall > Log Files > Live View, then leave logging enabled only where it remains useful.
The three nodes share VLAN 20, so their node-to-node packets are switched
directly by vmbr1; they do not pass through OPNsense. Rules for Kubernetes
TCP 6443, UDP 8472, and TCP 10250 must therefore also be enforced on the
Rocky Linux host firewalls. An OPNsense same-subnet rule alone would not protect
or permit that traffic.
7. Configure firewalld on the nodes¶
Use the live VLAN 20 subnet in place of <vlan20-cidr>.
On the control-plane node:
sudo firewall-cmd --permanent \
--add-rich-rule='rule family="ipv4" source address="<vlan20-cidr>" port port="6443" protocol="tcp" accept'
On all three nodes:
sudo firewall-cmd --permanent \
--add-rich-rule='rule family="ipv4" source address="<vlan20-cidr>" port port="8472" protocol="udp" accept'
sudo firewall-cmd --permanent \
--add-rich-rule='rule family="ipv4" source address="<vlan20-cidr>" port port="10250" protocol="tcp" accept'
sudo firewall-cmd --permanent --zone=trusted --add-source=10.244.0.0/16
sudo firewall-cmd --permanent --zone=trusted --add-source=10.96.0.0/16
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
sudo firewall-cmd --zone=trusted --list-sources
UDP 8472 is Flannel VXLAN traffic and must never be exposed to the WAN. TCP
2379-2380 was not opened because this lab has one server and does not use an
embedded-etcd HA control plane.
8. Verify time, SELinux, and swap¶
Run on all nodes:
timedatectl
timedatectl show -p NTPSynchronized --value
getenforce
systemctl is-active firewalld
systemctl is-active qemu-guest-agent
swapon --show
The observed results were synchronized time, Enforcing, active firewalld,
and an active guest agent. Disable swap if swapon --show returns an entry:
sudo swapoff -a
sudo cp /etc/fstab /etc/fstab.pre-k3s
sudo sed -i '/[[:space:]]swap[[:space:]]/s/^/#/' /etc/fstab
Re-run swapon --show; it should return no rows.
9. Reserve Kubernetes networks¶
I checked that these ranges did not overlap the home LAN, VLANs, WireGuard, or any network reached through the VPN:
| Purpose | Range |
|---|---|
| Pod network | 10.244.0.0/16 |
| Service network | 10.96.0.0/16 |
They are cluster-internal ranges. VPN users do not need direct routes to them because requests enter through Traefik on a node address.
Completion checks¶
- Three VMs exist on
vmbr1, VLAN 20. - Hostnames are unique and final.
- DHCP reservations are stable.
- Short and fully qualified node names resolve.
- Nodes have synchronized time.
- SELinux remains enforcing.
- Host and OPNsense firewall paths are documented.
- Pod and Service ranges do not overlap existing networks.
- No Kubernetes port is exposed on the WAN.