This is an old revision of the document!
Overview
Kubernetes is the new mind breaking technology of Google and it is very close to Docker. In fact you need docker to run Kubernetes as well. So you can say that Kubernetes is based on Docker. So let's get it going. We will use 3 machines:
- 1 Master
- 2 Nodes (not slaves or workers)
To configure our kubernetes, we have to install the following:
- Docker (or rkt) - Container runtime.
- Kubelet - Kubernetes Node Agent.
- Kubeadm - The tool used to build the cluster.
- Kubectl - The Kubernetes Client
- CNI - Install support for CNI network (Container network Interface / Spec or Model for Kubernetes Network)
Install Packages
To install the packages we have to:
- Configure the Repos
- Actuall install the packages.
So let's get going :)
Configure the Repos
The repo is configured very easy using the following script:
Repo Config
apt-get update && apt-get install -y apt-transport-https curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - cat <<EOF >/etc/apt/sources.list.d/kubernetes.list deb http://apt.kubernetes.io/ kubernetes-xenial main EOF apt-get update
Please bare in mind, this is for Ubuntu Xenial 64. If you have different distribution please adjust….the last entry :)
vagrant@node-1:~$ sudo su - root@node-1:~# apt-get update && apt-get install -y apt-transport-https 0% [Working] Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB] Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:5 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [850 kB] Get:6 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [7,532 kB] Get:7 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [489 kB] Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [200 kB] Get:9 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [5,728 B] Get:10 http://security.ubuntu.com/ubuntu xenial-security/multiverse Translation-en [2,708 B] Get:11 http://archive.ubuntu.com/ubuntu xenial/universe Translation-en [4,354 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [144 kB] Get:13 http://archive.ubuntu.com/ubuntu xenial/multiverse Translation-en [106 kB] Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1,129 kB] Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [796 kB] Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [333 kB] Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.8 kB] Get:18 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse Translation-en [8,468 B] Get:19 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [7,280 B] Get:20 http://archive.ubuntu.com/ubuntu xenial-backports/main Translation-en [4,456 B] Get:21 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [8,064 B] Get:22 http://archive.ubuntu.com/ubuntu xenial-backports/universe Translation-en [4,328 B] Fetched 16.3 MB in 12s (1,318 kB/s) Reading package lists... Done Reading package lists... Done Building dependency tree Reading state information... Done apt-transport-https is already the newest version (1.2.32). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. root@node-1:~# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - OK root@node-1:~# cat <<EOF >/etc/apt/sources.list.d/kubernetes.list > deb http://apt.kubernetes.io/ kubernetes-xenial main > EOF root@node-1:~# apt-get update Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease Hit:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:4 http://archive.ubuntu.com/ubuntu xenial-backports InRelease Hit:5 http://security.ubuntu.com/ubuntu xenial-security InRelease Get:2 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [8,993 B] Get:6 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 Packages [35.3 kB] Fetched 44.3 kB in 2s (20.6 kB/s) Reading package lists... Done root@node-1:~#
Please run this command on all 3 machines.
Install the packages
So let's install the packages now:
Install packages
root@k8s-master:~# apt-get install docker.io kubeadm kubectl kubelet kubernetes-cni Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: bridge-utils cgroupfs-mount conntrack containerd cri-tools ebtables pigz runc socat ubuntu-fan Suggested packages: mountall aufs-tools debootstrap docker-doc rinse zfs-fuse | zfsutils The following NEW packages will be installed: bridge-utils cgroupfs-mount conntrack containerd cri-tools docker.io ebtables kubeadm kubectl kubelet kubernetes-cni pigz runc socat ubuntu-fan 0 upgraded, 15 newly installed, 0 to remove and 0 not upgraded. Need to get 104 MB of archives. After this operation, 532 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://archive.ubuntu.com/ubuntu xenial/universe amd64 pigz amd64 2.3.1-2 [61.1 kB] Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 bridge-utils amd64 1.5-9ubuntu1 [28.6 kB] Get:3 http://archive.ubuntu.com/ubuntu xenial/universe amd64 cgroupfs-mount all 1.2 [4,970 B] Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 conntrack amd64 1:1.4.3-3 [27.3 kB] Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 runc amd64 1.0.0~rc7+git20190403.029124da-0ubuntu1~16.04.4 [1,890 kB] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 containerd amd64 1.2.6-0ubuntu1~16.04.3 [19.7 MB] Get:6 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 cri-tools amd64 1.13.0-00 [8,776 kB] Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 docker.io amd64 18.09.7-0ubuntu1~16.04.5 [30.4 MB] Get:7 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubernetes-cni amd64 0.7.5-00 [6,473 kB] Get:9 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubelet amd64 1.18.2-00 [19.5 MB] Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ebtables amd64 2.0.10.4-3.4ubuntu2.16.04.2 [79.9 kB] Get:14 http://archive.ubuntu.com/ubuntu xenial/universe amd64 socat amd64 1.7.3.1-1 [321 kB] Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 ubuntu-fan all 0.12.8~16.04.3 [35.1 kB] Get:10 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubectl amd64 1.18.2-00 [8,825 kB] Get:11 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubeadm amd64 1.18.2-00 [8,162 kB] Fetched 104 MB in 6s (15.3 MB/s) Preconfiguring packages ... Selecting previously unselected package pigz. (Reading database ... 58264 files and directories currently installed.) Preparing to unpack .../pigz_2.3.1-2_amd64.deb ... Unpacking pigz (2.3.1-2) ... Selecting previously unselected package bridge-utils. Preparing to unpack .../bridge-utils_1.5-9ubuntu1_amd64.deb ... Unpacking bridge-utils (1.5-9ubuntu1) ... Selecting previously unselected package cgroupfs-mount. Preparing to unpack .../cgroupfs-mount_1.2_all.deb ... Unpacking cgroupfs-mount (1.2) ... Selecting previously unselected package conntrack. Preparing to unpack .../conntrack_1%3a1.4.3-3_amd64.deb ... Unpacking conntrack (1:1.4.3-3) ... Selecting previously unselected package runc. Preparing to unpack .../runc_1.0.0~rc7+git20190403.029124da-0ubuntu1~16.04.4_amd64.deb ... Unpacking runc (1.0.0~rc7+git20190403.029124da-0ubuntu1~16.04.4) ... Selecting previously unselected package containerd. Preparing to unpack .../containerd_1.2.6-0ubuntu1~16.04.3_amd64.deb ... Unpacking containerd (1.2.6-0ubuntu1~16.04.3) ... Selecting previously unselected package cri-tools. Preparing to unpack .../cri-tools_1.13.0-00_amd64.deb ... Unpacking cri-tools (1.13.0-00) ... Selecting previously unselected package docker.io. Preparing to unpack .../docker.io_18.09.7-0ubuntu1~16.04.5_amd64.deb ... Unpacking docker.io (18.09.7-0ubuntu1~16.04.5) ... Selecting previously unselected package ebtables. Preparing to unpack .../ebtables_2.0.10.4-3.4ubuntu2.16.04.2_amd64.deb ... Unpacking ebtables (2.0.10.4-3.4ubuntu2.16.04.2) ... Selecting previously unselected package kubernetes-cni. Preparing to unpack .../kubernetes-cni_0.7.5-00_amd64.deb ... Unpacking kubernetes-cni (0.7.5-00) ... Selecting previously unselected package socat. Preparing to unpack .../socat_1.7.3.1-1_amd64.deb ... Unpacking socat (1.7.3.1-1) ... Selecting previously unselected package kubelet. Preparing to unpack .../kubelet_1.18.2-00_amd64.deb ... Unpacking kubelet (1.18.2-00) ... Selecting previously unselected package kubectl. Preparing to unpack .../kubectl_1.18.2-00_amd64.deb ... Unpacking kubectl (1.18.2-00) ... Selecting previously unselected package kubeadm. Preparing to unpack .../kubeadm_1.18.2-00_amd64.deb ... Unpacking kubeadm (1.18.2-00) ... Selecting previously unselected package ubuntu-fan. Preparing to unpack .../ubuntu-fan_0.12.8~16.04.3_all.deb ... Unpacking ubuntu-fan (0.12.8~16.04.3) ... Processing triggers for man-db (2.7.5-1) ... Processing triggers for ureadahead (0.100.0-19.1) ... Processing triggers for systemd (229-4ubuntu21.27) ... Setting up pigz (2.3.1-2) ... Setting up bridge-utils (1.5-9ubuntu1) ... Setting up cgroupfs-mount (1.2) ... Setting up conntrack (1:1.4.3-3) ... Setting up runc (1.0.0~rc7+git20190403.029124da-0ubuntu1~16.04.4) ... Setting up containerd (1.2.6-0ubuntu1~16.04.3) ... Setting up cri-tools (1.13.0-00) ... Setting up docker.io (18.09.7-0ubuntu1~16.04.5) ... Adding group `docker' (GID 116) ... Done. Setting up ebtables (2.0.10.4-3.4ubuntu2.16.04.2) ... update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults Setting up kubernetes-cni (0.7.5-00) ... Setting up socat (1.7.3.1-1) ... Setting up kubelet (1.18.2-00) ... Setting up kubectl (1.18.2-00) ... Setting up kubeadm (1.18.2-00) ... Setting up ubuntu-fan (0.12.8~16.04.3) ... Processing triggers for ureadahead (0.100.0-19.1) ... Processing triggers for systemd (229-4ubuntu21.27) ...
Please execute that on all 3 machines