Lab VMs Setup
In our lab sessions we are assigning some IP ranges for each of you. Please refer to the IP allocation table [https://ws.learn.ac.lk/wiki/containerization2023Agenda/IPAllocation here].
First for your computer assign the IP address given as 'Host Machine
'.
For this workshop we need to create 3 VMs in total. VMs are named as 'Master Node, Worker Node 1 and Worker Node 2
'. Accordingly we have given the relevant IP addresses for those as well in the table. But for this Lab session we only need a single a VM. Later you may create other 2 VMs.
Let's create a VM and give it the IP address allocated for 'Master Node
'.For this we are going to use Oracle Virtual Box 7.0 latest. If you haven't installed it on your computer download and install it.Install Virtual Box software with default settings, make sure you have enabled virtualization support from your host machine BIOS.
For all 3 VMs, we are going to Ubuntu 22.04 latest as the Operating System. For the Lab we are providing with a you a preinstalled Virtual Appliance file and you can download it from this [http://192.248.4.233/ws-files/ubuntu-22.ova link].
Import downloaded virtual appliance file (OVA file) into Oracle virtual box from File > Import Appliance.
While importing make sure to select 'Generate new MAC addresses for all Network Adapters
' from 'MAC Address Policy
'. Also you may change the field Name. For this Lab we recommend to have 4GB RAM and 4 CPU cores. You may change fields accordingly. Click finish to import the appliance.
Select the VM from left panel on Virtual box, right click and open Settings. Go to 'Network
' menu and on Adapter 1 choose 'Attached to
' be Bridged Adapter, then select the name of the network adapter currently you are connecting to the lab network.
Then start the VM using Green arrow button.
Once the VM is started login to the VM using below credentials.
'username : user
'
'password : Learn2023
'
Now your VM should have an IP address assigned through DHCP. To view the IP address and network adapter details enter the following command.
'
ip addr show
'
But we need to assign the correct IP address manually which is given in this [https://ws.learn.ac.lk/wiki/containerization2023Agenda/IPAllocation table]. To configure the IP address need to edit the configuration file in /etc/netplan directory. In this case file will be 00-installer-config.yaml.
'
sudo nano /etc/netplan/00-installer-config.yaml
'
edit the file as below. Please be careful about correct indentation and to avoid tab characters and following spaces. Only use spacebar to get spaces from left. Here each line start have indentations of 2,4,6,8,.. etc from the left.
'
network:
renderer: networkd
ethernets:
enp0s3:
addresses:
- 192.248.X.Y/23
nameservers:
addresses: [192.248.1.161,1.1.1.1]
routes:
- to: default
via: 192.248.111.254
version: 2
'
Save the configuration file. Enter below to apply the changes.
'
sudo netplan apply
'
check the IP address change and connectivity.
'
ip addr show
ping 192.248.1.161
'
Once the network configuration is complete you may go ahead with renaming the hostname. Please add a meaningful name the VM. Since here we have 3 VMs for Kubernetes master and 2 worker nodes, you may have similar names like master, worker1, worker2 for each VMs. Since we are going to use the current VM as the master node in the next hands-on session you may name it as master or with a similar name.For this enter below commands.
'
sudo hostnamectl set-hostname master
'
Next change the hostname entry in the /etc/hosts file.
'
sudo nano /etc/hosts
'
'
127.0.0.1 localhost
127.0.1.1 master
'
This ubuntu installation by default may include cdrom repository to the apt sources.list. We need remove it because no cdrom is attached.
'
sudo nano /etc/apt/sources.list
'
Comment out the following line
'
#deb [check-date=no] file:/cdrom jammy main restricted
'''
Now the Ubuntu VM is ready and you can go ahead with Docker installation.