kubernetes-dedicated, linux, ubuntu

Your dedicated Kubernetes cluster on Ubuntu with Kubeadm

Hi,

I’m not the best fan of Google documentation, in fact if there is something that they are very bad at, (besides interviewing people) is documenting things. But look, they are not the only ones, long before Google joined the battle against AWS, I had to read all the Amazon documentation, in fact I had to hate myself, my job and my life for long nights. During that period, I learned about EC2, AWS auto-scaling, puppet, cheff, ansible scripts, capistrano scripts …. oh how many nights I spent reading that docs ?

Honestly, I’ve spend so much time reading docs and watching people talking about Kubernetes, but besides Kelsey Hightower (When he was working for CoreOS) no other speaker was able to really DEMO kubernetes cluster on bare-metal and really make it happen. The main problem at least for me, was after the conference, you get your notebook, your favorite dedicated server provider (OVH ? ) and try yourself… but, well … it does not work.

I just want to move one to something better, I just want to get the job done and be able to focus on programming awesome software … Finally this day is a little closer now.

 

Easy to follow step by step tutorial

Out of my frustration I decided it was time to do some easy to follow step by step tutorial.

Seriously, I don’t have much time to loose, and I want to get my own Kubernetes cluster on bare metal / dedicated server, why is this So complicated ??

I’ve been trying to do this for at least 1 year, release after release of Kubernetes, CoreOS, RancherOS … always hitting the same spot … and always ending up in a dead end with some freak problem that makes me hate myself, hate Docker and kubernetes all together.

 

This week, I had a pleasant experience and so I decided it was about time to share it with the others, please bare in mind that Kubeadm is alpha and something may not work. (You have been Advised.)

 

Kubernetes Dedicated Bare-Metal Cluster on Ubuntu with Kubeadm

Today I will be teaching you to create your own Kubernetes cluster, OUTSIDE Google Cloud. 

Don’t get me wrong Google people, but I just like to explore the world and be able to have a dedicated server, without having to pay so much money for it. Because in the end, this is OpenSource software and we are living in a Free world.

 

 

So, for this tutorial we will be using 3 servers with Ubuntu 16.04, so please have it ready before starting. You can use any cloud provider that you want. I’m using DigitalOcean or Packet.net because they accept paypal and they have descent pricing, but feel free to chose anything you like better.

 

Installing required sources for Kubernetes on Ubuntu 16.06

First thing is to update your apt-get and install transport-https in order to be able to download the right resources via https:

apt-get update && apt-get install -y apt-transport-https

(...)

Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
 Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
 Get:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
 Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [544 kB]
 Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [220 kB]
 Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [469 kB]
 Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [185 kB]
 Get:8 http://archive.ubuntu.com/ubuntu xenial-security/main amd64 Packages [268 kB]
 Get:9 http://archive.ubuntu.com/ubuntu xenial-security/main Translation-en [113 kB]
 Get:10 http://archive.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [115 kB]
 Get:11 http://archive.ubuntu.com/ubuntu xenial-security/universe Translation-en [59.8 kB]
 Fetched 2177 kB in 1s (1723 kB/s)
 Reading package lists... Done
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following NEW packages will be installed:
 apt-transport-https
 0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
 Need to get 26.1 kB of archives.
 After this operation, 214 kB of additional disk space will be used.
 Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 apt-transport-https amd64 1.2.20 [26.1 kB](...)
 Fetched 26.1 kB in 0s (887 kB/s)
 perl: warning: Setting locale failed.
 perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LC_TIME = "nl_NL.UTF-8",
 LC_MONETARY = "nl_NL.UTF-8",
 LC_ADDRESS = "nl_NL.UTF-8",
 LC_TELEPHONE = "nl_NL.UTF-8",
 LC_NAME = "nl_NL.UTF-8",
 LC_MEASUREMENT = "nl_NL.UTF-8",
 LC_IDENTIFICATION = "nl_NL.UTF-8",
 LC_NUMERIC = "nl_NL.UTF-8",
 LC_PAPER = "nl_NL.UTF-8",
 LANG = "en_US.UTF-8"
 are supported and installed on your system.
 perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
 debconf: unable to initialize frontend: Dialog
 debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76, <> line 1.)
 debconf: falling back to frontend: Readline
 Selecting previously unselected package apt-transport-https.
 (Reading database ... 23775 files and directories currently installed.)
 Preparing to unpack .../apt-transport-https_1.2.20_amd64.deb ...
 Unpacking apt-transport-https (1.2.20) ...
 Setting up apt-transport-https (1.2.20) ...

 

The next step is to add the google cloud keys to your Ubuntu installation in order to be able to authenticate and download the packages using the right key:

root@kubernetes-1:~# curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
 OK

Now we will add the kubernetes Ubuntu sources into the /etc/apt/sources.list.d/kubernetes.list so apt-get knows where to find what we are looking for:

 
root@kubernetes-1:~# cat <<EOF >/etc/apt/sources.list.d/kubernetes.list \
deb http://apt.kubernetes.io/ kubernetes-xenial main \
EOF

 

Running some Updates

After updating your sources list, you need to tell Ubuntu: Hey please update yourself and be ready because we will be doing alpha crazy stuff over here, next we will install Docker.

 root@kubernetes-1:~# apt-get update
 Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
 Hit:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease
 Hit:3 http://archive.ubuntu.com/ubuntu xenial-security InRelease
 Get:4 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [8936 B]
 Get:5 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 Packages [3472 B]
 Fetched 12.4 kB in 1s (8232 B/s)
 Reading package lists... Done

What is Docker:

Docker is an additional layer of abstraction and automation of operating-system-level virtualization on Windows and Linux.[6] Docker uses the resource isolation features of the Linux kernel such as cgroups and kernel namespaces, and a union-capable file system such as OverlayFS and others[7] to allow independent “containers” to run within a single Linux instance, avoiding the overhead of starting and maintaining virtual machines.[8]  – Wikipidia

 

Docker-linux-interfaces.svg

