Answered by the Webhosting Experts

Deploy K8s on Bare Metal in 20 Minutes: Complete Setup Guide

how to deploy kubernetes in bare metalThe buzz around bare metal Kubernetes isn’t just hype—it’s a strategic shift driven by real performance and cost advantages. While cloud platforms simplified initial Kubernetes adoption, many organizations are discovering that running their clusters directly on physical hardware delivers superior performance at a fraction of the cost.

Modern bare metal deployments have evolved far beyond the complex manual configurations of the past. With automated provisioning tools and cloud-native management platforms, you can now deploy production-ready Kubernetes clusters on dedicated hardware faster than ever before.

This guide walks you through deploying Kubernetes on bare metal infrastructure in just 20 minutes, covering everything from initial setup to optimization best practices.

Whether you’re running AI/ML workloads that demand maximum performance or seeking predictable infrastructure costs, bare metal Kubernetes offers compelling advantages worth exploring.

Why Bare Metal?

The move to bare metal isn’t a step backward—it’s a strategic optimization that addresses three critical enterprise needs: performance, cost control, and compliance.

Performance Advantages That Matter

Removing the virtualization layer delivers tangible performance gains that become crucial for demanding workloads.

Benchmarks consistently show bare metal servers delivering 2x faster CPU performance, 3x faster RAM access, and 5x more network bandwidth compared to virtual machines.

For AI/ML teams training deep learning models, these improvements translate directly to faster iteration cycles and reduced training costs.

Klink AI experienced this firsthand when their document processing times dropped from 10 minutes on IBM SoftLayer to seconds after migrating to bare metal Kubernetes—a 10x performance improvement that revolutionized their end-user experience.

Cost Predictability in an Unpredictable Market

With 61% of organizations facing increased cost pressure, the economics of bare metal become compelling.

Ericsson’s comprehensive analysis found that bare metal Kubernetes deployments achieve an 18% reduction in Total Cost of Ownership compared to virtualized environments, primarily by eliminating hypervisor licensing fees and maximizing hardware utilization.

The cost benefits extend beyond raw compute.

Cloud egress fees and unpredictable billing models often create budget surprises, while bare metal providers like Hivelocity offer flat, predictable pricing that includes generous bandwidth allocations.

Klink AI’s infrastructure costs became 5x cheaper after moving away from AWS—a savings that directly improved their bottom line.

Meeting Modern Workload Demands

The explosive growth of AI and edge computing creates new infrastructure requirements that bare metal addresses effectively. With 73% of edge Kubernetes adopters running AI/ML workloads, the demand for low-latency, high-performance compute continues accelerating.

Edge deployments particularly benefit from bare metal’s performance characteristics. Applications requiring real-time inference or data processing near the source need the consistent, predictable performance that only dedicated hardware can provide.

Prerequisites

Before diving into deployment, ensure your environment meets these requirements:

Hardware Requirements:

  • Minimum 3 servers for a production cluster (1 control plane, 2 worker nodes)
  • 4GB RAM minimum per node (8GB+ recommended)
  • 20GB available disk space per node
  • Network connectivity between all nodes
  • Static IP addresses for each node

Software Requirements:

  • AlmaLinux 8+ on all nodes
  • Container runtime (containerd recommended)
  • Root or sudo access on all nodes
  • SSH access configured between nodes

Network Configuration:

  • All nodes must communicate on ports 6443, 2379-2380, 10250-10252
  • Pod network CIDR that doesn’t conflict with node networks
  • Load balancer or external IP for API server access

Step-by-Step Deployment Guide

Step 1: OS Installation and Configuration

Start with a clean AlmaLinux 8+ installation on each node. Disable swap and configure the kernel for Kubernetes:

# Disable swap permanently
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

# Load required kernel modules
cat << EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

sudo modprobe overlay
sudo modprobe br_netfilter

# Configure sysctl parameters
cat << EOF | sudo 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

sudo sysctl --system

Step 2: Container Runtime Installation

Install containerd as the container runtime:

# Update package index and install dependencies
sudo dnf update -y
sudo dnf install -y yum-utils device-mapper-persistent-data lvm2

# Add Docker's official repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# Install containerd
sudo dnf install -y containerd.io

