Skip to content

Deploying a kubeadm Kubernetes 1.30 cluster with stacked etcd on AlmaLinux 9 — 3 control + 3 worker installer

Stand up a production-grade Kubernetes 1.30 cluster on AlmaLinux 9 — three control-plane nodes with stacked etcd, three workers, kube-vip APIs, containerd, Cilium CNI. Full installer with verification.

You inherit a production environment running an unmanaged Kubernetes built two years ago by a contractor who is no longer reachable. The control plane is a single VM. The etcd data dir lives on the same disk as /var/log, which fills up monthly. You can’t upgrade because the version is two minors behind upstream support. You can’t add a second control plane because the apiserver is bound to a single IP and there’s no mechanism to share the etcd quorum. The decision tree leads in exactly one direction: rebuild on a documented installer, get back to a supported version, and never end up here again. This article is that installer — a clean kubeadm-managed HA cluster on AlmaLinux 9 with stacked etcd, three control-plane nodes, three workers, kube-vip for the API VIP, and Cilium as the CNI.

What’s happening

Stacked etcd means each control-plane node runs its own etcd member as a static pod on the same machine as the apiserver. The alternative — external etcd — runs etcd on dedicated nodes outside the kubeadm flow. Stacked is the right default when you control three solid VMs: lower operational surface area, simpler upgrades, and kubeadm manages the etcd certificates for you. External etcd is the right call when you need to scale etcd independently (very large clusters), share an etcd ring between multiple Kubernetes clusters, or run etcd on dedicated NVMe to isolate IO contention. For a typical B2B SaaS workload of a few hundred pods, stacked is the simpler and safer choice — and it’s what this installer builds.

The HA requirement: clients (workers, kubectl, your CI) need a single address that survives any one control-plane node dying. kube-vip handles this with a layer-2 VIP that floats between the three control-plane nodes via ARP. One node holds the VIP at any time; if it fails, the next node takes over within a few seconds. The VIP appears in the apiserver’s TLS SAN list so cert verification keeps working through failover.

Containerd is the container runtime — Kubernetes deprecated dockershim three years ago, and containerd is what kubeadm pulls by default. Cilium replaces the kube-proxy iptables/ipvs forwarding with eBPF, which scales to thousands of services without quadratic rule reloads and gives you network policies in the same control plane. The installer below ships kube-proxy disabled (--skip-phases=addon/kube-proxy) and lets Cilium take that role.

The five things that go wrong in the field, in roughly descending order: (1) swap is enabled and the kubelet refuses to start (--fail-swap-on=true is still the default), (2) SELinux is enforcing without the right container_runtime_t contexts and pods can’t write to hostPath, (3) the firewall blocks intra-cluster traffic on 6443/2379/2380/4240/8472, (4) the system clock is more than 5s off NTP and the etcd Raft heartbeat fails, (5) the same hostname is used twice (kubeadm rejects this and the second join is silent). The installer handles all five.

How to verify

Once the installer has run on all six nodes:

# Node roles and Ready state
kubectl get nodes -o wide
# NAME      STATUS   ROLES           AGE   VERSION
# cp-1      Ready    control-plane   18m   v1.30.4
# cp-2      Ready    control-plane   16m   v1.30.4
# cp-3      Ready    control-plane   16m   v1.30.4
# wk-1      Ready    <none>          14m   v1.30.4
# wk-2      Ready    <none>          14m   v1.30.4
# wk-3      Ready    <none>          14m   v1.30.4

# Cilium agent on every node
kubectl -n kube-system get pods -l k8s-app=cilium -o wide

# Cilium quick health
kubectl -n kube-system exec ds/cilium -- cilium status --brief

etcd quorum from any control-plane node:

ETCDCTL_API=3 etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  endpoint status --write-out=table

ETCDCTL_API=3 etcdctl \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  member list --write-out=table

VIP location at any moment:

for ip in 10.30.0.11 10.30.0.12 10.30.0.13; do
  ssh root@${ip} "ip -4 addr show | grep -F '10.30.0.10/'" \
    && echo "  ^-- VIP on ${ip}"
done

End-to-end pod scheduling and DNS:

kubectl run nettest --image=ghcr.io/nicolaka/netshoot:v0.13 -it --rm --restart=Never -- \
  bash -c 'dig +short kubernetes.default.svc.cluster.local && \
           curl -sk https://kubernetes.default/healthz?verbose | head -5'

The fix

Save the script as /root/setup-k8s-node.sh and run it on each of the six nodes after editing the variables at the top. It performs the full installer on AlmaLinux 9: base hardening, swap off, SELinux into permissive for the install then restored to enforcing with the right contexts, kernel modules and sysctl, containerd from the official repo, the Kubernetes pkgs.k8s.io community repo for the 1.30 channel, kubeadm/kubelet/kubectl pinned, firewalld rules for intra-cluster traffic, kube-vip static manifest on control-plane nodes, kubeadm init on the first CP with --upload-certs, join on the next two CPs and on the workers, and the Cilium install via the Cilium CLI right after the cluster is up.

#!/usr/bin/env bash
set -euo pipefail

### AlmaLinux 9 Kubernetes 1.30 installer (kubeadm + stacked etcd)
### Roles: cp-init | cp-join | worker

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

# === EDIT PER NODE ===
ROLE="cp-init"                       # cp-init | cp-join | worker
NODE_NAME="cp-1"                     # short hostname
NODE_IP="10.30.0.11"                 # this node's private IP
VIP="10.30.0.10"                     # control-plane VIP
VIP_INTERFACE="ens18"                # NIC for kube-vip ARP (CPs only)
K8S_MINOR="v1.30"                    # repo channel
KUBE_VERSION="1.30.4-150500.1.1"     # pinned package version
KUBE_VIP_VERSION="v0.8.4"
CILIUM_VERSION="1.16.4"
POD_CIDR="10.244.0.0/16"
SERVICE_CIDR="10.96.0.0/12"
CLUSTER_NAME="prod-k8s"
# Use the same shared join token on every node. Generate once:
# kubeadm token generate
KUBEADM_TOKEN="abcdef.0123456789abcdef"
# Pre-generate a stable certificate key with `kubeadm certs certificate-key`
CERT_KEY="REPLACE_WITH_CERT_KEY"
# Cluster DNS domain
CLUSTER_DOMAIN="cluster.local"
# =====================

echo
echo "========================================"
echo "k8s node ${NODE_NAME} (${NODE_IP}) - role: ${ROLE}"
echo "========================================"
echo

hostnamectl set-hostname "${NODE_NAME}"

echo "==> Updating base OS"
dnf -y update
dnf -y install epel-release
dnf -y install vim curl wget chrony fail2ban dnf-automatic \
  policycoreutils-python-utils lsof tcpdump bind-utils tar gzip \
  iproute iptables nftables socat conntrack-tools ethtool jq

systemctl enable --now chronyd

echo "==> Disabling swap (kubelet requirement)"
swapoff -a
sed -i.bak '/[[:space:]]swap[[:space:]]/s/^/#/' /etc/fstab

echo "==> SELinux: enforcing with container contexts"
# kubeadm historically wanted permissive; AlmaLinux 9 + containerd handles enforcing.
# We keep enforcing but apply the targeted policy that lets the kubelet write to
# /var/lib/kubelet and containerd mount volumes correctly.
dnf -y install container-selinux selinux-policy-base
setsebool -P container_use_cephfs 1 || true

echo "==> Kernel modules"
cat > /etc/modules-load.d/k8s.conf <<'MODS'
br_netfilter
overlay
nf_conntrack
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
MODS
modprobe -a br_netfilter overlay nf_conntrack ip_vs ip_vs_rr ip_vs_wrr ip_vs_sh

