K8S-Course 02: Installing the kubernetes Lab – part 1

Tram Ho


In this article, I introduce how to use VMware Workstation Pro software on windows to create virtual machines (VMs). Then install kubernetes onto these VMs.


Requirements: Have a configuration server with 16GB RAM or more (8GB or 12GB is also possible but it will not be guaranteed) The server installs win10/win11/winserver and most importantly, the machine must have an internet connection (to download) package, docker image..) The architecture of the lab system will be as follows: image.png

I plan to install the machines with the following information:

Virtual machineRoleIPRAMCPUHDDNote
master1master192.168.10.11 (NAT)2GB2 cores30GBWill install more haproxy
worker1worker192.168.10.12 (NAT)4GB2 cores30GBWill install more rancher
worker2worker192.168.10.13 (NAT)4GB2 cores30GB + 30GBWill install more nfs-server
kubesprayinstallation server192.168.10 (NAT)2GB2 cores30GB

Note: The above RAM/CPU configuration is an example with a 16GB RAM case, if you have more, you can increase it for comfort. Note that the configuration of k8s node is at least 2GB of RAM.

Basically, install VMware Workstation on your PC to create virtual machines. Create 3 virtual machines running Centos7 (master1, worker1, worker2) to install k8s, kubespray virtual machine to be the installation server. From this kubespray virtual machine, I will install k8s on the above 3 nodes.

On the PC will install mobaxterm (or puty or SSH-Client you are familiar with) to connect to k8s after installation.

Steps to take

I will show you how to install the kubernetes lab system in the main steps (assuming you already have a windows PC)

  • Install VMware Workstation Pro on Windows PC + Configure network for vmware
  • Install a new VM using Centos7 + configure basic parameters
  • Clone the above VM into 04 VMs with names respectively: master1, worker1, worker2 and kubespray
  • Update hostname, IP.. for new cloned VMs
  • Configure the kubespray virtual machine to prepare for the installation of k8s
  • Parameter configuration for k8s installation + installation using kubespray

Detailed instructions

Install VMware Workstation Pro

You refer to the link to download and install VMware Workstation Pro here . Basically, only next is done, then I don’t give further instructions.

Network Configuration for VMware Workstation Pro

This step is for the purpose of setting up the IP range I will use for virtual machines (VMs) later. To do this, open VMware Workstation Pro and go to edit ==> Virtual Network Editor ==> Select the network type as NAT :


Here, I guide you to use NAT, then the VMs will be given a private IP in the range that you set in the Subnet IP section. You can set up this range arbitrarily, here I recommend using the range mask (as shown).

Centos7 installation guide and parameter configuration

Install centos7 on a virtual machine (VM)

First you download the Centos7 installer here , remember to choose the right file ” CentOS-7-x86_64-Minimal-2009.iso ” for it to be lightweight!

After downloading the file to your computer, open VMware Workstation Pro to prepare to install a new VM. You go to File ==> New Virtual Machine.. ==> Typical ==> Next ==> Installer disc image file (iso): ==> Point to the centos iso file that you downloaded to your computer in the previous step ==> next

Continue to enter the name of the VM (the name displayed on VMworkstation Pro) and the place where you want to save this virtual machine ==> Next:


In the “Maximum disk size (GB)” section, select the size of 30GB, tick ” Split virtual disk into multiple files ==> Next.

Almost done, now it’s time to configure the resources for the virtual machine. Tick ​​” Poweron this virtual machine after creation ” and click Customize Hardware… :


Here are a few points to note:

  • Memory: Choose 2048 (2GB)
  • Processors: Select 1 processor * 2 cores. If your computer has a good chip, it can be increased accordingly. image.png
  • Network Adapter: Tick the checkbox ” NAT: Used to share the host’s IP address image.png

Okie, now click Finish to start the installation. In this interface, press Enter to do it quickly without having to wait for tens of seconds:


In the first interface, select English language: image.png

Next in this interface we will configure the time (datetime), installation partition (INSTALLATION DESTINATION) and network.


Select DATE & TIME and set the server time + set timezone to HCM ==> Press Done when done.


Continue to select ” INSTALLATION DESTINATION ” ==> Select the 30GB drive that we created ==> Done


Next is to configure Hostname and network. First enter hostname as centos7 ==> Apply. Next enable the Ethernet network (ens33) to make it green as shown:


Click on Configure… to configure the IP for it:

image.png We select the IPv4 Settings tab and select the Method from “DHCP” to “Manual”, press the Add button and set the following parameters:


The DNS I set is 2 DNS of google so that the VM can connect to the internet:,

The reason here I set the IP as is to avoid the IPs I have planned for the nodes. Later, when I clone this virtual machine, I will correct the IP according to the plan.

After completing the above step, we click Begin Installation to begin the installation of Centos 7. Next we need to set the password for the root user by clicking on ROOT PASSWORD and entering the password twice.


Click on USER CREATION to create a super user named sysadmin: image.png

Please note the password for this root and sysadmin user for future use!

When the installation is complete, there will be a message to reboot the virtual machine, click reboot :


After reboot we can login with the user/pass created above and check the IP of the virtual machine:


So it has been successfully assigned IP already.

Next, we use SSH client software to connect to it, making it easier to operate than directly on the console of VMware workstation.

Configuring parameters for virtual machines

First we configure the sysadmin user to have sudo privileges without a password. We edit the file /etc/sudoers and add the following line at the end of the file:

Then we need to check and disable swap on centos. Use the following command to check:

So the system is using swap, and has the mount in the fstab configuration.

To disable swap we do 2 things:

  • Use the command disable swap:

  • Remove the line mount swap in the file /etc/fstab (if there is a line with swap, comment it with a “#” at the beginning of the line:

Here you download this repo to your computer to get the initial installation script files: https://github.com/rockman88v/kubernetes_basic_course.git

In the session02-Installation/scripts folder, you copy 2 files ” update-vm.sh ” and ” configure-vm.sh ” to the virtual machine in the /home/sysadmin directory (the root directory of the sysadmin user). Then assign execute permissions to these two script files and run the configure-vm.sh script:

Basically, you have installed and configured a virtual machine ready for the installation of k8s later. We will shutdown any virtual machine to clone it into virtual machines for installation.

Shutdown the virtual machine from the current ssh session:

Clone virtual machine

Go to VMware Workstation and select the virtual machine we just installed ==> Right-click and select Manage ==> Clone ==> Next ==> Next ==> Create a full clone: image.png

First, we clone into the master1 virtual machine, we name it and choose the folder to save the virtual machine:


After completing, we select the new virtual machine to clone (master1) ==> Right-click ==> Setting and adjust RAM/CPU/HDD parameters as initial planning.

Repeat the step of cloning the virtual machine into worker1, worker2 and kubespray machines (note the adjustment of RAM/CPU/HDD parameters as in the initial planning).

As for the worker2 virtual machine, we will add it a new disk of 30GB capacity (later as an NFS server to install the storage class that will be used in the following lessons): Right-click the worker2 virtual machine ==> Manage ==> Add. .. ==> Hard Disk ==> SCSI ==> Create a new virtual disk ==> Set space to 30GB + tick split virtual disk into multiple files ==> Next ==> Finish ==> OK

At the end of the clone process, we have 04 virtual machines according to the design .

Update hostname, IP for new cloned VMs

After cloning the 4 virtual machines, we will turn on each virtual machine to reconfigure the correct hostname/IP according to planning (because of the full clone, all 4 virtual machines are being set with the same hostnam/IP).

For example with master1 we turn it on, and update the hostname/IP with the command below:


It should be done on the console of VMware Workstation because after running the VM’s IP will change to the correct planning. So if SSH from an SSH Client, it will lose connection after running the script

So the hostname and IP have been updated.

Do the same with the rest of the virtual machines.

As for the worker2 virtual machine , we need one more step to mount a new disk for it (in the previous step we added a disk for it).

So the new disk is at /dev/sdb . We mount the following:

So the new disk has been mounted to /nfs-data. We need to configure more in /etc/fstab so that after reboot it will be mounted again. We add the following line to the file:

So here we have basically finished setting up 04 VMs with the correct configuration according to the original planning :

Virtual machineRoleIPRAMCPUHDDNote
master1master192.168.10.11 (NAT)2GB2 cores30GBWill install more haproxy
worker1worker192.168.10.12 (NAT)4GB2 cores30GBWill install more rancher
worker2worker192.168.10.13 (NAT)4GB2 cores30GB + 30GBMounted to /nfs-data
kubesprayinstallation server192.168.10 (NAT)2GB2 cores30GB

In the next section, we will configure the kubespray VM to install the k8s cluster .


Share the news now

Source : Viblo