|

Docker & Kubernetes Container Orchestration on Bare-Metal Linux Servers

Docker & Kubernetes on Bare-Metal Linux Servers technical architecture and dedicated infrastructure diagram
Verified Answer

Deploying Docker and Kubernetes directly on bare-metal Linux servers eliminates hypervisor CPU overhead, noisy-neighbor I/O contention, and cloud NAT gateway fees. Production clusters pair containerd with kubeadm or K3s, Cilium eBPF networking with MetalLB for bare-metal LoadBalancer IPs, and Rook-Ceph or OpenEBS for local NVMe persistent storage.

Managed cloud Kubernetes services simplify control-plane setup, but they introduce steep per-node management fees, virtualized disk throttling, and unpredictable egress charges as workloads scale. Running Docker and Kubernetes directly on bare-metal Linux hardware gives platform teams direct access to physical CPU cores, NUMA topology, and multi-gigabit NICs. Designing a resilient bare-metal cluster requires solving three infrastructure layers that cloud providers normally abstract away: container runtime tuning, Layer 2/BGP load balancing, and distributed NVMe persistence.

Zero Hypervisor Tax

Reclaims 10–18% CPU and memory overhead lost to nested virtualization layers.

Native NVMe Throughput

Delivers sub-millisecond etcd fsync latency and raw PCIe Gen4 storage IOPS.

Predictable Networking

BGP and eBPF CNI plugins route pod traffic at wire speed without cloud NAT bottlenecks.

Bare-Metal Kubernetes vs. Cloud-Managed Clusters

Before committing to physical hardware, engineering teams should weigh raw hardware economics against operational responsibility. On bare metal, you own kernel upgrades, hardware RAID or ZFS health, and BGP peering—tasks handled by AWS or GCP in managed offerings. However, for stateful databases, AI inference, CI/CD runners, and high-throughput microservices, the performance-per-dollar advantage of dedicated bare-metal servers is substantial.

Architecture Layer Bare-Metal Linux Cluster Managed Cloud Kubernetes
Compute Isolation Physical cores, NUMA pinning Shared vCPU hypervisor slices
Storage I/O Direct PCIe NVMe + Rook-Ceph Network-attached block volumes (EBS)
LoadBalancer IPs MetalLB (L2/BGP) or Cilium LB Cloud NLB/ALB (per-hour + LCU fees)
Bandwidth Cost High unmetered / flat TB pools \$0.05–\$0.09/GB egress + cross-AZ fees
Control Plane HA kube-vip / HAProxy across 3+ nodes Provider-managed SLA

Container Runtime Choices: Docker Engine vs. containerd

Kubernetes removed the legacy dockershim in v1.24, meaning production clusters talk directly to containerd or CRI-O over the Container Runtime Interface (CRI). That does not mean Docker is obsolete on bare metal: developers still rely on Docker Engine and Docker Compose for single-node microservices, local image builds, and CI runners.

On dedicated Kubernetes nodes, install containerd with SystemdCgroup = true enabled in /etc/containerd/config.toml. Matching the cgroup driver between kubelet and containerd prevents out-of-memory killer races and ensures accurate CPU quota enforcement under cgroups v2. When building custom images on the same host, use rootless BuildKit or Kaniko inside isolated runner pods rather than mounting the host Docker socket (/var/run/docker.sock), which effectively grants root-equivalent privileges to any compromised CI job.

Preparing Linux Kernel Parameters and Bootstrapping kubeadm

Every bare-metal node requires swap disabled, br_netfilter and overlay kernel modules loaded, and IPv4 forwarding enabled before cluster initialization. For three-node high-availability control planes, place kube-vip as a static pod to advertise a virtual control-plane IP via ARP or BGP.

PuTTY / Linux Terminal (bash)

# 1. Disable swap and configure kernel modules for Kubernetes networking
swapoff -a && sed -i '/ swap / s/^/#/' /etc/fstab
cat <<EOF | tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
modprobe overlay && modprobe br_netfilter

# 2. Enable bridged packet filtering and IP forwarding
cat <<EOF | tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF
sysctl --system

# 3. Initialize the control plane with a dedicated pod CIDR
kubeadm init --pod-network-cidr=10.244.0.0/16 --control-plane-endpoint="10.10.0.100:6443" --upload-certs

Solving Bare-Metal Networking with Cilium and MetalLB

Without a cloud controller manager, Kubernetes Service objects of type LoadBalancer remain in a perpetual Pending state. Pairing Cilium (an eBPF-based CNI that replaces kube-proxy iptables chains with kernel-level hash maps) and MetalLB solves external ingress cleanly.

In Layer 2 mode, MetalLB responds to ARP requests for a reserved subnet of public or private IPs on your VLAN. While L2 mode is fast to configure on a single rack, all traffic for a given LoadBalancer IP funnels through one elected speaker node before kube-proxy or Cilium forwards packets to destination pods. In BGP mode, each worker node peers directly with your top-of-rack or datacenter router to distribute traffic via Equal-Cost Multi-Path (ECMP) routing, eliminating single-node ingress bottlenecks and preserving client source IP addresses when externalTrafficPolicy: Local is set.

For north-south HTTP/HTTPS routing, deploy Ingress-Nginx or Cilium Gateway API behind your MetalLB IP pool and pair it with cert-manager to automate Let’s Encrypt TLS certificate issuance and renewal across cluster services.

Persistent NVMe Storage: Local Path vs. Rook-Ceph

Stateless pods scale effortlessly, but PostgreSQL, Kafka, and Prometheus require durable storage. For single-node or replicated-at-application-level databases, OpenEBS LocalPV or Rancher’s local-path-provisioner exposes raw NVMe namespaces with near-zero latency overhead. When pods must reschedule across nodes without losing state, deploy Rook-Ceph across dedicated raw NVMe drives on at least three worker nodes with a dedicated 10 Gbps or 25 Gbps storage VLAN.

Separate your Ceph public network from your cluster replication network whenever your hardware includes dual 10G/25G NICs. This prevents heavy OSD recovery or snapshot backfills from saturating the primary interface used by kubelet health probes and application APIs. Always monitor SMART wear levels and NVMe temperatures via node_exporter and Prometheus Alertmanager so failing drives are drained before quorum degrades.

Observability, Upgrades, and Day-2 Bare-Metal Operations

Running bare-metal clusters in production requires disciplined Day-2 automation. Use kube-prometheus-stack to scrape hardware metrics, container cgroup throttling, and etcd fsync durations into Grafana dashboards. For cluster upgrades, drain one node at a time with kubectl drain --ignore-daemonsets --delete-emptydir-data, upgrade kubeadm, kubelet, and kubectl sequentially across minor versions, and take automated etcdctl snapshot save backups to off-server object storage prior to every control-plane change.

NUMA Pinning, CPU Manager and HugePages on Bare-Metal Nodes

Unlike virtualized cloud instances that hide physical socket topology, bare-metal dual-socket AMD EPYC and Intel Xeon servers expose multiple NUMA (Non-Uniform Memory Access) domains. When Kubernetes schedules a latency-sensitive PostgreSQL, Redis, or AI inference pod without topology awareness, threads on Socket 0 frequently read memory attached to Socket 1 across the inter-socket bus—adding 40–80% tail latency under heavy load.

Configure kubelet with cpuManagerPolicy: static and topologyManagerPolicy: single-numa-node, reserve cores for the OS and kubelet via reservedSystemCPUs, and assign Pods the Guaranteed QoS class (exact integer CPU requests equal to limits). For memory-intensive databases, pre-allocate 2 MiB or 1 GiB Linux HugePages on the bare-metal host so pods minimize TLB cache misses.

/etc/sysctl.d/99-tuning.conf

# 1. Pre-allocate 2 MiB HugePages on bare-metal worker nodes (/etc/sysctl.d/90-hugepages.conf)
vm.nr_hugepages = 4096

# 2. Excerpt from /var/lib/kubelet/config.yaml for deterministic core pinning
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cpuManagerPolicy: static
topologyManagerPolicy: single-numa-node
reservedSystemCPUs: "0-3"
memoryManagerPolicy: Static

Remember to inspect physical PCIe slot locality with lstopo (hwloc) so high-throughput NVMe drives and 25G NICs sit on the same NUMA node as the pods consuming them.

Cilium eBPF DSR and BGP ECMP Packet Path Architecture

Traditional Kubernetes kube-proxy evaluates sequential iptables rules in O(N) time, adding measurable CPU overhead once clusters exceed a few thousand Services. Replacing kube-proxy with Cilium in kubeProxyReplacement=true mode moves Service load balancing into kernel eBPF hash maps with O(1) lookup complexity and native XDP packet acceleration.

Bare-Metal Ingress Mode Client Source IP Preserved Return Traffic Path Throughput Ceiling
MetalLB L2 (ARP/NDP) Only with externalTrafficPolicy: Local Hairpins through single elected speaker node Limited to 1 node NIC
MetalLB / Cilium BGP (SNAT) No (NATed to node IP) Returns via ingress node Scales across nodes via ECMP
Cilium BGP + eBPF DSR Yes (end-to-end client IP) Direct Server Return straight from pod host Full cluster aggregate NIC speed

Enabling Cilium Direct Server Return (DSR) over BGP ECMP eliminates cross-node return hops entirely: the backend worker node replies straight to the external router while preserving the client’s real source IP for WAF rate-limiting and audit logs.

etcd Raft Isolation and Bare-Metal Disaster Recovery

On converged bare-metal nodes where control-plane daemons share hardware with CI builds or container registry pulls, heavy disk writes can stall etcd Raft heartbeats and trigger cascading leader re-elections. Always dedicate a separate NVMe namespace or partition to /var/lib/etcd, set ionice -c 1 -n 0 priority on the etcd static pod/unit, and alert if Prometheus etcd_disk_wal_fsync_duration_seconds p99 crosses 10 milliseconds.

Automate hourly encrypted etcdctl snapshot save uploads to off-rack S3-compatible storage alongside Velero/Restic persistent volume backups, and test full quorum restoration onto a clean node quarterly so bare-metal hardware failures remain routine operational events rather than outages.

PuTTY / Linux Terminal (bash)

# 1. Install Cilium eBPF CNI replacing kube-proxy with Direct Server Return (DSR)
helm install cilium cilium/cilium --namespace kube-system \
  --set kubeProxyReplacement=true \
  --set loadBalancer.mode=dsr \
  --set bgpControlPlane.enabled=true \
  --set k8sServiceHost=10.10.0.100 \
  --set k8sServicePort=6443

# 2. Take a point-in-time etcd snapshot before control-plane upgrades
ETCDCTL_API=3 etcdctl snapshot save /var/backups/etcd-$(date +%F-%H%M).db \
  --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

Kubelet Eviction Thresholds & System Reservation

Unlike managed cloud nodes pre-configured by the provider, bare-metal Linux servers will kernel-OOM-kill containerd or kubelet if runaway pods consume 100% of host RAM. Explicitly set systemReserved (memory: 2Gi), kubeReserved (memory: 2Gi), and evictionHard (memory.available<1Gi, nodefs.available<10%) so kubelet gracefully evicts BestEffort pods long before the physical host locks up.

Frequently Asked Questions on Bare-Metal Container Orchestration

Should I use kubeadm, K3s, or Talos Linux on bare metal?
Use kubeadm for standard upstream Kubernetes on Ubuntu or AlmaLinux, K3s for lightweight edge or small 3-node clusters, and Talos Linux when you want an immutable, API-driven OS with zero SSH surface.
Can I run Docker Compose alongside Kubernetes on the same server?
It is technically possible because containerd can run independently of Docker Engine, but mixing unmanaged Docker containers with kubelet cgroup reservations risks memory contention in production.
How many servers are needed for a high-availability bare-metal cluster?
A minimum of three physical nodes is required to maintain an odd-numbered etcd quorum if one node goes offline, with separate worker nodes recommended for heavy workloads.
Why does etcd performance matter so much on bare metal?
etcd writes every cluster state change synchronously to disk; slow SATA drives cause leader election timeouts, whereas dedicated NVMe SSDs keep fsync latency under 2 milliseconds.
How does MetalLB expose Kubernetes LoadBalancer services on bare metal without a cloud provider?
MetalLB assigns real routable IPs from a configured L2 (ARP/NDP) or BGP address pool to Kubernetes LoadBalancer services, eliminating the need for cloud-provider load balancers or awkward NodePort workarounds.
What Linux sysctl settings are mandatory before running kubeadm on bare metal?
Disable swap (swapoff -a), load the overlay and br_netfilter kernel modules, and enable net.bridge.bridge-nf-call-iptables=1 and net.ipv4.ip_forward=1 so pod and service traffic routes cleanly.
Docker & Kubernetes Container Orchestration on Bare-Metal

Applying the bare-metal kubernetes vs cloud-managed clusters principles covered above helps prevent resource bottlenecks and configuration drift in production. Review our Linux web hosting plans to match CPU, NVMe I/O, and network capacity to your workload.