echo "==> sysctl for kube-proxy/Cilium-friendly forwarding"
cat > /etc/sysctl.d/99-k8s.conf <<'SYSCTL'
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
fs.inotify.max_user_instances = 8192
fs.inotify.max_user_watches = 524288
vm.max_map_count = 524288
kernel.dmesg_restrict = 1
net.netfilter.nf_conntrack_max = 1048576
net.core.somaxconn = 4096
SYSCTL
sysctl --system

echo "==> Hardening SSH"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart sshd

echo "==> fail2ban + automatic security updates"
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban

cat > /etc/dnf/automatic.conf <<'DNFAUTO'
[commands]
upgrade_type = security
random_sleep = 900
download_updates = yes
apply_updates = yes
[emitters]
emit_via = stdio
DNFAUTO
systemctl enable --now dnf-automatic.timer

echo "==> Firewalld (intra-cluster open, public closed)"
dnf -y install firewalld
systemctl enable --now firewalld
firewall-cmd --permanent --new-zone=k8s-internal || true
firewall-cmd --permanent --zone=k8s-internal --add-source=10.30.0.0/24
firewall-cmd --permanent --zone=k8s-internal --add-source=${POD_CIDR}
firewall-cmd --permanent --zone=k8s-internal --add-source=${SERVICE_CIDR}
# CP-only ports
if [[ "${ROLE}" =~ ^cp- ]]; then
  firewall-cmd --permanent --zone=k8s-internal --add-port=6443/tcp   # apiserver
  firewall-cmd --permanent --zone=k8s-internal --add-port=2379/tcp   # etcd client
  firewall-cmd --permanent --zone=k8s-internal --add-port=2380/tcp   # etcd peer
  firewall-cmd --permanent --zone=k8s-internal --add-port=10257/tcp  # ctrl-mgr
  firewall-cmd --permanent --zone=k8s-internal --add-port=10259/tcp  # scheduler
fi
# All-node ports
firewall-cmd --permanent --zone=k8s-internal --add-port=10250/tcp    # kubelet
firewall-cmd --permanent --zone=k8s-internal --add-port=30000-32767/tcp  # NodePort
firewall-cmd --permanent --zone=k8s-internal --add-port=4240/tcp     # cilium health
firewall-cmd --permanent --zone=k8s-internal --add-port=4244/tcp     # hubble
firewall-cmd --permanent --zone=k8s-internal --add-port=8472/udp     # vxlan (cilium overlay if used)
firewall-cmd --reload

echo "==> Installing containerd 1.7"
dnf -y install yum-utils
dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
dnf -y install containerd.io

mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml
# Use systemd cgroup driver (matches kubelet default on this distro)
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
# Use a maintained pause image
sed -i 's|sandbox_image = ".*"|sandbox_image = "registry.k8s.io/pause:3.10"|' /etc/containerd/config.toml
systemctl enable --now containerd

echo "==> Installing kubeadm/kubelet/kubectl ${KUBE_VERSION}"
cat > /etc/yum.repos.d/kubernetes.repo <<EOF
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/${K8S_MINOR}/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF

dnf -y install --disableexcludes=kubernetes \
  kubelet-${KUBE_VERSION} \
  kubeadm-${KUBE_VERSION} \
  kubectl-${KUBE_VERSION}
systemctl enable kubelet