# Configure containerd
sudo mkdir -p /etc/containerd
containerd config default | sudo tee /etc/containerd/config.toml
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl enable containerd

Step 3: Kubernetes Components Installation

Install kubeadm, kubelet, and kubectl on all nodes:

# Add Kubernetes repository
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF

# Install Kubernetes components
sudo dnf install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable kubelet

Step 4: Control Plane Initialization

Initialize the control plane on your designated master node:

# Initialize the cluster
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=<MASTER_IP>

# Configure kubectl for the current user
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

# Save the join command for worker nodes
kubeadm token create --print-join-command > ~/join-command.txt

Step 5: Network Configuration

Deploy Calico for pod networking:

# Install Calico CNI
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/tigera-operator.yaml
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/custom-resources.yaml

# Verify the installation
kubectl get pods -n calico-system

Step 6: Worker Node Joining

On each worker node, run the join command generated earlier:

# Run the join command (replace with your actual command)
sudo kubeadm join <MASTER_IP>:6443 --token <TOKEN> --discovery-token-ca-cert-hash sha256:<HASH>

Step 7: Verification and Testing

Verify your cluster is running correctly:

# Check node status
kubectl get nodes

# Deploy a test application
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=NodePort

# Verify the deployment
kubectl get pods
kubectl get services

By using AlmaLinux, a stable and supported Linux distribution, this guide ensures compatibility and a futureproof approach to deploying Kubernetes on bare metal.

Optimization and Best Practices

Networking Considerations

For production bare metal deployments, implement MetalLB to provide load balancer services:

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml

Configure an IP address pool that matches your network infrastructure to enable external access to services.

Storage Solutions

Implement persistent storage using local volumes or distributed storage like Ceph. For high-performance workloads, local NVMe storage often provides the best performance:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

Security Measures

Harden your cluster with these essential security practices:

  • Enable RBAC with least-privilege access policies
  • Use Pod Security Standards to enforce security contexts
  • Implement network policies to segment traffic
  • Regular security patches and updates
  • Monitor cluster activity with audit logging

Monitoring and Logging

Deploy Prometheus and Grafana for comprehensive cluster monitoring:

# Add Prometheus Helm repository
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

# Install Prometheus stack
helm install prometheus prometheus-community/kube-prometheus-stack

This provides monitoring for both Kubernetes metrics and underlying hardware health—crucial for bare metal deployments where you’re responsible for the full stack.

Troubleshooting Common Issues

Pod Network Issues: If pods can’t communicate, verify your CNI plugin installation and ensure firewall rules allow necessary traffic between nodes.

Node Not Ready: Check kubelet logs with journalctl -u kubelet and ensure all prerequisites are met, particularly around swap being disabled and required kernel modules loaded.

API Server Connectivity: Verify the API server is accessible on port 6443 and that your kubeconfig file points to the correct endpoint.

Resource Constraints: Monitor node resources with kubectl top nodes and ensure adequate CPU and memory are available for your workloads.

Supercharge Your Deployment with Modern Automation

While this manual approach works for learning and small deployments, production environments benefit from automated provisioning.

Modern bare metal cloud providers like Hivelocity eliminate the traditional complexity of physical server management through API-driven deployment and Kubernetes-native automation.

Hivelocity’s Cluster API integration transforms bare metal deployment from a manual process to a declarative, infrastructure-as-code approach.

You can provision entire Kubernetes clusters on dedicated hardware with the same ease as managed cloud services, while maintaining the performance and cost advantages of bare metal.

With over 50 data centers globally and servers deployable in under 20 minutes, platforms like Hivelocity make bare metal Kubernetes accessible without sacrificing automation or scalability.

Their flat pricing model eliminates surprise costs while delivering the predictable performance your AI/ML workloads demand.

Deploy K8s on Bare Metal with Hivelocity Today!

Ready to experience the performance and cost benefits of bare metal Kubernetes without the operational complexity?

Hivelocity’s automated bare metal cloud combines the power of dedicated hardware with cloud-like simplicity.

Start your deployment today and discover why leading AI companies choose bare metal infrastructure for their most demanding workloads.

Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your my.hivelocity.net account and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your my.hivelocity.net account or if you are on the go, please reach out from your valid my.hivelocity.net account email to us here at: support@hivelocity.net. We are also available to you through our phone and live chat system 24/7/365.