Build Kubernetes Cluster with Mirantis

Introduction

In this post we will build Kubernetes with Mirantis, which is formerly Docker Enterprise). It is the foundation of Kubernetes provided by Mirantis.

Environment

In this case environment will be very simple we will build Manager/Worker with a simple configuration one by one. The configuration will also include mgmt. host which will act as a management terminal. More about system requirements can be found in the link below.

Components that have been used

Vagrantfile:

Let’s Start

Since the launchpad requires an environment that allows ssh connection to each server from the mgmt. , first create and deploy the ssh key, and then install all required packages and construction tools on the mgmt. terminal.

Preparation

Create and deploy the ssh key

#Generate SSH Key in mgmt host
vagrant@mgmt:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/vagrant/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/vagrant/.ssh/id_rsa.
Your public key has been saved in /home/vagrant/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:LmswUxY65mcMd6/C1lnxJDi3mBX+7ttCV2KiuLOa7uU vagrant@mgmt
The key's randomart image is:
+---[RSA 2048]----+
| |
| . . |
| . . o . |
| = + + * o o .|
| o B .SO O o o |
| = +.+ = + . |
| B..o= o . |
| =** o. |
| =*oEo .oo. |
+----[SHA256]-----+
vagrant@mgmt:~$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDYw45xAKioMyJdVCel8Mjsc8xcYbvgqzVf6X8zNQBZbWIwINa+dsTFThkHA+WmQ9eW8/Zsb5kGhqNy7VnrqEBw84JI/F1hMzM1UYw8sspwCZpmlaHjs5JwX6Xsirkj7R8StxczPMci6S7DVyfZ4xRt8xd7SzNofD1BFQbY9Th5fnNKbByNaa4tILPbiP/VZPfdx/MYAMWkTRKHadUVrgJ291660T/MvCMgZTbN6RWY+plIyFUsbaiBt5JSQdcaQo0GoUYVW8XD5yetY+g50eKl2EXE35B59Zn7bhzYLamS1SKCvdTm2KMMn5r3khWJs2LcQNYkcD3Bb9xIUBt0d4YX vagrant@mgmt

Now we can save this key in host kube1 and kube2

#Host kube1. Edit file and paste key from mgmt host
vagrant@kube1:~$ nano .ssh/authorized_keys
#Host kube2. Edit file and paste key from mgmt host
vagrant@kube2:~$ nano .ssh/authorized_keys

Install necessary packages on mgmt. host.

vagrant@mgmt:~$ sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2
vagrant@mgmt:~$

Pre-installation preparation for kubectl

vagrant@mgmt:~$ sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - ^C
vagrant@mgmt:~$ sudo echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
vagrant@mgmt:~$ sudo apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:4 https://packages.cloud.google.com/apt kubernetes-xenial InRelease [9,383 B]
Get:6 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 Packages [47.0 kB]
Fetched 56.4 kB in 1s (37.9 kB/s)
Reading package lists... Done
vagrant@mgmt:~$ sudo apt-get install -y kubectl
vagrant@mgmt:~$ kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-12T14:18:45Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
vagrant@mgmt:~$

Download launchpad and install

vagrant@mgmt:~$ wget https://github.com/Mirantis/launchpad/releases/download/1.2.1/launchpad-linux-x64
vagrant@mgmt:~$ sudo mv launchpad-linux-x64 /usr/local/sbin/launchpad
vagrant@mgmt:~$ sudo chmod +x /usr/local/sbin/launchpad
vagrant@mgmt:~$ ls -laht /usr/local/sbin/launchpad
-rwxrwxr-x 1 vagrant vagrant 12M Apr 14 09:07 /usr/local/sbin/launchpad
vagrant@mgmt:~$
vagrant@mgmt:~$ launchpad version
version: 1.2.1
commit: b137ab8
vagrant@mgmt:~$

Build MKE

Now we are ready , use launchpad to build our MKE. Enter your user information before running launchpad as below:

vagrant@mgmt:~$ launchpad register
> Name ********
> Email ********
> Company ********
> I agree to Mirantis Launchpad Software Evaluation License Agreement https://github.com/Mirantis/launchpad/blob/master/LICENSE Yes
INFO Registration completed!
vagrant@mgmt:~$

Launchpad will be use the cluster configuration file (yaml) to build with, so we will need to create it.

Template we can create with vagrant@mgmt:~$ launchpad init > launchpad.yaml however the template is quite poor and needs to be adapted.

Generated template:

vagrant@mgmt:~$ cat launchpad.yaml
apiVersion: launchpad.mirantis.com/mke/v1.3
kind: mke
metadata:
name: my-mke-cluster
spec:
hosts:
- ssh:
address: 10.0.0.1
user: root
port: 22
keyPath: ~/.ssh/id_rsa
role: manager
- role: worker
mke:
version: 3.3.7
mcr:
version: 20.10.0
cluster:
prune: false
vagrant@mgmt:~$

Full configuration yml are below:

Let’s now launch our MKE using the launchpad. This can be done in two ways launchpad apply or launchpad apply --config mke.yml if your file name is different from launchpad.yaml because that is the default filename that is taken into account.

Output from console during installation

Access to cluster

After the installation is finished, we can get to our cluster. We should download client information for connection.

  • Via kubectl
vagrant@mgmt:/vagrant$ launchpad client-config --config mke.yml
INFO Note: The configuration has been migrated from a previous version
INFO to see the migrated configuration use: launchpad describe config
INFO ==> Running phase: Open Remote Connection
INFO [ssh] kube01.local:22: testing connection
INFO ==> Running phase: Detect host operating systems
INFO [ssh] kube01.local:22: is running Ubuntu 18.04.5 LTS
INFO ==> Running phase: Gather Facts
INFO [ssh] kube01.local:22: gathering host facts
INFO [ssh] kube01.local:22: is running mirantis container runtime version 20.10.0
INFO [ssh] kube01.local:22: using 192.168.123.124 as private IP
INFO [ssh] kube01.local:22: is running "Ubuntu 18.04.5 LTS"
INFO [ssh] kube01.local:22: internal address: 192.168.123.124
INFO [ssh] kube01.local:22: gathered all facts
INFO [ssh] kube01.local:22: MKE has version 3.3.7
INFO ==> Running phase: Validate Hosts
INFO validating hostname uniqueness
INFO ==> Running phase: Download Client Bundle
INFO Successfully wrote client bundle to /home/vagrant/.mirantis-launchpad/cluster/mke-test-cluster/bundle/admin
INFO ==> Running phase: Close Connection
INFO [ssh] kube01.local:22: disconnected
vagrant@mgmt:/vagrant$ cd /home/vagrant/.mirantis-launchpad/cluster/mke-test-cluster/bundle/admin && eval "$(<env.sh)" && cd ~
Cluster "ucp_kube01.local:6443_admin" set.
User "ucp_kube01.local:6443_admin" set.
Context "ucp_kube01.local:6443_admin" created.
vagrant@mgmt:~$
vagrant@mgmt:~$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
kube01 Ready master 9m38s v1.18.14-mirantis-1
kube02 Ready <none> 7m21s v1.18.14-mirantis-1
vagrant@mgmt:~$
  • Via web browser

Add entry in %SYSTEMROOT%\System32\drivers\etc\hosts

192.168.123.124 kube01.local

Now we can open https://kube01.local/login/ and provide login and password which we defined in the mke.yml file. After logging in, we can request trial license.

Login page:

Dashboard:

DevOps Consultant. I’m strongly focused on automation, security, and reliability.