🎉Celebrating 25 Years of Tech Excellence and Trust - Learn More

DevOps
Updated: Sep 21, 2024

How to Install Kubernetes on Different Operating Systems?

Verified
Verified Expert in Engineering
Akash Kareliya works as a Application Evaluator at Radixweb. He holds 7 years of experience in intuitive frameworks and cloud technologies.
Kubernetes Installation Guide

Quick Summary: Kubernetes, known as 'K8s or kube,' is an open-source container orchestration platform that helps deploy, scale, and manage apps. In this blog, you'll learn how to install Kubernetes on different operating systems. Enjoy your read!

Installing Kubernetes…wait…wait!

Let's just start this blog with some facts about Kubernetes. As per Statista report, Kubernetes is the leading container orchestration platform, and 60% of organizations have already accepted it in 2022. But why is Kubernetes gaining such popularity? Why are companies opting for Kubernetes installation increasingly?

So, for companies that function at a large scale, using a single Linux container instance isn't sufficient. Specific complex applications need multiple Linux containers that can easily collaborate. Therefore, this architecture came with a new scaling issue. Here, Kubernetes - a container orchestration system — came into action. Kubernetes, aka 'K8s or Kube,' is an open-source container orchestration platform that helps manage, scale, and implement apps. The Kube automates the management and implementation of cloud-native applications utilizing public cloud platforms and on-premises infrastructure.

Kubernetes installation helps in application workload distribution throughout the Kubernetes cluster setup and automates different requirements of dynamic container networking. You can think of it as a sort of meta-process that can simultaneously automate the implementation and scaling of multiple containers. Hence, for understanding Kubernetes, you need to realize that a complete app may consist of multiple containers, all requiring functioning together in specific ways. So, when you install Kubernetes, you experience software that shifts a collection of virtual or physical hosts (servers) into a particular platform that:

  • Helps host containerized workloads, offering storage, network, and compute resources
  • Automatically maintains multiple containerized apps – taking care of the system’s health

Now, you know what Kubernetes is. So, further we'll discuss the Kubernetes installation process for different operating systems. However, before diving into – how to install Kubernetes? – let’s look at some essential aspects of Kubernetes.

Why wait, then? Let's get the Kubernetes installation done.

Streamline App Deployment and Manage Containerized Workflow with Our Kubernetes Services

Consult Us Now
On This Page
  1. Features of Kubernetes
  2. Advantages of Kubernetes
  3. What is Kubectl?
  4. What is Minikube?
  5. How to Install Kubernetes on Ubuntu?
  6. How to Install Kubernetes on Windows?
  7. How to Install Kubernetes on Mac?
  8. Summing Up!

Features of Kubernetes

