Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
Production-Grade Kubernetes on CoreOS - Multi-Node Deployment Guide#
Deploying Kubernetes in production environments requires careful consideration of security, stability, and scalability. Fedora CoreOS provides an excellent foundation for Kubernetes deployments due to its minimal, immutable nature and built-in security features. This guide walks you through creating a production-ready Kubernetes cluster on CoreOS with enhanced security.
Security Overview#
This deployment includes several security enhancements:
- SELinux enabled by default for mandatory access control
- CRI-O container runtime with strong SELinux integration
- Secure node communication through kubeadm’s built-in PKI infrastructure
- Network security with kube-router for network policy enforcement
- Immutable infrastructure principles through CoreOS design
Prerequisites#
Before you begin, ensure you have:
- Fedora CoreOS qcow2 image (download here)
- A host with
podman,libvirt, andvirt-installtools installed - SSH key pair generated (
ssh-keygen -t ed25519)
Hardware requirements per node:
- 2+ vCPUs
- 4GB+ RAM
- 10GB+ storage (20GB+ recommended for production)
Initial Configuration#
1. Create Butane Configuration#
Butane is CoreOS’s configuration transpiler. Create a file named fcos.bu:
1variant: fcos2version: 1.4.03storage:4 files:5 # CRI-O Configuration6 - path: /etc/dnf/modules.d/cri-o.module7 mode: 06448 overwrite: true9 contents:10 inline: |11 [cri-o]12 name=cri-o13 stream=1.1714 profiles=15 state=enabled16
17 # Kubernetes Repository18 - path: /etc/yum.repos.d/kubernetes.repo19 mode: 064420 overwrite: true21 contents:22 inline: |23 [kubernetes]24 name=Kubernetes25 baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/26 enabled=127 gpgcheck=128 gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key29
30 # Network Configuration31 - path: /etc/modules-load.d/br_netfilter.conf32 mode: 064433 overwrite: true34 contents:35 inline: br_netfilter36
37 # Kubernetes Network Parameters38 - path: /etc/sysctl.d/kubernetes.conf39 mode: 064440 overwrite: true41 contents:42 inline: |43 net.bridge.bridge-nf-call-iptables=144 net.ipv4.ip_forward=145passwd:46 users:47 - name: core48 ssh_authorized_keys:49 - YOUR_SSH_PUBLIC_KEY_HEREReplace YOUR_SSH_PUBLIC_KEY_HERE with the content of your public SSH key.
2. Generate Ignition Configuration#
Convert the Butane configuration to an Ignition file:
1podman run --interactive --rm \2 quay.io/coreos/butane:release \3 --pretty --strict < fcos.bu > fcos.ign3. Create VM Deployment Script#
Create a script named start_fcos.sh to launch CoreOS VMs:
1#!/bin/sh2
3IGN_CONFIG=/path/to/fcos.ign4IMAGE=/path/to/fedora-coreos.qcow25VM_NAME=node$16VCPUS=27RAM_MB=40968DISK_GB=209STREAM=stable10
11chcon --verbose --type svirt_home_t ${IGN_CONFIG}12virt-install --connect="qemu:///system" --name="${VM_NAME}" \13 --vcpus="${VCPUS}" --memory="${RAM_MB}" \14 --os-variant="fedora-coreos-$STREAM" --import --graphics=none \15 --disk="size=${DISK_GB},backing_store=${IMAGE}" \16 --qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${IGN_CONFIG}"Make the script executable:
1chmod +x start_fcos.shNode Setup#
1. Launch VMs#
Start your cluster nodes. For a basic production setup, you’ll need at least three nodes (one control plane and two workers):
1# Launch in separate terminals or tmux panes2./start_fcos.sh 1 # Control plane3./start_fcos.sh 2 # Worker4./start_fcos.sh 3 # WorkerNote the IP addresses assigned to each VM during boot.
2. Configure Host Resolution#
Add the node IP addresses to your host’s /etc/hosts file for easier access: