Skip to content

Latest commit

 

History

History
162 lines (148 loc) · 5.68 KB

01.Prerequisites-VM-Configuration.md

File metadata and controls

162 lines (148 loc) · 5.68 KB

Prerequisites - VM configuration

This tutorial leverges VirtualBox to provision compute infrastructure required to bootstrap a Kubernetes cluster from groundup . All you need is a Windows system (or Linux system) with VirtualBox installed.

1) VirtualBox network configuration
  • Create HostOnly network with IP range 192.168.78.0
  • DHCP should be disabled on this network
  • Internet access is needed on all VMs (only for downloading stuffs)
  • A NAT network which can be leverged by VMs
+--------------------------------+
| VBox Host Networking           |
+---------------+----------------+
| HostOnly      | 192.168.78.0   |
| NAT           | VBOX Defined   |
+---------------+----------------+
2) Create a template VM which will be used to clone all needed VMs
  • You need atleast 50GB free space to host all VMs

  • All Vms will be placed in a directory called (Don't create these manually now!) DRIVE_NAME:/VMs/k8s_the_hardway/

  • Install Ubuntu 16.04 with latest patches

  • VM configuration

    • VM Name : Ubuntu16-template
    • Memory : 2 GB
    • CPU : 1
    • Disk : 100GB
    • NAT network interface : 1
    • HostOnly interface : 1 (ref. step 1).

NAT interface should be the first interface and HostOnly should be second

  • Install Ubuntu on this VM and go ahead with all default options

  • When asked prvide user name k8s and set password

  • Select below in Software Selection screen

  • Manual Software Selection

  • OpenSSH Server

  • After restart , make sure NAT interface is up

  • Login to the template VM with user k8s and execute below commands to install latest patches.

$ sudo apt-get update 
$ sudo apt-get upgrade 
  • Poweroff template VM
$ sudo poweroff
  • Open CMD and execute below commands to create all needed VMs. You can replace the valye of DRIVER_NAME with a drive which is having enough free space (~50GB)
 set DRIVE_NAME=D
 cd C:\Program Files\Oracle\VirtualBox
 VBoxManage.exe clonevm "Ubuntu16-template" --name "controller-01" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register
 VBoxManage.exe clonevm "Ubuntu16-template" --name "controller-02" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register  
 VBoxManage.exe clonevm "Ubuntu16-template" --name "controller-03" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register
 VBoxManage.exe clonevm "Ubuntu16-template" --name "worker-01" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register
 VBoxManage.exe clonevm "Ubuntu16-template" --name "worker-02" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register
 VBoxManage.exe clonevm "Ubuntu16-template" --name "worker-03" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register
 VBoxManage.exe clonevm "Ubuntu16-template" --name "lb-01" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register
 VBoxManage.exe clonevm "Ubuntu16-template" --name "lb-02" --groups "/K8S The Hard Way LAB" --basefolder "%DRIVE_NAME%:\VMs" --register
3) Start VMs one by one and perform below
  • IP Address and Hostname for each VMs
192.168.78.201 controller-01
192.168.78.202 controller-02
192.168.78.203 controller-03
192.168.78.211 worker-01
192.168.78.212 worker-02
192.168.78.213 worker-03
192.168.78.225 lb-01
192.168.78.226 lb-02
  • Assign IP address and make sure it comesup at boot
sudo systemctl stop networking
sudo vi /etc/network/interfaces

auto enp0s8
iface enp0s8 inet static
    address 192.168.78.X #<--- Replace X with corresponding IP octect
    netmask 255.255.255.0

sudo systemctl restart networking
  • You may access the VM using the IP via SSH and can complete all remaining steps from that session (for copy paste :) )
  • Change Host name
HOST_NAME=<host name> # <--- Replace <host name> with corresponding one
sudo hostnamectl set-hostname ${HOST_NAME} --static --transient 
  • Regenrate SSH Keys
sudo /bin/rm -v /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
  • Change iSCSI initiator IQN
sudo vi /etc/iscsi/initiatorname.iscsi 
InitiatorName=iqn.1993-08.org.debian:01:HOST_NAME  #<--- Append HostName to have unique iscsi iqn 
  • Change Machine UUID
sudo rm /etc/machine-id /var/lib/dbus/machine-id
sudo systemd-machine-id-setup
  • Add needed entries in /etc/hosts
sudo bash -c  "cat <<EOF >>/etc/hosts
192.168.78.201 controller-01
192.168.78.202 controller-02
192.168.78.203 controller-03
192.168.78.211 worker-01
192.168.78.212 worker-02
192.168.78.213 worker-03
192.168.78.225 lb-01
192.168.78.226 lb-02
192.168.78.220 lb
EOF"
  • Reboot VM
sudo reboot
  • Repeat the steps above for all VMs
  • Do a ping test to make sure all VMs can reach each other.
4) Make a note of below Pod CIDR assignment and Service IP range , which will be used later
+--------------------------------+
|        Pod CIDR range          |
+---------------+----------------+
| worker-01     | 10.10.1.0/24   |
| worker-02     | 10.10.2.0/24   |
| worker-03     | 10.10.3.0/24   |
+---------------+----------------+

+--------------------------------+
|       Service IP range         |
+---------------+----------------+
|       172.168.0.0/16           |
+---------------+----------------+

+--------------------------------+
|       Cluster Service IP       |
+---------------+----------------+
|       172.168.0.1              |
+---------------+----------------+

+--------------------------------+
|       DNS Service IP           |
+--------------------------------+
|       172.168.0.2              |
+--------------------------------+

Part 2 - A Virtual LoadBalancer for Highly available API server