When thinking to install Kubernetes, remember it comes with several features (that you'll love) that help orchestrate multiple containers across different hosts, enhance resource utilization with higher use of infrastructure, and automate the management of other K8s clusters. Some of the essential features of Kubernetes include:

Features of Kubernetes

  • Auto-Scaling - Automatically helps scale the containerized apps up and down to fit the changing needs based on its usage, and also with the help of DevOps services.

  • Lifecycle Management - It helps automate the implementations and updations with the ability to roll back to previous versions and pause and continue a deployment.

  • Declarative Model - You just need to declare the desired state, and Kubernetes will function in the background to manage that state and recover from any failures.

  • Robust and Self-Healing - Kubernetes is a powerful platform that enables auto restart, auto-scaling, auto replication, and auto-placement, helping the application self-heal.

  • Consistent Storage - K8s go up and add dynamic storage.

  • Load Balancing - Kubernetes supports various external and internal load balancing options to address diverse needs and requirements.

  • DevSecOps Support - Heard about DevSecOps? It is an advanced security approach that automates and aligns different container functionalities across clouds, integrates other security options throughout the container lifecycle, and allows teams to deliver high-quality, secure software solutions more quickly. In simple terms, Kubernetes is one of the best DevOps tools for container management, and combining it with DevSecOps enhances the developer efficiency and overall security of the software.

Let's now move ahead and discuss some of the best advantages of Kubernetes.

Advantages of Kubernetes

The Kubernetes platform is getting a lot more popular, and companies are opting for Kubernetes installation as it offers a plethora of essential advantages, including:

Kubernetes Benefits

  • Scalability - Cloud native applications are known for their horizontal scaling. Kubernetes uses auto-scaling, which spins up the additional container instances and automatically scales in response to your demand.

  • Portability - Containers are portable throughout different environments, from virtual environments to plain metal. Kubernetes support all major public clouds. You can execute containerized apps on K8s across several different settings.

  • Affordable - K8s automated scaling, flexibility, and inherent resource optimization to execute workloads where they offer the most valuable means that enables keep the IT expenses under control.

  • Simplified CI/CD - CI/CD is a critical DevOps practice that helps automate the creation, testing, and implementation of apps in production environments. Companies often hire DevOps experts proficient in integrating CI/CD and Kubernetes to build scalable CI/CD pipelines that load dynamically.

  • API-based - REST is the actual fabric of Kubernetes. Moreover, you can control everything in the Kubernetes environment with the help of programming.

Kubernetes consists of two primary versions – a production environment and a learning environment. Before directly diving into installing Kubernetes, it’s essential to understand the tools (Minikube and Kubectl) used to deploy these environments. Let’s get a better understanding of these tools.

What is Kubectl?

Kubectl is a command-line tool for Kubernetes that enables developers to run commands on the Kubernetes cluster setup. You can install Kubectl to deploy apps, check and handle different cluster resources, and view logs. In this blog, I'm going to use Kubectl to install Kubernetes. And don't worry, you'll also learn to install Kubectl.

What is Minikube?

Minikube is an efficient tool that enables developers to execute Kubernetes cluster setup locally through a virtual machine. It lets you run a single-node Kubernetes cluster on your system to examine Kubernetes or other significant development work. And to install Minikube, you can visit - how to install Minikube?

Want to Hire a High-Momentum Team Delivering the Best Kubernetes Deployment Solution?

Hire Best Kubernetes Services

That was all about the significant aspects of Kubernetes. Congratulations! We've reached the core part of our Kubernetes installation guide. So, be ready to learn – how to install Kubernetes on different operating systems. I'll try to make the installation part as smooth as I can.

Talking about different operating systems, firstly, we'll be learning - how to install Kubernetes on Ubuntu?

How to Install Kubernetes on Ubuntu?

Wondering how to install Kubernetes on Ubuntu? As Ubuntu is a Linux distribution, we can also rephrase the question into – how to install Kubernetes on Linux. So, to begin with, Kubernetes installation on Ubuntu, you first need to install Kubectl and Docker.

Okay, you need to install Kubectl for apparent reasons, but why Docker? As there's always a debate going on between Kubernetes vs Docker.

Let me clarify that developers use Docker as a software platform to build containerized apps. On the other hand, installing K8s helps automate the process of operating cloud-native, containerized apps built with Docker or other tools. Therefore, Docker and Kubernetes often go hand in hand.

Important Note: Steps in this Kubernetes installation tutorial can also be easily applied to newer Ubuntu versions.

Let's now set up Docker!

Kubernetes needs an existing Docker installation. Install and enable Docker on each server node by the following steps:

Step 1: Update the package list:

sudo apt update

Step 2: Next, install Docker with the command:

sudo apt install docker.io –y

Install Docker

Step 3: Set Docker to launch on boot by entering the following:

sudo systemctl enable docker

Step 4: Verify Docker is running:

sudo systemctl status docker

Check If Docker is Running

Step 5: Start Docker if it is not running:

sudo systemctl start docker

Install Kubernetes! Follow the steps.

Step 1: Add Kubernetes Signing Key

Since you want to download Kubernetes from a non-standard repository, it is essential to ensure that the software is authentic. This is done by adding a signing key.

On each node, use the curl command to download the key, then store it in a safe place (default is /usr/share/keyrings):

curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo tee /usr/share/keyrings/kubernetes.gpg

Step 2: Add Software Repositories

Kubernetes is not included in the default repositories. To add the Kubernetes repository to your list, enter the following on each node:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/kubernetes.gpg] http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list