Installing Docker:

 
 root@kubernetes-1:~# apt-get install -y docker-engine
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following additional packages will be installed:
 apparmor aufs-tools cgroupfs-mount git git-man libapparmor-perl liberror-perl libltdl7 patch
 Suggested packages:
 apparmor-profiles apparmor-profiles-extra apparmor-docs apparmor-utils mountall git-daemon-run
 | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn ed
 diffutils-doc
 The following NEW packages will be installed:
 apparmor aufs-tools cgroupfs-mount docker-engine git git-man libapparmor-perl liberror-perl libltdl7 patch
 0 upgraded, 10 newly installed, 0 to remove and 11 not upgraded.
 Need to get 19.0 MB of archives.
 After this operation, 102 MB of additional disk space will be used.
 Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libapparmor-perl amd64 2.10.95-0ubuntu2.6 [31.4 kB]
 Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 apparmor amd64 2.10.95-0ubuntu2.6 [450 kB]
 Get:3 http://archive.ubuntu.com/ubuntu xenial/universe amd64 aufs-tools amd64 1:3.2+20130722-1.1ubuntu1 [92.9 kB]
 Get:4 http://archive.ubuntu.com/ubuntu xenial/universe amd64 cgroupfs-mount all 1.2 [4970 B]
 Get:5 http://archive.ubuntu.com/ubuntu xenial/main amd64 libltdl7 amd64 2.4.6-0.1 [38.3 kB]
 Get:6 http://archive.ubuntu.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB]
 Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.1 [735 kB]
 Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.1 [3068 kB]
 Get:10 http://archive.ubuntu.com/ubuntu xenial/main amd64 patch amd64 2.7.5-1 [90.4 kB]
 Get:9 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 docker-engine amd64 1.11.2-0~xenial [14.5 MB]
 Fetched 19.0 MB in 3s (5102 kB/s)
 perl: warning: Setting locale failed.
 perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LC_TIME = "nl_NL.UTF-8",
 LC_MONETARY = "nl_NL.UTF-8",
 LC_ADDRESS = "nl_NL.UTF-8",
 LC_TELEPHONE = "nl_NL.UTF-8",
 LC_NAME = "nl_NL.UTF-8",
 LC_MEASUREMENT = "nl_NL.UTF-8",
 LC_IDENTIFICATION = "nl_NL.UTF-8",
 LC_NUMERIC = "nl_NL.UTF-8",
 LC_PAPER = "nl_NL.UTF-8",
 LANG = "en_US.UTF-8"
 are supported and installed on your system.
 perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
 debconf: unable to initialize frontend: Dialog
 debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76, <> line 10.)
 debconf: falling back to frontend: Readline
 Preconfiguring packages ...
 Selecting previously unselected package libapparmor-perl.
 (Reading database ... 23781 files and directories currently installed.)
 Preparing to unpack .../libapparmor-perl_2.10.95-0ubuntu2.6_amd64.deb ...
 Unpacking libapparmor-perl (2.10.95-0ubuntu2.6) ...
 Selecting previously unselected package apparmor.
 Preparing to unpack .../apparmor_2.10.95-0ubuntu2.6_amd64.deb ...
 Unpacking apparmor (2.10.95-0ubuntu2.6) ...
 Selecting previously unselected package aufs-tools.
 Preparing to unpack .../aufs-tools_1%3a3.2+20130722-1.1ubuntu1_amd64.deb ...
 Unpacking aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
 Selecting previously unselected package cgroupfs-mount.
 Preparing to unpack .../cgroupfs-mount_1.2_all.deb ...
 Unpacking cgroupfs-mount (1.2) ...
 Selecting previously unselected package libltdl7:amd64.
 Preparing to unpack .../libltdl7_2.4.6-0.1_amd64.deb ...
 Unpacking libltdl7:amd64 (2.4.6-0.1) ...
 Selecting previously unselected package docker-engine.
 Preparing to unpack .../docker-engine_1.11.2-0~xenial_amd64.deb ...
 Unpacking docker-engine (1.11.2-0~xenial) ...
 Selecting previously unselected package liberror-perl.
 Preparing to unpack .../liberror-perl_0.17-1.2_all.deb ...
 Unpacking liberror-perl (0.17-1.2) ...
 Selecting previously unselected package git-man.
 Preparing to unpack .../git-man_1%3a2.7.4-0ubuntu1.1_all.deb ...
 Unpacking git-man (1:2.7.4-0ubuntu1.1) ...
 Selecting previously unselected package git.
 Preparing to unpack .../git_1%3a2.7.4-0ubuntu1.1_amd64.deb ...
 Unpacking git (1:2.7.4-0ubuntu1.1) ...
 Selecting previously unselected package patch.
 Preparing to unpack .../patch_2.7.5-1_amd64.deb ...
 Unpacking patch (2.7.5-1) ...
 Processing triggers for systemd (229-4ubuntu17) ...
 Processing triggers for man-db (2.7.5-1) ...
 Processing triggers for libc-bin (2.23-0ubuntu7) ...
 Setting up libapparmor-perl (2.10.95-0ubuntu2.6) ...
 Setting up apparmor (2.10.95-0ubuntu2.6) ...
 debconf: unable to initialize frontend: Dialog
 debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
 debconf: falling back to frontend: Readline
 update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
 insserv: can not symlink(../init.d/halt, ../rc0.d/K11halt): File exists
 insserv: can not symlink(../init.d/halt, ../rc0.d/K11halt): File exists
 insserv: can not symlink(../init.d/sendsigs, ../rc0.d/K04sendsigs): File exists
 insserv: can not symlink(../init.d/sendsigs, ../rc0.d/K04sendsigs): File exists
 insserv: can not symlink(../init.d/umountnfs.sh, ../rc0.d/K06umountnfs.sh): File exists
 insserv: can not symlink(../init.d/umountnfs.sh, ../rc0.d/K06umountnfs.sh): File exists
 insserv: can not symlink(../init.d/iscsid, ../rc0.d/K03iscsid): File exists
 insserv: can not symlink(../init.d/networking, ../rc0.d/K07networking): File exists
 insserv: can not symlink(../init.d/umountfs, ../rc0.d/K08umountfs): File exists
 insserv: can not symlink(../init.d/umountfs, ../rc0.d/K08umountfs): File exists
 insserv: can not symlink(../init.d/umountroot, ../rc0.d/K09umountroot): File exists
 insserv: can not symlink(../init.d/umountroot, ../rc0.d/K09umountroot): File exists
 insserv: can not symlink(../init.d/hwclock.sh, ../rc0.d/K06hwclock.sh): File exists
 insserv: can not symlink(../init.d/hwclock.sh, ../rc0.d/K06hwclock.sh): File exists
 insserv: can not symlink(../init.d/open-iscsi, ../rc0.d/K02open-iscsi): File exists
 insserv: can not symlink(../init.d/rsyslog, ../rc0.d/K05rsyslog): File exists
 insserv: can not symlink(../init.d/mdadm-waitidle, ../rc0.d/K10mdadm-waitidle): File exists
 insserv: can not symlink(../init.d/iscsid, ../rc1.d/K03iscsid): File exists
 insserv: can not symlink(../init.d/open-iscsi, ../rc1.d/K02open-iscsi): File exists
 insserv: can not symlink(../init.d/rsyslog, ../rc1.d/K05rsyslog): File exists
 insserv: can not symlink(../init.d/ondemand, ../rc2.d/S03ondemand): File exists
 insserv: can not symlink(../init.d/rc.local, ../rc2.d/S03rc.local): File exists
 insserv: can not symlink(../init.d/ondemand, ../rc3.d/S03ondemand): File exists
 insserv: can not symlink(../init.d/rc.local, ../rc3.d/S03rc.local): File exists
 insserv: can not symlink(../init.d/ondemand, ../rc4.d/S03ondemand): File exists
 insserv: can not symlink(../init.d/rc.local, ../rc4.d/S03rc.local): File exists
 insserv: can not symlink(../init.d/ondemand, ../rc5.d/S03ondemand): File exists
 insserv: can not symlink(../init.d/rc.local, ../rc5.d/S03rc.local): File exists
 insserv: can not symlink(../init.d/sendsigs, ../rc6.d/K04sendsigs): File exists
 insserv: can not symlink(../init.d/sendsigs, ../rc6.d/K04sendsigs): File exists
 insserv: can not symlink(../init.d/umountnfs.sh, ../rc6.d/K06umountnfs.sh): File exists
 insserv: can not symlink(../init.d/umountnfs.sh, ../rc6.d/K06umountnfs.sh): File exists
 insserv: can not symlink(../init.d/iscsid, ../rc6.d/K03iscsid): File exists
 insserv: can not symlink(../init.d/networking, ../rc6.d/K07networking): File exists
 insserv: can not symlink(../init.d/umountfs, ../rc6.d/K08umountfs): File exists
 insserv: can not symlink(../init.d/umountfs, ../rc6.d/K08umountfs): File exists
 insserv: can not symlink(../init.d/umountroot, ../rc6.d/K09umountroot): File exists
 insserv: can not symlink(../init.d/umountroot, ../rc6.d/K09umountroot): File exists
 insserv: can not symlink(../init.d/hwclock.sh, ../rc6.d/K06hwclock.sh): File exists
 insserv: can not symlink(../init.d/hwclock.sh, ../rc6.d/K06hwclock.sh): File exists
 insserv: can not symlink(../init.d/open-iscsi, ../rc6.d/K02open-iscsi): File exists
 insserv: can not symlink(../init.d/reboot, ../rc6.d/K11reboot): File exists
 insserv: can not symlink(../init.d/reboot, ../rc6.d/K11reboot): File exists
 insserv: can not symlink(../init.d/rsyslog, ../rc6.d/K05rsyslog): File exists
 insserv: can not symlink(../init.d/mdadm-waitidle, ../rc6.d/K10mdadm-waitidle): File exists
 insserv: can not symlink(../init.d/hwclock.sh, ../rcS.d/S04hwclock.sh): File exists
 insserv: can not symlink(../init.d/mountdevsubfs.sh, ../rcS.d/S03mountdevsubfs.sh): File exists
 insserv: can not symlink(../init.d/checkroot.sh, ../rcS.d/S05checkroot.sh): File exists
 insserv: can not symlink(../init.d/mountnfs-bootclean.sh, ../rcS.d/S10mountnfs-bootclean.sh): File exists
 insserv: can not symlink(../init.d/mountnfs.sh, ../rcS.d/S09mountnfs.sh): File exists
 insserv: can not symlink(../init.d/bootmisc.sh, ../rcS.d/S11bootmisc.sh): File exists
 insserv: can not symlink(../init.d/checkfs.sh, ../rcS.d/S07checkfs.sh): File exists
 insserv: can not symlink(../init.d/mountall.sh, ../rcS.d/S08mountall.sh): File exists
 insserv: can not symlink(../init.d/mountall-bootclean.sh, ../rcS.d/S09mountall-bootclean.sh): File exists
 insserv: can not symlink(../init.d/procps, ../rcS.d/S03procps): File exists
 diff: /var/lib/apparmor/profiles/.apparmor.md5sums: No such file or directory
 Setting up aufs-tools (1:3.2+20130722-1.1ubuntu1) ...
 Setting up cgroupfs-mount (1.2) ...
 Setting up libltdl7:amd64 (2.4.6-0.1) ...
 Setting up docker-engine (1.11.2-0~xenial) ...
 Setting up liberror-perl (0.17-1.2) ...
 Setting up git-man (1:2.7.4-0ubuntu1.1) ...
 Setting up git (1:2.7.4-0ubuntu1.1) ...
 Setting up patch (2.7.5-1) ...
 Processing triggers for systemd (229-4ubuntu17) ...
 Processing triggers for libc-bin (2.23-0ubuntu7) ...

 

After installing Docker, we are now able to install Kubelet, Kubeadm, Kubectl and Kubernetes CNI.

 

The kubelet is the primary “node agent” that runs on each node.

The kubectl is a command line interface for running commands against Kubernetes clusters.

 

The Kubernetes CNI is the CNI (Container Network Interface) project, a specification and libraries for writing plugins to configure network interfaces in Linux containers. CNI has a wide range of support and the specification is simple to implement.

Who is also using CNI?

Container runtimes

 

Installing Kubelet, Kubeadm, Kubectl and Kubernetes CNI.

This will make sure that you have the proper commands in place, and that you are able to generate all the required tokens and very easily configure your very new Kubernetes cluster:

 root@kubernetes-1:~# apt-get install -y kubelet kubeadm kubectl kubernetes-cni
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following additional packages will be installed:
 ebtables ethtool
 The following NEW packages will be installed:
 ebtables ethtool kubeadm kubectl kubelet kubernetes-cni
 0 upgraded, 6 newly installed, 0 to remove and 11 not upgraded.
 Need to get 42.9 MB of archives.
 After this operation, 323 MB of additional disk space will be used.
 Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 ebtables amd64 2.0.10.4-3.4ubuntu1 [79.6 kB]
 Get:2 http://archive.ubuntu.com/ubuntu xenial/main amd64 ethtool amd64 1:4.5-1 [97.5 kB]
 Get:3 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubernetes-cni amd64 0.5.1-00 [5560 kB]
 Get:4 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubelet amd64 1.6.4-00 [18.3 MB]
 Get:5 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubectl amd64 1.6.4-00 [9659 kB]
 Get:6 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubeadm amd64 1.6.4-00 [9234 kB]
 Fetched 42.9 MB in 5s (7779 kB/s)
 perl: warning: Setting locale failed.
 perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LC_TIME = "nl_NL.UTF-8",
 LC_MONETARY = "nl_NL.UTF-8",
 LC_ADDRESS = "nl_NL.UTF-8",
 LC_TELEPHONE = "nl_NL.UTF-8",
 LC_NAME = "nl_NL.UTF-8",
 LC_MEASUREMENT = "nl_NL.UTF-8",
 LC_IDENTIFICATION = "nl_NL.UTF-8",
 LC_NUMERIC = "nl_NL.UTF-8",
 LC_PAPER = "nl_NL.UTF-8",
 LANG = "en_US.UTF-8"
 are supported and installed on your system.
 perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
 debconf: unable to initialize frontend: Dialog
 debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76, <> line 6.)
 debconf: falling back to frontend: Readline
 Selecting previously unselected package ebtables.
 (Reading database ... 24924 files and directories currently installed.)
 Preparing to unpack .../ebtables_2.0.10.4-3.4ubuntu1_amd64.deb ...
 Unpacking ebtables (2.0.10.4-3.4ubuntu1) ...
 Selecting previously unselected package ethtool.
 Preparing to unpack .../ethtool_1%3a4.5-1_amd64.deb ...
 Unpacking ethtool (1:4.5-1) ...
 Selecting previously unselected package kubernetes-cni.
 Preparing to unpack .../kubernetes-cni_0.5.1-00_amd64.deb ...
 Unpacking kubernetes-cni (0.5.1-00) ...
 Selecting previously unselected package kubelet.
 Preparing to unpack .../kubelet_1.6.4-00_amd64.deb ...
 Unpacking kubelet (1.6.4-00) ...
 Selecting previously unselected package kubectl.
 Preparing to unpack .../kubectl_1.6.4-00_amd64.deb ...
 Unpacking kubectl (1.6.4-00) ...
 Selecting previously unselected package kubeadm.
 Preparing to unpack .../kubeadm_1.6.4-00_amd64.deb ...
 Unpacking kubeadm (1.6.4-00) ...
 Processing triggers for systemd (229-4ubuntu17) ...
 Processing triggers for man-db (2.7.5-1) ...
 Setting up ebtables (2.0.10.4-3.4ubuntu1) ...
 update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
 Setting up ethtool (1:4.5-1) ...
 Setting up kubernetes-cni (0.5.1-00) ...
 Setting up kubelet (1.6.4-00) ...
 Setting up kubectl (1.6.4-00) ...
 Setting up kubeadm (1.6.4-00) ...
 Processing triggers for systemd (229-4ubuntu17) ...

 

Running Kubeadm init

Now is time to start Kubeadm, if you followed all the steps until here, you are very likely to get a clean install of Kubeadm, however, this is Kubernetes, kubeadm is alpha and you may hit the wall:

 root@kubernetes-1:~# kubeadm init
 [kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters.
 [init] Using Kubernetes version: v1.6.4
 [init] Using Authorization mode: RBAC
 [preflight] Running pre-flight checks
 [preflight] The system verification failed. Printing the output from the verification:
 OS: Linux
 KERNEL_VERSION: 4.4.0-77-generic
 CGROUPS_CPU: enabled
 CGROUPS_CPUACCT: enabled
 CGROUPS_CPUSET: enabled
 CGROUPS_DEVICES: enabled
 CGROUPS_FREEZER: enabled
 CGROUPS_MEMORY: enabled
 DOCKER_VERSION: 1.11.2
 DOCKER_GRAPH_DRIVER: aufs
 [preflight] Some fatal errors occurred:
 failed to parse kernel config: unable to load kernel module "configs": output - "modprobe: FATAL: Module configs not found in directory /lib/modules/4.4.0-77-generic\n", err - exit status 1
 [preflight] If you know what you are doing, you can skip pre-flight checks with `--skip-preflight-checks`

 

This just happened to you ? Do not worry, we are not google cloud docs, we use the commands and if is not working, I will advise you the best way to deal with it:

 

Fixing the Kubeadm installation error: failed to parse kernel config: unable to load kernel module “configs”:

The best way to deal with this is to install the kernel module configs that kubeadm installation is checking for, and that can be real easy done with the following command:

root@kubernetes-1:~# apt-get install linux-image-$(uname -r)
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 Suggested packages:
 fdutils linux-doc-4.4.0 | linux-source-4.4.0 linux-tools linux-headers-4.4.0-77-generic
 The following NEW packages will be installed:
 linux-image-4.4.0-77-generic
 0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
 Need to get 21.9 MB of archives.
 After this operation, 66.8 MB of additional disk space will be used.
 Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 linux-image-4.4.0-77-generic amd64 4.4.0-77.98 [21.9 MB]
 Fetched 21.9 MB in 0s (22.1 MB/s)
 perl: warning: Setting locale failed.
 perl: warning: Please check that your locale settings:
 LANGUAGE = (unset),
 LC_ALL = (unset),
 LC_TIME = "nl_NL.UTF-8",
 LC_MONETARY = "nl_NL.UTF-8",
 LC_ADDRESS = "nl_NL.UTF-8",
 LC_TELEPHONE = "nl_NL.UTF-8",
 LC_NAME = "nl_NL.UTF-8",
 LC_MEASUREMENT = "nl_NL.UTF-8",
 LC_IDENTIFICATION = "nl_NL.UTF-8",
 LC_NUMERIC = "nl_NL.UTF-8",
 LC_PAPER = "nl_NL.UTF-8",
 LANG = "en_US.UTF-8"
 are supported and installed on your system.
 perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
 debconf: unable to initialize frontend: Dialog
 debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76, <> line 1.)
 debconf: falling back to frontend: Readline
 Selecting previously unselected package linux-image-4.4.0-77-generic.
 (Reading database ... 24989 files and directories currently installed.)
 Preparing to unpack .../linux-image-4.4.0-77-generic_4.4.0-77.98_amd64.deb ...
 debconf: unable to initialize frontend: Dialog
 debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
 debconf: falling back to frontend: Readline
 Done.
 Unpacking linux-image-4.4.0-77-generic (4.4.0-77.98) ...
 Setting up linux-image-4.4.0-77-generic (4.4.0-77.98) ...
 Running depmod.
 update-initramfs: deferring update (hook will be called later)
 Examining /etc/kernel/postinst.d.
 run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-77-generic /boot/vmlinuz-4.4.0-77-generic
 run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-77-generic /boot/vmlinuz-4.4.0-77-generic
 update-initramfs: Generating /boot/initrd.img-4.4.0-77-generic
 W: Possible missing firmware /lib/firmware/ast_dp501_fw.bin for module ast
 W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
 run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-77-generic /boot/vmlinuz-4.4.0-77-generic
 run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-77-generic /boot/vmlinuz-4.4.0-77-generic
 Generating grub configuration file ...
 Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
 Found linux image: /boot/vmlinuz-4.4.0-77-generic
 Found initrd image: /boot/initrd.img-4.4.0-77-generic
 done

 

Installing Kubeadm (No errors this time)

Now is time, for you to be finally from the cloud provider expensive fees, and get yourself a brand new kubernetes installation on your bare-metal server!!!! YEY!!!

 

 root@kubernetes-1:~# kubeadm init
 [kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters.
 [init] Using Kubernetes version: v1.6.4
 [init] Using Authorization mode: RBAC
 [preflight] Running pre-flight checks
 [certificates] Generated CA certificate and key.
 [certificates] Generated API server certificate and key.
 [certificates] API Server serving cert is signed for DNS names [kubernetes-1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 147.75.100.45]
 [certificates] Generated API server kubelet client certificate and key.
 [certificates] Generated service account token signing key and public key.
 [certificates] Generated front-proxy CA certificate and key.
 [certificates] Generated front-proxy client certificate and key.
 [certificates] Valid certificates and keys now exist in "/etc/kubernetes/pki"
 [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/kubelet.conf"
 [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/controller-manager.conf"
 [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/scheduler.conf"
 [kubeconfig] Wrote KubeConfig file to disk: "/etc/kubernetes/admin.conf"
 [apiclient] Created API client, waiting for the control plane to become ready
 [apiclient] All control plane components are healthy after 39.553551 seconds
 [apiclient] Waiting for at least one node to register
 [apiclient] First node has registered after 9.004966 seconds
 [token] Using token: 6b23b1.39a6163ce456f249
 [apiconfig] Created RBAC rules
 [addons] Created essential addon: kube-proxy
 [addons] Created essential addon: kube-dns

Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run (as a regular user):

 sudo cp /etc/kubernetes/admin.conf $HOME/
 sudo chown $(id -u):$(id -g) $HOME/admin.conf
 export KUBECONFIG=$HOME/admin.conf

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

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

 kubeadm join --token 6b23b1.39a6163ce456f249 147.75.100.45:6443

 

 

Configuring Kubeadm

So lets follow the install instructions and first we will make sure that the admin.conf is properly setup in our cluster, this will make sure the kubectl is pointing to the right place:

 sudo cp /etc/kubernetes/admin.conf $HOME/
 sudo chown $(id -u):$(id -g) $HOME/admin.conf
 export KUBECONFIG=$HOME/admin.conf

 

Adding two legs to the Kubernetes cluster:

In order to join other machines into the cluster its really easy, just run the suggested command by Kubeadm init, in the case of this tutorial is:

kubeadm join --token 6b23b1.39a6163ce456f249 147.75.100.45:6443

If you run this in two other servers and get back to master and run the following command, you should see the 3 legs of your cluster pumping and alive:

 root@kubernetes-1:~# kubectl get nodes
 NAME STATUS AGE VERSION
 kubernetes-1 NotReady 1h v1.6.4
 kubernetes-2 NotReady 2m v1.6.4
 kubernetes-3 NotReady 2m v1.6.4

 

Thats it, you have a cluster of 3 legs with Kubernetes on bare-metal server without having to do any hard thinking, just by following some simple steps. Easy huh ? 🙂

This is all for today, next time we will be following some more steps for installing the pod network and configuring helm charts, Stay tuned.

 

 

Happy coding everyone.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s