# === kube-vip static manifest (CP nodes only) =====================
write_kubevip_manifest() {
  mkdir -p /etc/kubernetes/manifests
  cat > /etc/kubernetes/manifests/kube-vip.yaml <<KVPOD
apiVersion: v1
kind: Pod
metadata:
  name: kube-vip
  namespace: kube-system
spec:
  hostNetwork: true
  containers:
    - name: kube-vip
      image: ghcr.io/kube-vip/kube-vip:${KUBE_VIP_VERSION}
      args: ["manager"]
      securityContext:
        capabilities:
          add: ["NET_ADMIN","NET_RAW","SYS_TIME"]
      env:
        - name: vip_arp
          value: "true"
        - name: port
          value: "6443"
        - name: vip_interface
          value: "${VIP_INTERFACE}"
        - name: vip_cidr
          value: "32"
        - name: cp_enable
          value: "true"
        - name: cp_namespace
          value: "kube-system"
        - name: svc_enable
          value: "false"
        - name: lb_enable
          value: "false"
        - name: vip_leaderelection
          value: "true"
        - name: vip_leaseduration
          value: "5"
        - name: vip_renewdeadline
          value: "3"
        - name: vip_retryperiod
          value: "1"
        - name: address
          value: "${VIP}"
      volumeMounts:
        - name: kubeconfig
          mountPath: /etc/kubernetes/admin.conf
          readOnly: true
  volumes:
    - name: kubeconfig
      hostPath:
        path: /etc/kubernetes/admin.conf
        type: FileOrCreate
KVPOD
}

# === kubeadm config for cp-init ===================================
write_kubeadm_init() {
  cat > /root/kubeadm-init.yaml <<EOF
apiVersion: kubeadm.k8s.io/v1beta3
kind: InitConfiguration
bootstrapTokens:
  - token: "${KUBEADM_TOKEN}"
    ttl: 24h0m0s
    usages:
      - signing
      - authentication
localAPIEndpoint:
  advertiseAddress: ${NODE_IP}
  bindPort: 6443
nodeRegistration:
  name: ${NODE_NAME}
  criSocket: unix:///run/containerd/containerd.sock
certificateKey: ${CERT_KEY}
---
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
kubernetesVersion: ${KUBE_VERSION%%-*}
clusterName: ${CLUSTER_NAME}
controlPlaneEndpoint: "${VIP}:6443"
networking:
  podSubnet: ${POD_CIDR}
  serviceSubnet: ${SERVICE_CIDR}
  dnsDomain: ${CLUSTER_DOMAIN}
apiServer:
  certSANs:
    - "${VIP}"
    - "10.30.0.11"
    - "10.30.0.12"
    - "10.30.0.13"
    - "kubernetes"
    - "kubernetes.default"
    - "kubernetes.default.svc"
    - "kubernetes.default.svc.${CLUSTER_DOMAIN}"
etcd:
  local:
    dataDir: /var/lib/etcd
---
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cgroupDriver: systemd
---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: "iptables"
EOF
}

case "${ROLE}" in
  cp-init)
    echo "==> Writing kube-vip manifest (must exist before kubeadm init)"
    write_kubevip_manifest
    write_kubeadm_init
    echo "==> kubeadm init (skip-phases: addon/kube-proxy — Cilium replaces it)"
    kubeadm init --config /root/kubeadm-init.yaml \
      --upload-certs \
      --skip-phases=addon/kube-proxy

    mkdir -p /root/.kube
    cp /etc/kubernetes/admin.conf /root/.kube/config
    chown -R "$(id -u)":"$(id -g)" /root/.kube

    echo "==> Installing Cilium CLI"
    CILIUM_CLI_VERSION="$(curl -s https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt)"
    CLI_ARCH=amd64
    curl -L --fail --remote-name-all https://github.com/cilium/cilium-cli/releases/download/${CILIUM_CLI_VERSION}/cilium-linux-${CLI_ARCH}.tar.gz
    tar -C /usr/local/bin -xzf cilium-linux-${CLI_ARCH}.tar.gz
    rm cilium-linux-${CLI_ARCH}.tar.gz

    echo "==> Installing Cilium ${CILIUM_VERSION} (kube-proxy replacement)"
    KUBECONFIG=/etc/kubernetes/admin.conf cilium install --version "${CILIUM_VERSION}" \
      --set kubeProxyReplacement=true \
      --set k8sServiceHost="${VIP}" \
      --set k8sServicePort=6443 \
      --set ipam.mode=kubernetes \
      --set routingMode=tunnel \
      --set tunnelProtocol=vxlan \
      --set hubble.enabled=true \
      --set hubble.relay.enabled=true \
      --set hubble.ui.enabled=true

    echo "==> Print the join command for CPs and workers"
    echo
    echo "  # On cp-2 and cp-3 (with ROLE=cp-join + CERT_KEY above):"
    kubeadm token create --print-join-command --certificate-key "${CERT_KEY}" || true
    echo
    echo "  # On workers (with ROLE=worker):"
    kubeadm token create --print-join-command || true
    ;;

  cp-join)
    write_kubevip_manifest
    echo "==> Joining as additional control-plane node"
    kubeadm join "${VIP}:6443" \
      --token "${KUBEADM_TOKEN}" \
      --discovery-token-unsafe-skip-ca-verification \
      --control-plane \
      --certificate-key "${CERT_KEY}" \
      --apiserver-advertise-address "${NODE_IP}" \
      --node-name "${NODE_NAME}"

    mkdir -p /root/.kube
    cp /etc/kubernetes/admin.conf /root/.kube/config
    ;;

  worker)
    echo "==> Joining as worker"
    kubeadm join "${VIP}:6443" \
      --token "${KUBEADM_TOKEN}" \
      --discovery-token-unsafe-skip-ca-verification \
      --node-name "${NODE_NAME}"
    ;;

  *)
    echo "Unknown ROLE: ${ROLE}"
    exit 1
    ;;
