U1.27 Ubuntu Quick Start (QS): Installing Kubernetes on premises with Kubespray. - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki
-
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
- run the command python3 --version
-
For each machine u200401, u200402, u200403
- we have sudo-enabled user = yury with identical password for each machine
- For each machine u200401, u200402, u200403
- run the command
sudo apt install openssh-server
- 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
- read the article Installing Kubernetes with Kubespray
- read the article Kubespray git
- visit this site kubespray.io
- read the article Kubernetes Release History
- in our case it's 1.22.3
-
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
- read the article Requirements files
- run the command
sudo pip install -r requirements.txt
Click to show the picture
-
Step 4: Copy inventory/sample as inventory/cluster
- run the command
- it creates cluster subfolder
- run the command
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
-
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
- read the article Kubernetes Release History
- in our case it's 1.22.3
- run the commands (no sudo prefix for the command)
- read the article Kubernetes Release History
nano inventory/cluster/group_vars/k8s_cluster/k8s-cluster.yml
Click to show the 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
- 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
- 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
Click to show the 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
- To disable GUI
sudo systemctl set-default multi-user
sudo reboot
- As a next step on UbuntuAnsible machine
- we launched ** Cubesprey **
- here is a result
- we launched ** Cubesprey **
Click to show the picture
- After Kubernetes started on Ubuntu200401, Ubuntu200402, Ubuntu200403 machines
- we have
Click to show the picture
- it's better than before, but still very high memory consumption
- 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)
- 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)
- in the current installation node3 belongs only to the Worker Node group
Click to show the picture for the node3 (Ubuntu200403)
-
Summary:
- swapping of all nodes is disabled
- memory consumption of all nodes is acceptable
- for comfortable development and testing of deployment, we will need a second home data-center
- read this article Remotely manage Hyper-V hosts with Hyper-V Manager