Installing Kubernetes with Kubeadm, quick and dirty!


In this tutorial we will be installing Kubernetes onto servers using Kubeadm. You may use any service you wish, if you have a subscription to linux-academy you can run the commands listed below on their cloud servers.

We also go over the option of installing two different CNIs (Container Network Interfaces), Flannel and Calico.

Note: If you decide to use AWS EC2 instances make sure your instances are configured correctly so your EC2 security group allows for SSH, port 80, 8080 and 6443 and traffic is open between the subnets.


  • A way to create your node servers (ex: LinuxAcademy Cloud Servers or AWS EC2 Instances)


1 Create your master and worker nodes

Create your master and worker nodes. For our example we will have 1 master node and 2 worker nodes, you can however make more worker nodes, it will not affect this tutorial. In this example a total of 3 servers which will become our cluster. Make sure Ubuntu is selected for the operating system.

For AWS EC2 instance, visit this page.

For Linux Academy cloud servers, visit this page.

2 Installing Kubeadm and necessary components

SSH into every server you created, master and worker nodes, and install the following below. If you have problems installing the packages install the Docker Repository and the Kubernetes Repository on each server.

Step 1: Install Docker repository on all servers

curl -fsSL | sudo apt-key add -
sudo add-apt-repository    "deb [arch=amd64] \
   $(lsb_release -cs) \

Step 2: Install Kubernetes repository on all servers

curl -s | sudo apt-key add -
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb kubernetes-xenial main

Step 2: Update apt-get on all servers

sudo su
apt-get update

Step 3: Install Docker-CE on all servers

apt-get install -y docker-ce

Step 4: Install Kubeadm, Kubelet and Kubectl

apt-mark hold kubelet kubeadm kubectl holds back specific packages from updating

apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl

Step 5: Enable  net.bridge.bridge-nf-call-iptables on all servers

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

3 Create Cluster

Step 1: Create the actual cluster with kubeadm init on master

SSH only to the master and run the following commands, you can run sudo su to gain root permissions.

Pod network add-ons may have arguments that need to be passed to the kubeadmin initialization. Both Flannel and Calico have a specific required  --pod-network-cidr .

For Flannel use
kubeadm init --pod-network-cidr=
For Calico use
kubeadm init --pod-network-cidr=

Kubeadm will output this response

Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

mkdir -p $HOME/.kube
 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
 sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:

You can now join any number of machines by running the following on each node
as root:

kubeadm join --token xxxxxx.xxxxxxxx --discovery-token-ca-cert-hash sha256:xxxxxxxxxxxxxxxxxxxxxxx

The output contains two important pieces of information.

  1. It contains information on how to start using the cluster as a regular user by running a set of commands.
  2. It contains the join command that will be used in the next section to connect worker nodes to your cluster. SAVE THIS COMMAND FOR LATER! (caps lock, sorry)

Step 2: Apply the outputted command

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Step 3: Install your flavor of CNI

For Flannel use
kubectl apply -f
For Calico use
kubectl apply -f

Your almost there!

You should now be able to see your pods and master node via kubectl commands.
You will only see your master node and what pods are in your master node.

If you receive a NotReady on master this is because some pods are still pending. This status will become Ready once the pending pods have finished initializing.

To view nodes:

kubectl get nodes --all-namespaces


NAME                      STATUS     ROLES    AGE   VERSION     NotReady   master   5m    v1.12.2

To view pods:

kubectl get pods --all-namespaces


NAMESPACE     NAME                            READY     STATUS    RESTARTS   AGE
kube-system   etcd-ip-xxx                     1/1       Running   0          9m
kube-system   kube-apiserver-ip-xxx           1/1       Running   0          9m
kube-system   kube-controller-manager-ip-xxx  1/1       Running   0          9m
kube-system   kube-dns-xxx-xxx                0/3       Pending   0          10m
kube-system   kube-proxy-xxx                  1/1       Running   0          10m
kube-system   kube-scheduler-ip-xxx           1/1       Running   0          9m

4 Join worker nodes to cluster

Forgot your kubeadm join command?

run sudo kubeadm token create --print-join-command  on master to generate a new one.

Step 1: Run your join command on all worker nodes

Now that your master is up and running, its time to join your worker nodes to the cluster. Run the join command that you saved from the previous section.

The kubeadm init command that was previously ran on master contains a kubeadm join command containing a token and hash. This will need to be copied and ran on every worker node with  sudo.

sudo kubeadm join $controller_private_ip:6443 --token $token --discovery-token-ca-cert-hash $hash

The cluster should now be up and running! Verify by running the command below on the Kube Master server. This is where Kubectl is installed.

Make sure all the nodes have a status of Ready.

To view nodes:

kubectl get nodes
NAME                      STATUS   ROLES    AGE   VERSION      Ready    master   54m   v1.12.2      Ready             49m   v1.12.2      Ready             49m   v1.12.2

This tutorial was given a 3 since its short and easy. Certain aspects of this tutorial may also show up on the CKA exam section "Core Concepts" worth 19% of the exam.

— admin
Prev post: Welcome to AWS Cloud Guru!Next post: Setting up AWS CLI on Mac and Windows

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *