To create Kubernetes clusters, developers use the leading open-source platform for container orchestration. Kubernetes automates the deployment, scaling, and management of containerized applications, ensuring high availability and efficient resource usage across distributed server environments.

In this article, we’ll walk through the process of setting up Kubernetes on a Linux server. We’ll cover prerequisites, installation steps, configuration options, managing Kubernetes services, applying security measures, and addressing common issues you may encounter during deployment.
Prerequisites
Before you begin installing Kubernetes, you need to make sure your Linux server environment is properly prepared. Meeting these requirements helps avoid installation errors.
- A Linux server (Ubuntu, Debian, CentOS, Fedora, or RHEL recommended)
- At least 2 CPUs and 2 GB RAM (production systems should use more)
- A non-root user with
sudo
privileges - Stable internet connection to download packages and container images
swap
disabled on the system (Kubernetes doesn’t support swap)- Docker or another container runtime pre-installed
Disabling swap can be done using:
sudo swapoff -a
And to make it permanent, comment out the swap entry in /etc/fstab
.
Install Kubernetes on Linux
Now let’s go through the steps required to install Kubernetes on your Linux server.
- Updating the System
Update the package manager to ensure you’re working with the latest system libraries.
sudo apt update && sudo apt upgrade -y # Ubuntu/Debian
sudo yum update -y # CentOS/RHEL
- Installing Dependencies
Install required utilities such as apt-transport-https
, curl
, and software-properties-common
.
sudo apt install -y apt-transport-https ca-certificates curl
- Adding Kubernetes Repository
Add the official Kubernetes package repository to your system.
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo add-apt-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
For CentOS/RHEL:
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
Installing Kubernetes Components
Install the three core components: kubeadm
, kubelet
, and kubectl
.
sudo apt install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
For CentOS/RHEL:
sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
- Starting Kubernetes Services
Enable and start the kubelet service.
sudo systemctl enable kubelet
sudo systemctl start kubelet
At this point, Kubernetes is installed but not yet configured.
Configuring Kubernetes on Linux
After installation, Kubernetes needs to be configured to initialize a cluster and allow workloads to run.
- Initializing the Master Node
On your primary server, run:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
This command initializes your cluster. At the end, it provides a kubeadm join
command — save it for connecting worker nodes.
- Setting up kubectl Access
To manage the cluster, configure your user to use kubectl
.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
- Deploying a Pod Network Add-on
Kubernetes requires a network plugin for pods to communicate. A common choice is Flannel:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
- Joining Worker Nodes
On each worker node, run the kubeadm join
command that was generated during kubeadm init
. This connects them to the master node.
Securing Kubernetes on Linux
Security should be a priority when deploying Kubernetes clusters.
- Role-Based Access Control (RBAC): Limit permissions for users and services.
- Network Policies: Define how pods can communicate with each other.
- Pod Security Policies: Restrict privileged containers and enforce best practices.
- TLS Encryption: Ensure all communication between cluster components is encrypted.
- Regular Updates: Keep Kubernetes, kubelet, and container runtime patched.
By enforcing these practices, you reduce the risk of vulnerabilities and unauthorized access.
Managing Kubernetes Services on Linux
Once Kubernetes is running, you’ll need to manage it effectively. Here are some key commands:
- Check Cluster Nodes
kubectl get nodes
- View All Pods
kubectl get pods --all-namespaces
- Check System Services
systemctl status kubelet
- Restart the kubelet Service
sudo systemctl restart kubelet
- View Cluster Info
kubectl cluster-info
These commands help you monitor the health and status of your Kubernetes environment.
Common Issues and Fixes
When setting up Kubernetes, you may face some common challenges. Let’s look at a few and their fixes.
- Swap is enabled
- Kubernetes won’t work with swap enabled. Run
swapoff -a
and remove swap from/etc/fstab
.
- Kubernetes won’t work with swap enabled. Run
- kubeadm init fails
- Ensure your server has enough RAM and CPU.
- Check firewall settings and disable conflicting services.
- The worker node can’t join
- Verify the join token hasn’t expired.
- Regenerate using:
kubeadm token create --print-join-command
- Pods stuck in the Pending state
- Likely a network plugin issue. Reinstall Flannel or another CNI plugin.
By knowing these fixes, you can quickly resolve most problems and stabilize your Kubernetes environment.
FAQs: Create Kubernetes on Linux Server
How do I create Kubernetes on a Linux server?
To create Kubernetes on a Linux server, install a container runtime (like Docker or containerd), set up kubeadm, configure nodes, and initialize the cluster. Once done, you can deploy and manage containerized applications easily.
What are the prerequisites to create Kubernetes on Linux?
Before creating Kubernetes, ensure you have a 64-bit Linux system, at least 2 GB RAM, multiple nodes (for clusters), and installed tools like kubeadm, kubectl, and kubelet to manage the setup properly.
How can I secure Kubernetes on a Linux server?
To secure Kubernetes, use role-based access control (RBAC), enable network policies, apply regular updates, and restrict root access. Monitoring clusters and using secrets management ensures a safer and more reliable Kubernetes environment.
Conclusion
Kubernetes is a powerful tool for managing containerized applications at scale, and Linux servers provide the ideal environment for running it. In this guide, we walked through preparing your system, installing Kubernetes components, initializing the cluster, configuring networking, applying security best practices, managing services, and resolving common issues.
By following these steps, you can successfully create Kubernetes on a Linux server and build a secure, production-ready container orchestration platform that supports scalable, resilient, and efficient workloads. For more, visit the official Kubernetes documentation.