---
title: "Master Installing Kubernetes on Ubuntu"
description: "Need to get a Kubernetes cluster set up quickly? Learn how installing Kubernetes on Ubuntu is done with this handy step-by-step tutorial!"
canonical: "https://adamtheautomator.com/installing-kubernetes-on-ubuntu/"
---

# Master Installing Kubernetes on Ubuntu

> Need to get a Kubernetes cluster set up quickly? Learn how installing Kubernetes on Ubuntu is done with this handy step-by-step tutorial!

Source: https://adamtheautomator.com/installing-kubernetes-on-ubuntu/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Master Installing Kubernetes on Ubuntu](https://adamtheautomator.com/wp-content/uploads/2021/06/Step-by-Step-Tutorial-Installing-Kubernetes-on-Ubuntu.jpg)

# Master Installing Kubernetes on Ubuntu

[![](https://secure.gravatar.com/avatar/2beb65fca997135120ed98dc6a2e57dcdf1a7d7d2f5ff687b5d91dc7ccd7a6b5?s=192&d=mm&r=g)Sagar](https://adamtheautomator.com/author/shanky-mendiratta/)29 June 20217 min. read

Categories: [DevOps](/category/devops/)

Tags:[Kubernetes](/tag/kubernetes/)

Table of Contents

*   [Tutorial Prerequisites](#h-tutorial-prerequisites)
*   [Installing Kubernetes on Ubuntu Prerequisites](#h-setting-up-kubernetes-prerequisites)
*   [Installing Kubernetes on the Master and Worker Nodes](#h-installing-kubernetes-on-the-master-and-worker-nodes)
*   [Initializing a Kubernetes Cluster](#h-initializing-a-kubernetes-cluster)
*   [Running Your First application on Kubernetes](#h-running-your-first-application-on-kubernetes)
*   [Conclusion](#h-conclusion)

If you’re stuck managing hundreds of containers, [Kubernetes](https://kubernetes.io/docs/concepts/overview/) is your friend. If you need to learn installing Kubernetes on Ubuntu, this tutorial is your best friend.

Kubernetes is an open-source tool for automating deployment, scaling, and managing containerized applications. In this tutorial, you will learn step-by-step process of installing Kubernetes on Ubuntu machine and get your first container running.

Lets begin!

## Tutorial Prerequisites

This post will be a step-by-step tutorial. To follow along, be sure you have two [Ubuntu](https://adamtheautomator.com/docker-ubuntu/) 14.04.4 LTS or greater machines with Docker installed. This tutorial uses [Ubuntu 18.04.5 LTS](https://releases.ubuntu.com/18.04/) with Docker 19.03.8 installed on each machine.

Related:[How to Install and Use Docker on Ubuntu (In the Real World)](https://adamtheautomator.com/docker-ubuntu/)

> _You technically can install Kubernetes on a single node, it’s not recommended. Separating nodes provides [fault tolerance and high availability](https://kubernetes.io/docs/setup/production-environment/#production-control-plane)._

The Ubuntu hosts the tutorial uses will be called MASTER using an IP address of 10.0.0.200 for the master node and WORKER for the worker node.

## Installing Kubernetes on Ubuntu Prerequisites

Before you learn installing Kubernetes on Ubuntu, you should first run through a few prerequisite tasks to ensure the install goes smoothly.

To get started, open your favorite [SSH](https://adamtheautomator.com/ssh-command-in-linux/) client, connect to MASTER and follow along.

Related:[A Windows Guy in a Linux World: Setting up SSH in Linux](https://adamtheautomator.com/ssh-command-in-linux/)

1\. (Optional) Assign the hostname of `master-node` to MASTER by running the `hostnamectl` command. You don’t have to rename the nodes but doing so will ensure that all your nodes have a unique hostname which will be easier to identify while working with the cluster.

```bash
# Assiging the hostname master-node to the first ubuntu machine
 sudo hostnamectl set-hostname master-node
```

> _Assign a hostname of `worker-node` to WORKER._

2\. (Optional) Next, run the `hostname` command to verify you’ve successfully updated the hostname. If `hostname` returns the expected hostname, you’re good to go.

![Updating the hostname](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T155405.802.png)

Updating the hostname

3\. Next, run the [`sudo apt update`](https://www.cyberciti.biz/faq/what-does-sudo-apt-get-update-command-do-on-ubuntu-debian/) command to ensure Ubuntu has all of the latest packages available for installation. You should do this to ensure when the time comes, `apt` can find all of the required package repositories.

```bash
# Updating Package Repositories for the Latest Version
# Sudo is used to elevate permissions for a non-privileged account
 sudo apt update 
```

![Updating Package Repositories for the Latest Version ](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T155520.011.png)

Updating Package Repositories for the Latest Version

> _Although this tutorial uses the root user, it is typically best practice to use a less-privileged account that is a member of the sudoers group._

4\. Now, run [`apt install`](https://vitux.com/how-to-use-apt-to-install-programs-from-command-line-in-debian/) begin installing Kubernetes on Ubuntu dependency packages [transport-https](https://manpages.ubuntu.com/manpages/lunar/en/man1/apt-transport-https.1.html) and [curl](https://manpages.ubuntu.com/manpages/trusty/man1/curl.1.html). You’ll need these packages to download the required Kubernetes packages later.

```bash
# Installing the transport-https and curl package on each ubuntu system
 sudo apt-get install -y apt-transport-https curl
```

![Installing the transport-https and curl package on each ubuntu system](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T155625.167.png)

Installing the transport-https and curl package on each ubuntu system

5\. Run `curl` to download and add the required GPG security key with `apt-key` to authenticate to the Kubernetes package repository later. If successful, you should get an OK response in your terminal.

```bash
# Adding the Kubernetes GPG Key on each ubuntu system
 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
```

6\. Now, run the `apt-add-repository` command to add the Kubernetes package repository in Ubuntu. You must perform this step because, by default, the Kubernetes repository is not present in the _/etc/apt/sources.list_ file.

```bash
# Adding the Kubernetes repository on each ubuntu system
 sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
```

![Adding the Kubernetes repository on each ubuntu system](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T160010.215.png)

Adding the Kubernetes repository on each ubuntu system

7\. Finally, run the [`sudo apt update`](https://www.cyberciti.biz/faq/what-does-sudo-apt-get-update-command-do-on-ubuntu-debian/) command again to force `apt` to read the new package repository list and ensure all of the latest packages available for installation.

8\. Perform steps 1-7 on WORKER also.

## Installing Kubernetes on the Master and Worker Nodes

Now that you have the prerequisite packages installed on both MASTER and WORKER, it’s time to set up Kubernetes. Kubernetes consists of three packages/tools, [kubeadm](https://kubernetes.io/docs/reference/setup-tools/kubeadm/), [kubelet](https://kubernetes.io/docs/concepts/overview/components/#kubelet), and [kubectl](https://kubernetes.io/docs/reference/kubectl/kubectl/). Each of these packages contains all of the binaries and configurations necessary to set up a Kubernetes cluster.

Related:[Kubernetes: How Components Fit Together as an Architecture Diagram](https://adamtheautomator.com/kubernetes-architecture-diagram/)

Assuming you are still connected to the **MASTER** via SSH:

1\. Run the `apt-get install` command to install the kubeadm, kubectl, and kubelet packages.

*   [kubelet](https://kubernetes.io/docs/concepts/overview/components/#kubelet) is an agent that runs on each worker node and manages all containers in pods.
*   [Kubeadm](https://kubernetes.io/docs/reference/setup-tools/kubeadm/) is a tool that helps in initializing and creating Kubernetes clusters.
*   [kubectl](https://kubernetes.io/docs/reference/kubectl/kubectl/) allows you to run commands against Kubernetes clusters.

```bash
# Installing the kubeadm kubelet kubectl package/tool on each ubuntu machine.
 sudo apt-get install kubeadm kubelet kubectl
```

![Installing the kubeadm kubelet kubectl package/tool on each ubuntu machine](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T160213.884.png)

Installing the kubeadm kubelet kubectl package/tool on each ubuntu machine

2\. Run each previously installed package with the `version` parameter. The below code snippet is combining all of the commands on a single line for simplicity.

```bash
# Verify the version of each of the tools on each machine.
 kubeadm version && kubelet --version && kubectl version
```

If all goes well, the set of commands above should return a `kubeadm version`, a line that says `Kubernetes vX.XX.X` for `kubelet`, and a `Client Version` representing the version for `kubectl`.

![Verify the version of each of the tools on each machine.](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T160406.458.png)

Verify the version of each of the tools on each machine.

3\. Now, go through steps one and two on **WORKER** also.

## Initializing a Kubernetes Cluster

By now, you should have Kubernetes installed on both the master node (MASTER) and a worker node (WORKER). But, Kubernetes on Ubuntu isn’t doing much good if it’s not running. You now need to initialize the cluster on MASTER.

Assuming you are still connected to the **MASTER** via SSH:

1\. Run the `kubeadm init` command below to initialize the Kubernetes cluster. The below command tells Kubernetes the IP address where its [kube-apiserver](https://kubernetes.io/docs/concepts/overview/components/#control-plane-components) is located with the `--apiserver-advertise-address` parameter. In this case, that IP address is the master node itself.

The command below is also defining the range of IP addresses to use for the [pod network](https://kubernetes.io/docs/concepts/overview/components/#control-plane-components) using the `-pod-network-cidr` parameter. The pod network allows pods to communicate with each other. Setting the pod network like this will instruct the master node to automatically assign IP addresses for every node.

```bash
kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.0.0.200
```

If successful, you will see output similar to the below screenshot.

Be sure to copy the two commands highlighted in blue. You will need these commands later to join the worker node to the cluster.

![Kubernetes initialized](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T160605.374.png)

Kubernetes initialized

2\. Run the first highlighted box commands in step 1 now on the master node. These commands force Kubernetes to run as a non-root account for security reasons.

```bash
# Run the below commands on Master Node to run Kubernetes cluster with a regular user
   # Creating a directory that will hold configurations such as the admin key files, which are required to connect to the cluster, and the cluster’s API address.
   mkdir -p $HOME/.kube
   # Copy all the admin configurations into the newly created directory 
   sudo cp -i /etc/Kubernetes/admin.conf $HOME/.kube/config
   # Change the user from root to regular user that is non-root account
   sudo chown $(id -u):$(id -g) $HOME/.kube/config
```

3\. Now, SSH into the worker node and run the [`kubeadm join` command](https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-join/) as shown above in the second highlighted box in step 1.

This command joins the worker node to the cluster. Both the `--token` and `--discovery-token-ca-cert-hash` values are generated by the master node in step 1 to allow the worker node to connect securely to the master node and validates that the root CA public key is the same as the one held by the master node.

```bash
# Run the below command on Worker Node to join the Kubernetes cluster
 kubeadm join 10.0.0.200:6443 --token ismq95.dtz5nn9rej9w5m30 \
         --discovery-token-ca-cert-hash sha256:7c12e833b38f210625301b31a030ed20172227cbc625c04a71e0256c6e86b555
```

![The Kubernetes worker node has joined the cluster](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T160840.992.png)

The Kubernetes worker node has joined the cluster

4\. Next, run the `kubectl` command on the master node to verify the worker node has been successfully added to the cluster. If successful, you should see both the master and worker node show up with a **STATUS** of **NotReady**.

The nodes show a status of **NotReady** because you haven’t yet set up the network for them to communicate.

```bash
# Verifying the nodes on the Kubernetes cluster
 kubectl get nodes
```

![Verifying the nodes on the Kubernetes cluster](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T160940.657.png)

Verifying the nodes on the Kubernetes cluster

5\. Run the `kubectl apply` the command to download a popular pod network YAML configuration and deploy a pod network to the master node. Creating a pod network establishes network connectivity between two pods in two different nodes.

Kubernetes allows you to set up pod networks via YAML configuration files. One of the most popular pod networks is called [Flannel](https://github.com/flannel-io/flannel#flannel). Flannel is responsible for allocating an IP address lease to each node.

The [Flannel YAML file](https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml) contains the various configuration necessary for setting up the pod network.

```bash
# Establishing the Network connectivity between two MASTER AND WORKER
 kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
```

![Establishing the Network connectivity between two MASTER AND WORKER](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T161048.050.png)

Establishing the Network connectivity between two MASTER AND WORKER

6\. Now, run `kubectl get nodes` again to verify both nodes show a **STATUS** of **Ready** on the master node.

![verify both nodes](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T161207.008.png)

verify both nodes

## Running Your First application on Kubernetes

You should now have a fully functioning Kubernetes environment set up. Great job! A running Kubernetes cluster is great but it’s not doing much good until you deploy some containers on it.

In this final section, let’s briefly cover how to create a [Kubernetes deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) and [service](https://kubernetes.io/docs/concepts/services-networking/service/) to run a simple NGINX container.

Assuming you are still connected to the **MASTER** via SSH:

1\. Run the [`kubectl create deployment` command](https://kubernetes.io/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro/) to create a deployment configuration. Deployments are how Kubernetes create and update application instances. A deployment also allows Kubernetes to continually monitor the application and fix any issues via a self-healing mechanism.

The below command creates a deployment configuration called `nginx`, downloads the`nginx` Docker image from [Docker Hub](https://hub.docker.com/), and creates a pod (and container within) on the worker node.

```bash
kubectl create deployment nginx --image=nginx
```

2\. Now, run `kubectl get deployments` to ensure Kubernetes has created the deployment.

```bash
kubectl get deployments nginx
```

3\. Next, run `kubectl create service` to create a service. A service is a way Kubernetes exposes an application over the network running on one or more pods.

The below command creates a network service to expose the `nginx` deployment (and pod)’s TCP port 80 outside of the cluster.

```bash
kubectl create service nodeport nginx --tcp=80:80
```

4\. Run the `kubectl get svc` command to verify Kubernetes created the service successfully. The `kubectl get svc` command is a great way to get an overview of all Kubernetes services.

```bash
kubectl get svc
```

> _You can also see more information about the service by running `kubectl describe services nginx`._

Below, you can see that Kubernetes has successfully created the NGINX service and is currently running on port `80` on the master node and mapping that port to port `31414` on the pod.

![Checking the service](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T161657.272.png)

Checking the service

5\. Since the pod running the application is now available via port 31414 via the service, run `curl` to ensure you can bring up the default NGINX web page.

```bash
# Testing the NGINX service on MASTER Node listening on Port 31414
 curl localhost:31414
```

![Testing the NGINX service on MASTER Node listening on Port 31414](https://adamtheautomator.com/wp-content/uploads/2021/06/Untitled-2021-06-17T161729.298.png)

Testing the NGINX service on MASTER Node listening on Port 31414

## Conclusion

You should now know how installing Kubernetes on Ubuntu is done. Throughout this tutorial, you walked through each step to get a Kubernetes cluster set up and also deploying your first application. Good job!

Now, that you have a Kubernetes cluster set up, what applications are you going to deploy next to it?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Finstalling-kubernetes-on-ubuntu%2F&text=Master%20Installing%20Kubernetes%20on%20Ubuntu)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Finstalling-kubernetes-on-ubuntu%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Finstalling-kubernetes-on-ubuntu%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/07/featured_image-3.png)

### [Build Your First Internal Developer Platform](/build-first-internal-developer-platform/)

Build your first Internal Developer Platform with Backstage, a software catalog, software templates, CI/CD handoffs, and Kubernetes deployment manifests.

![](https://adamtheautomator.com/wp-content/uploads/2026/06/featured_image-9.png)

### [DevOps to Platform Engineer: 2026 Transition Roadmap](/devops-platform-engineer-2026-transition-roadmap/)

Learn how to move from DevOps to platform engineering in 2026 with a practical roadmap covering transferable skills, internal developer platforms, Backstage, Crossplane, and portfolio projects.

![](https://adamtheautomator.com/wp-content/uploads/2024/02/kubernetes-blue-green.jpg)

### [Learning the Kubernetes Blue Green Deployment Strategy](/kubernetes-blue-green/)

Dive into Kubernetes blue-green deployments for smooth updates. Enhance your release process with this smart Kubernetes strategy!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
