I will be simulating a data center using Kubernetes on my laptop using Oracle Virtual Box. Listed below are software i have used for this exercise:

  • Oracle VM VirtualBox 6.0
  • Red Hat Linux 7.6

I will created 3 virtual machines: kmaster, knode1 and knode2 running Red Hat Linux 7.6

Navigate to Settings > Network for each virtual machine to set Bridge Adapter for each of them.

NOTE: Since this is my first simulation, we will go easy and use Rancher, an open source software to deploy and manage Kubernetes cluster for free. It uses docker containers.

Configuring Kubernetes Master

Check if docker-engine package is available as below:

yum info docker*

docker is not available in default Red Hat repos. Also, since we will be using Rancher for this demo, we would prefer installing a stable supported ce (community edition) of docker. Please refer to below link for supported docker versions.

https://rancher.com/docs/rancher/v1.6/en/hosts/#supported-docker-versions

I am going to install the most recent at the moment, 18.09.x-ce. For this, execute below command as root user.

curl https://releases.rancher.com/install-docker/18.09.sh | sh

This gave me below error:

adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
Could not fetch/save url https://download.docker.com/linux/centos/docker-ce.repo to file /etc/yum.repos.d/docker-ce.repo: [Errno 12] Timeout on https://download.docker.com/linux/centos/docker-ce.repo: (28, ‘Operation timed out after 30002 milliseconds with 0 out of 0 bytes received’)

Same error can be reproduced if i try to run below command:

yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo

To overcome the error, i added below workaround in /etc/yum.conf file.

#Adding timeout for docker-ce.repo
timeout=120

Now, try the curl command again.

curl https://releases.rancher.com/install-docker/18.09.sh | sh

Below is the output:

[root@kmaster ~]# curl https://releases.rancher.com/install-docker/18.09.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 15429 100 15429 0 0 72 0 0:03:34 0:03:33 0:00:01 3242
‘[‘ redhat = redhat ‘]’
for rhel_repo in ‘$rhel_repos’
sh -c ‘yum-config-manager –enable rhel-7-server-extras-rpms’
Loaded plugins: langpacks, product-id, subscription-manager
=============================================================== repo: rhel-7-server-extras-rpms ===============================================================
[rhel-7-server-extras-rpms]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7Server
baseurl = https://cdn.redhat.com/content/dist/rhel/server/7/7Server/x86_64/extras/os
cache = 0
cachedir = /var/cache/yum/x86_64/7Server/rhel-7-server-extras-rpms
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = True
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7Server/rhel-7-server-extras-rpms/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7Server/rhel-7-server-extras-rpms/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
hdrdir = /var/cache/yum/x86_64/7Server/rhel-7-server-extras-rpms/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 86400
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = Red Hat Enterprise Linux 7 Server – Extras (RPMs)
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7Server/rhel-7-server-extras-rpms
pkgdir = /var/cache/yum/x86_64/7Server/rhel-7-server-extras-rpms/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert = /etc/rhsm/ca/redhat-uep.pem
sslclientcert = /etc/pki/entitlement/3339265060502979054.pem
sslclientkey = /etc/pki/entitlement/3339265060502979054-key.pem
sslverify = True
throttle = 0
timeout = 120.0
ui_id = rhel-7-server-extras-rpms/x86_64
ui_repoid_vars = basearch
username =
for rhel_repo in ‘$rhel_repos’
sh -c ‘yum-config-manager –enable rhui-REGION-rhel-server-extras’
Loaded plugins: langpacks, product-id, subscription-manager
for rhel_repo in ‘$rhel_repos’
sh -c ‘yum-config-manager –enable rhui-rhel-7-server-rhui-extras-rpms’
Loaded plugins: langpacks, product-id, subscription-manager
for rhel_repo in ‘$rhel_repos’
sh -c ‘yum-config-manager –enable rhui-rhel-7-for-arm-64-extras-rhui-rpms’
Loaded plugins: langpacks, product-id, subscription-manager
sh -c ‘yum install -y -q yum-utils’
Package yum-utils-1.1.31-52.el7.noarch already installed and latest version
sh -c ‘yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo’
Loaded plugins: langpacks, product-id, subscription-manager
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
‘[‘ stable ‘!=’ stable ‘]’
sh -c ‘yum makecache fast’
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
docker-ce-stable | 3.5 kB 00:00:00
rhel-7-server-extras-rpms | 3.4 kB 00:00:00
rhel-7-server-optional-rpms | 3.2 kB 00:00:00
rhel-7-server-rpms | 3.5 kB 00:00:00
rhel-server-rhscl-7-rpms | 3.4 kB 00:00:00
(1/2): docker-ce-stable/x86_64/primary_db | 33 kB 00:01:59
(2/2): docker-ce-stable/x86_64/updateinfo | 55 B 00:01:59
Metadata Cache Created
sh -c ‘yum install -y -q docker-ce-18.09.8’
warning: /var/cache/yum/x86_64/7Server/docker-ce-stable/packages/docker-ce-18.09.8-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-18.09.8-3.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
Userid : “Docker Release (CE rpm) docker@docker.com
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://download.docker.com/linux/centos/gpg
‘[‘ -d /run/systemd/system ‘]’
sh -c ‘service docker start’
Redirecting to /bin/systemctl start docker.service
sh -c ‘docker version’
Client: Docker Engine – Community
Version: 19.03.2
API version: 1.39 (downgraded from 1.40)
Go version: go1.12.8
Git commit: 6a30dfc
Built: Thu Aug 29 05:28:55 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine – Community
Engine:
Version: 18.09.8
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 0dd43dd
Built: Wed Jul 17 17:10:42 2019
OS/Arch: linux/amd64
Experimental: false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the “docker” group with something like:
sudo usermod -aG docker your-user
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the “docker” group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.

Verify what docker packages have been installed.

yum info docker*

Once installation is complete, start the docker service.

systemctl start docker

Check, if the service has been started successfully.

systemctl status docker

Next, install Rancher server.

docker run -d –restart=unless-stopped -p 8080:8080 rancher/server:stable

Find your master node’s IP using ifconfig command.

ifconfig

Go to 192.168.1.95:8080 on your browser, to launch Rancher.

Navigate to Default > Manage Environment as below:

Click “Add Environment”

Select Environment Template as “Kubernetes” and give your environment a suitable name.

Click on “Create” button, to create your Kubernetes environment.

Adding a Kubernetes node

Install docker similar to Kubernetes master node.

curl https://releases.rancher.com/install-docker/18.09.sh | sh

Start docker service and verify the status

systemctl start docker
systemctl status docker

Now, we are ready to add this host to Kubernetes environment. Navigate to Infrastructure > Hosts > Add Host

Please note, while adding host, you should have correct environment selected.

Select or specify host registration URL and click save.

Now, carefully read the steps as shown on the next screen.

I ran the command in step 5 on node knode1.

Navigate to your Kubernetes environment, “k-ravlab” in this case. This will show the status as below:

Once, all services are started, you get below screen.

Add additional node/host

Follow the steps above to add additional node. I have named it as knode2.ravlab.com

The second node has been added as shown below:

What we built so far?

Before i start creating sample services, let’s take a quick look of what we built so far.