esac

echo "==> Waiting for kubelet to be Ready"
for i in {1..60}; do
  if systemctl is-active --quiet kubelet; then break; fi
  sleep 2
done

if [[ "${ROLE}" =~ ^cp- ]]; then
  echo "==> Waiting for apiserver on this node"
  for i in {1..60}; do
    if curl -k -fs "https://127.0.0.1:6443/healthz" >/dev/null 2>&1; then break; fi
    sleep 2
  done
fi

echo
echo "========================================"
echo "DONE — ${NODE_NAME} (${ROLE})"
echo "========================================"
echo
if [[ "${ROLE}" =~ ^cp- ]]; then
  KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes -o wide || true
fi
echo
echo "Listeners on this node:"
ss -lntp | grep -E ':(6443|2379|2380|10250|10257|10259|10256)\b' || true
echo
echo "Next steps:"
echo "  - On the remaining CPs, run with ROLE=cp-join"
echo "  - On workers, run with ROLE=worker"
echo "  - Verify Cilium: KUBECONFIG=/etc/kubernetes/admin.conf cilium status"
echo "  - Schedule etcd snapshots — kubeadm does not do this for you"

Make executable and run in order:

chmod 700 /root/setup-k8s-node.sh
# 1. cp-1 with ROLE=cp-init
# 2. cp-2 and cp-3 with ROLE=cp-join (after copying the printed CERT_KEY)
# 3. wk-1, wk-2, wk-3 with ROLE=worker
/root/setup-k8s-node.sh

After all six nodes report Ready, do three drills before any production workload. Drain and reboot the VIP holder — confirm kubectl get nodes keeps responding through the VIP, and that the VIP migrates to another CP within five seconds (for i in 10.30.0.11 10.30.0.12 10.30.0.13; do ssh root@$i "ip -4 addr | grep '${VIP}/'"; done). Stop the kubelet on cp-2 (systemctl stop kubelet) — etcd should report two healthy members and the cluster should keep serving API traffic. Schedule the first etcd snapshot to object storage right now (kubectl -n kube-system exec etcd-cp-1 -- etcdctl --endpoints=https://127.0.0.1:2379 ... snapshot save /tmp/etcd.snap.db && upload to S3) — if you don’t have snapshots before you put real data in, you don’t have a cluster, you have an experiment.

Stack Harbor operates kubeadm-managed clusters under environment management, with on-call coverage from the monitoring and support plane. If you’d prefer the cluster operated for you rather than building it, scope a managed Kubernetes engagement.