Step 3: Kubernetes Installation Tools

Kubeadm (Kubernetes Admin) tool helps initialize a cluster. It fast-tracks Kubernetes cluster setup by using community-sourced best practices. So, install Kubectl, Kubelet, and Kubeadm. Execute the following commands on each server node.

1. Install Kubernetes tools with the command:

sudo apt install kubeadm kubelet Kubectl

Kubeadm Tool

sudo apt-mark hold kubeadm kubelet kubectl

Kubelet Kubectl

Allow the process to complete.

2. Verify the installation with:

kubeadm version

Kubeadm Version

Important Note: Always take care that you install the same version of each package on each machine. Why? Because different versions can create instability. Also, this process prevents apps from automatically updating Kubernetes. And to take care of these things, you can always rely on Kubernetes consulting.

Step 4: Prepare for Kubernetes Deployment

This section shows how to prepare the servers for a Kubernetes configuration and deployment. Execute the following steps on each server node:

1. Disable the swap memory. To perform this action, execute swapoff:

sudo swapoff -a

Then type the sed command below:

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

2. Load the required containerd modules. Start by opening the configuration file for containerd in a text editor:

sudo nano /etc/modules-load.d/containerd.conf

3. Add the following two lines:

overlay

br_netfilter

Container Overlay

4. Next, use the modprobe command to add the modules:

sudo modprobe overlay

sudo modprobe br_netfilter

5. For Kubernetes configuration, configure Kubernetes networking. Open the kubernetes.conf file:

sudo nano /etc/sysctl.d/kubernetes.conf

6. Add the following lines:

net.bridge.bridge-nf-call-ip6tables = 1

net.bridge.bridge-nf-call-iptables = 1

net.ipv4.ip_forward = 1

Kubernetes Installation Code Lines

7. Save the file and exit, then reload the configuration by typing:

sudo sysctl --system

Reload the Configuration

Step 5: Assign Unique Hostname for Each Server Node

1. Decide which server to set as the controller node. Then enter the command:

sudo hostnamectl set-hostname master-node

2. Next, set a worker node hostname by entering the following on the worker server:

sudo hostnamectl set-hostname worker01

If you have additional worker nodes, use this process to set a unique hostname on each.

3. Edit the host file on each node by adding the IP address and hostname of the servers you want to add to the cluster.

Worker Nodes

Step 6: Initialize Kubernetes on Controller Node

Switch to the master node, and follow the steps to initialize Kubernetes on it:

1. Open the kubelet file in a text editor.

sudo nano /etc/default/kubelet

2. Add the following line to the file:

KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"

Save and exit the file.

3. Execute the following commands to reload the configuration:

systemctl daemon-reload

Reload the Command Configuration

systemctl restart kubelet

4. Open the Docker daemon configuration file:

sudo nano /etc/docker/daemon.json

5. Append the following Kubernetes configuration block:

{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file,"
"log-opts": {
"max-size": "100m"
},

"storage-driver": "overlay2"
}

Kubernetes configuration block

Save the file and exit.

6. Reload the configuration:

systemctl daemon-reload

systemctl restart docker

7. Open the kubeadm configuration file:

sudo nano /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

8. Add the line below to the file:

Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"

kubeadm configuration

Save the file and exit.

9. Reload the kubelet:

systemctl daemon-reload

systemctl restart kubelet

10. Initialize the cluster by typing:

sudo kubeadm init --control-plane-endpoint=[master-hostname] --upload-certs

