U1.27 Ubuntu Quick Start (QS): Installing Kubernetes on premises with Kubespray. - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki

Starting with

  • Pre-installed DHCP in the virtual environment (for example, a hardware implementation of a DHCP server in a modem)

  • Deploy three Ubuntu 20.04 TLS virtual machines. Consult the articles U1.01 and U1.02

    • Device name = u200401, ip = 192.168.100.12
    • Device name = u200402, ip = 192.168.100.13
    • Device name = u200403, ip = 192.168.100.17
  • For each machine u200401, u200402, u200403

    • run the command python3 --version
      • In our case it returns : Python 3.8.10
  • For each machine u200401, u200402, u200403

    • we have sudo-enabled user = yury with identical password for each machine

u200401, u200402, u200403 with openssh-server installed

  • For each machine u200401, u200402, u200403
    • run the command
sudo apt install openssh-server

u200401 with Kubespray installed

  • For the machine u200401
    • run the commands (no sudo prefix for the first four commands)
ssh-keygen
ssh-copy-id 192.168.100.12
ssh-copy-id 192.168.100.13
ssh-copy-id 192.168.100.17

sudo apt-get install python3-pip
sudo pip3 install --upgrade pip
sudo apt-get install git

Important notes

Installation steps

  • Step 1: clone kubespray.git
    • run the command (no sudo prefix for this command)
git clone https://github.com/kubernetes-sigs/kubespray.git
  • Note: now we need to repeat the commands from the Quick Start section
Click to show code
# Install dependencies from ``requirements.txt``
sudo pip3 install -r requirements.txt

# Copy ``inventory/sample`` as ``inventory/mycluster``
cp -rfp inventory/sample inventory/mycluster

# Update Ansible inventory file with inventory builder
declare -a IPS=(10.10.1.3 10.10.1.4 10.10.1.5)
CONFIG_FILE=inventory/mycluster/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}

# Review and change parameters under ``inventory/mycluster/group_vars``
cat inventory/mycluster/group_vars/all/all.yml
cat inventory/mycluster/group_vars/k8s_cluster/k8s-cluster.yml

# Deploy Kubespray with Ansible Playbook - run the playbook as root
# The option `--become` is required, as for example writing SSL keys in /etc/,
# installing packages and interacting with various systemd daemons.
# Without --become the playbook will fail to run!
ansible-playbook -i inventory/mycluster/hosts.yaml  --become --become-user=root cluster.yml
  • Step 2: cd kubespray
    • run the command
cd kubespray
  • Step 3: Install dependencies from requirements.txt
sudo pip install -r requirements.txt
Click to show the picture

picture

  • Step 4: Copy inventory/sample as inventory/cluster
    • run the command
      • it creates cluster subfolder
cp -rfp inventory/sample inventory/cluster
  • Step 5: Update Ansible inventory file
    • run the commands
declare -a IPS=(192.168.100.12 192.168.100.13 192.168.100.17)
CONFIG_FILE=inventory/cluster/hosts.yaml python3 contrib/inventory_builder/inventory.py ${IPS[@]}
  • Step 6: Review inventory/cluster/hosts.yaml
    • run the command
cat inventory/cluster/hosts.yaml
Click to show the picture

picture

  • Step 7: Review parameters under inventory/mycluster/group_vars
    • run the commands
cat inventory/cluster/group_vars/all/all.yml
cat inventory/cluster/group_vars/k8s_cluster/k8s-cluster.yml
  • Step 8: Modify kube_version
nano inventory/cluster/group_vars/k8s_cluster/k8s-cluster.yml
Click to show the picture

picture

  • Step 9: Deploy Kubespray with Ansible Playbook
    • run the commands
ansible-playbook -i inventory/cluster/hosts.yaml  --become --become-user=root -K cluster.yml
  • Here is a result
Click to show the picture

picture

Memory usage

  • We have set dynamic memory usage for each virtual machine.
  • Please take a look at the picture below
    • Note: No Pods have been deployed yet

picture

Memory usage no GUI

Note: how to enable/disable GUI for Ubuntu 20.04

  • To disable GUI
    • run the commands
sudo systemctl set-default multi-user
sudo reboot
  • To enable GUI
    • run the commands
sudo systemctl set-default graphical
sudo reboot

Starting with

  • Deploy four Ubuntu 20.04 TLS virtual machines. Consult the articles U1.01 and U1.02
Click to show the picture

picture

  • Ubuntu200401, Ubuntu200402, Ubuntu200403 machines will be used for Kubernetes
  • UbuntuAnsible machine will be used to run Kubespray
  • for Ubuntu200401, Ubuntu200402, Ubuntu200403 machines
    • To disable GUI
      • we ran the following commands
sudo systemctl set-default multi-user
sudo reboot
  • As a next step on UbuntuAnsible machine
    • we launched ** Cubesprey **
      • here is a result
Click to show the picture

picture

  • After Kubernetes started on Ubuntu200401, Ubuntu200402, Ubuntu200403 machines
    • we have
Click to show the picture

picture

  • it's better than before, but still very high memory consumption

Checking real memory consumption from inside virtual machines

  • run the commands
free -m
ls -l /proc/swaps
  • in the current installation node1 belongs only to the Control Plane group
Click to show the picture for the node1 (Ubuntu200401)

picture

  • in the current installation node2 belongs to the Control Plane group as well as the Worker Node group
Click to show the picture for the node2 (Ubuntu200402)

picture

  • in the current installation node3 belongs only to the Worker Node group
Click to show the picture for the node3 (Ubuntu200403)

picture

  • Summary:

HOWTOs

⚠️ **GitHub.com Fallback** ⚠️