This course notes are WIP.
🎻 Linux Academy course for understanding the Kubernetes container orchestration tool.
For this lesson, it’s needed to spin up some servers for deploying our Kubernetes cluster. In this case, we are gonna need three servers where one of those would be the Master Node and the two other ones would be the Node 1 and Node 2.
Everyone of these three nodes must have the following requirements:
Also, apart from that, the Master node requires to have a Control Plane properly installed.
A container runtime is the software that actually runs the containers. Kubernetes supports several other container runtimes (such as rkt and containerd) but Docker is the most popular. The first step in building our cluster is to install Docker on all three servers:
Add the Docker repository GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
Reload the apt sources list:
sudo apt-get update
Install Docker:
sudo apt-get install -y docker-ce
Prevent auto-updates for the Docker package:
sudo apt-mark hold docker-ce
Verify that docker is working:
sudo docker version
The point of this subsection is to install the different and needed component of Kubernetes. Before that, let’s explain what are these components.
Once understood these three components, let’s install them on all three servers:
Add the Kubernetes repository GPG key:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
Add the Kubernetes repository:
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
Reload the apt sources list:
sudo apt-get update
Install Kubernetes:
sudo apt-get install -y kubelet=1.12.7-00 kubeadm=1.12.7-00 kubectl=1.12.7-00
Prevent auto-updates for the Kube package:
sudo apt-mark hold kubelet kubeadm kubectl
Verify that Kubeadm is working:
kubeadm version
In this section, we will bootstrap the cluster on the Kube master node. Then, we will join each of the two worker nodes to the cluster, forming an actual multi-node Kubernetes cluster.
On the Kube master node, initialize the cluster:
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
Set up the local kubeconfig:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Actually, you can find these last commands in the output of the cluster initialization logs.
Verify that the cluster is responsive and that Kubectl is working:
kubectl version
You should get Server Version
as well as Client Version
. It should look something like this:
Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-24T06:54:59Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-24T06:43:59Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}
The kubeadm init
command should output a kubeadm join
command containing a token and hash. Copy that command and run it with sudo
on both worker nodes. It should look something like this:
sudo kubeadm join $some_ip:6443 --token $some_token --discovery-token-ca-cert-hash $some_hash
Verify that all nodes have successfully joined the cluster:
kubectl get nodes
You should see all three of your nodes listed. It should look something like this:
NAME STATUS ROLES AGE VERSION
wboyd1c.mylabserver.com NotReady master 5m17s v1.12.2
wboyd2c.mylabserver.com NotReady <none> 53s v1.12.2
wboyd3c.mylabserver.com NotReady <none> 31s v1.12.2
Note: The nodes are expected to have a STATUS of
NotReady
at this point.