Once this command finishes, it will display a kubeadm join message. Note the whole entry. This will be used to join the worker nodes to the cluster.

kubeadm join message

11. Enter the following to create a directory for the Kubernetes cluster:

mkdir -p $HOME/.kube

sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

sudo chown $(id -u):$(id -g) $HOME/.kube/config

Step 7: Deploy Pod Network to Cluster

A Pod Network is a way to allow communication between different nodes in the cluster. This Kubernetes installation tutorial will use the Flannel node network manager to create a pod network.

1. Use kubectl to install Flannel:

kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

2. Untaint the node:

kubectl taint nodes --all node-role.kubernetes.io/control-plane-

Step 8: Join Worker Node to Cluster

As indicated in Step 6, you can enter the kubeadm join command on worker nodes to connect them to the master node. Repeat the steps on each worker node you want to add to the cluster.

1. Execute the following commands to turn off apparmor:

systemctl stop apparmor

sudo systemctl turn off apparmor

systemctl restart containerd.service

2. Enter the command you noted in Step 6:

kubeadm join [master-node-ip]:6443 --token abcdef.1234567890abcdef --discovery-token-ca-cert-hash sha256:1234..cdef

Cluster Joining Message

Replace the alphanumeric codes with those from your master server. Repeat for each worker node on the cluster. Wait a few minutes, then you can check the status of the nodes.

3. Switch to the master server, and enter:

kubectl get nodes

Replace the alphanumeric codes

The system should display the worker nodes that you joined to the cluster.

Now, you can quickly answer how to install Kubernetes on Ubuntu.

Opt for Best DevOps Containerization Services and Build Efficient and Robust Software

Get in Touch

So, let's move ahead and learn - how to install Kubernetes on Windows 10?

How to Install Kubernetes on Windows?

Another significant question is how to install Kubernetes on Windows 10 (or other Windows versions).

So, to begin Kubernetes installation on Windows, we first need to install Kubectl, and the whole Kubernetes installation part will be based on that. Here, we'll install Kubectl binary with Curl on Windows.

Step 1: Download the latest 1.27 Kubectl patch release - kubectl 1.27.2

Or if you have curl installed, use this command:

curl.exe -LO "https://dl.k8s.io/release/v1.27.2/bin/windows/amd64/kubectl.exe"

Note: To find out the latest stable version, look at https://dl.k8s.io/release/stable.txt.

Step 2: Validate the binary (its optional, though)

Download the kubectl checksum file:

curl.exe -LO "https://dl.k8s.io/v1.27.2/bin/windows/amd64/kubectl.exe.sha256"

Validate the kubectl binary against the checksum file:

  • Using Command Prompt to compare CertUtil's output to the checksum file downloaded manually:
CertUtil -hashfile kubectl.exe SHA256

type kubectl.exe.sha256

  • Using PowerShell to automate the verification using the -eq operator to get a True or False result:
$(Get-FileHash -Algorithm SHA256 .\kubectl.exe).Hash -eq $(Get-Content .\kubectl.exe.sha256)

Step 3: Append or prepend the kubectl binary folder to your PATH environment variable

Step 4: Test to ensure the version of kubectl is the same as downloaded:

kubectl version --client

Note: The above command will generate a warning:

WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.

So, ignore this warning. You are only checking the version of kubectl that you have installed.

Or use this for a detailed view of the version:

kubectl version --client --output=yaml

Important Note: Always remember that Docker Desktop for Windows adds its kubectl version to PATH. If you have installed Docker Desktop prior, you require to place your PATH entry before the one added by the Docker Desktop installer or remove the Docker Desktop's kubectl.

And to verify Kubernetes configuration on Windows, you need to verify Kubectl configuration.

For kubectl to find and access a Kubernetes cluster, it requires a kubeconfig file, which is built automatically when you create a cluster using kube-up.sh or successfully deploy or install Minikube cluster. The kubectl configuration is at ~/.kube/config by default.

Step 5: Check that kubectl is configured correctly by getting the cluster state:

kubectl cluster-info

If you see a URL response, kubectl is correctly configured to access your cluster. However, if you see a similar message, kubectl is not configured correctly or cannot connect to a Kubernetes cluster setup.

The connection to the server <server-name:port> was refused - did you specify the right host or port?

For example, if you intend to run a Kubernetes cluster setup on your local laptop or computer system, you must install the Minikube tool first and re-run the above commands.

Step 6: If kubectl cluster-info returns the url response, but you can't access your cluster, to check whether it is configured properly, use:

kubectl cluster-info dump

I'm sure you can easily install Kubernetes on Windows with the help of these six steps. I know it can get a bit overwhelming, but doing it practically will help ease the Kubernetes installation process.

Moving forward, another critical question with another important operating system – how to install Kubernetes on Mac?

How to Install Kubernetes on Mac?

Same as Ubuntu and Windows, to install Kubernetes, it's imperative to install Kubectl. And to our surprise, there are multiple methods to install Kubectl on Mac. Here, I'm going to talk about two most important ways, that are:

  • Install Kubectl Binary with curl on Mac
  • Install with Homebrew on Mac

Step 1: Install Kubectl Binary with curl

And to download the latest release, follow the command:

Intel –

curl -LO "<https://dl.k8s.io/release/>$(curl -L -s <https://dl.k8s.io/release/stable.txt>)/bin/darwin/amd64/kubectl"

Apple Silicon -

curl -LO "<https://dl.k8s.io/release/>$(curl -L -s <https://dl.k8s.io/release/stable.txt>)/bin/darwin/arm64/kubectl"

Note: To download a specific version, replace the version with the command's

$(curl -L -s https://dl.k8s.io/release/stable.txt)

portion. For example, to download version 1.27.2 on Intel macOS, type:

curl -LO "https://dl.k8s.io/release/v1.27.2/bin/darwin/amd64/kubectl"

And for macOS on Apple Silicon, type:

curl -LO "https://dl.k8s.io/release/v1.27.2/bin/darwin/arm64/kubectl"

Step 2: Validate the binary (optional)

Download the kubectl checksum file:

Intel -

curl -LO "<https://dl.k8s.io/release/>$(curl -L -s <https://dl.k8s.io/release/stable.txt>)/bin/darwin/amd64/kubectl.sha256"

Apple Silicon -

curl -LO "<https://dl.k8s.io/release/>$(curl -L -s <https://dl.k8s.io/release/stable.txt>)/bin/darwin/arm64/kubectl.sha256"

Validate the kubectl binary against the checksum file:

echo "$(cat kubectl.sha256) kubectl" | shasum -a 256 --check

If valid, the output is:

kubectl: OK

If the check fails, shasum exits with nonzero status and prints output like:

kubectl: FAILED

shasum: WARNING: 1 computed checksum did NOT match

Remember to download the same version of checksum and binary.

Step 3: Make the kubectl binary executable

chmod +x ./Kubectl

Step 4: Move the Kubectl binary to a file location on your system PATH

sudo mv ./kubectl /usr/local/bin/kubectl
sudo chown root: /usr/local/bin/Kubectl

Note: Ensure/usr/local/bin is in your PATH environment variable.

Test to ensure the version you installed is up to date:

kubectl version –client

Note: The above command will generate a warning:

WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.

You can ignore this warning because you only need to check the version of kubectl that you have installed.

Or use this for a detailed view of the version:

kubectl version --client --output=yaml

Step 6: After installing the plugin, clean up the installation files:

rm kubectl kubectl.sha256

OR

Step 1: Install with Homebrew on macOS

If you are on Mac and using Homebrew package manager, you can install kubectl with Homebrew.

Run the installation command:

brew install kubectl

or

brew install kubernetes-cli

Step 2: Test to ensure the version you installed is up to date

kubectl version --client

Kubernetes Configuration for Mac

So, for Kubernetes configuration, it's essential to configure Kubectl. So, for kubectl to find and access a Kubernetes cluster, it needs a kubeconfig file, which is developed automatically when you build a cluster using kube-up.sh or successfully install a Minikube cluster. The kubectl configuration is at ~/.kube/config by default.

Step 1: Check that kubectl is correctly configured by getting the cluster state:

kubectl cluster-info

If you see a URL response, kubectl is correctly configured to access your cluster.

If you see a similar message, kubectl is not configured correctly or cannot connect to a Kubernetes cluster.

The connection to the server <server-name:port> was refused - did you specify the right host or port?

For example, if you intend to run a Kubernetes cluster on your laptop (locally), you will need to install the Minikube tool first and then re-run the commands above.

Step 2: If kubectl cluster-info returns the URL response, but you can't access your cluster, to check whether it is configured properly, use:

kubectl cluster-info dump

So, that was the most straightforward answer to the question – how to install Kubernetes on Mac?

Summing Up!he Kubernetes installation landscape can be a little daunting. But no worries, we've got it covered. So, that's all for how to install Kubernetes (on different operating systems)? However, the whole installation process will need some time and patience. Still, once it's done you can start managing and maintaining your applications seamlessly. You'll quickly pull off the installation process if you've thoroughly reviewed how to install Kubernetes on Ubuntu, Windows, and Mac in the above sections.However, there will be times when Kubernetes installation can confuse you. So, what to do, then? Talk to experts.And who are the experts? Say Hello to Radixweb.Radixweb is a trusted software development company that helps streamline app development and manage containerized workflow with its top-notch Kubernetes consulting services. Our experts will help you create a zero-disruption Kubernetes strategy to stay ahead of your competitors. Radixweb's Kubernetes consultants ensure you make the best use of this innovative system, from effortless management of containerized apps and automation of production-level workflows to reduced operational costs and improved productivity. If you plan to adopt and install Kubernetes, aka K8s but lack the required expertise, our Kubernetes consulting and development services are for you.Contact us today to learn more about Kubernetes and its services.

FAQs

What is needed to install Kubernetes?

What is the latest version of Kubernetes?

Do I need to install Docker before Kubernetes?

What are the different ways to install Kubernetes?

Don't Forget to share this post!

Akash Kareliya

Akash Kareliya

Verified
Verified Expert in Engineering
View All Posts

About the Author

Akash Kareliya is a proficient Application Evaluator known for his expertise in Python, Django, Flask, FastAPI, AWS Services, Docker, Kubernetes, and other emerging technologies. His ability to leverage cloud technologies and containerization frameworks allows him to build robust and efficient applications. Akash's dedication to continuous learning and his knack for finding innovative solutions makes him a valuable asset in driving technological advancements at Radixweb.

Radixweb

Radixweb is a product engineering company, driving start-to-end software product development success.

Verticals

OnPrintShopRxWebTezJS
Our Locations
MoroccoRue Saint Savin, Ali residence, la Gironde, Casablanca, Morocco
United States6136 Frisco Square Blvd Suite 400, Frisco, TX 75034 United States
IndiaEkyarth, B/H Nirma University, Chharodi, Ahmedabad – 382481 India
United States17510 Pioneer Boulevard Artesia, California 90701 United States
Canada123 Everhollow street SW, Calgary, Alberta T2Y 0H4, Canada
AustraliaSuite 411, 343 Little Collins St, Melbourne, Vic, 3000 Australia
MoroccoRue Saint Savin, Ali residence, la Gironde, Casablanca, Morocco
United States6136 Frisco Square Blvd Suite 400, Frisco, TX 75034 United States

View More

ClutchDun and BrandStreet

Copyright © 2025 Radixweb. All Rights Reserved. An ISO 27001:2022, ISO 9001:2015 Certified