Prerequisites
VM Hardware Requirements
8 GB of RAM (Preferably 16 GB) 50 GB Disk space
- Check if your system support virtualization and enabled the virtualization
Linux Find Out If CPU Support Intel VT
$ lscpu | grep -i virtualization
Virtualization: VT-x
If you see no output from above command then possibility are either your virtualization is not enabled from bios(link to enable) or you are using other CPU architecture(to check : link).
2. Install Virtual Box on Ubuntu/any Linux system
In mycase i have ubutntu(18.04) as my base OS.(Always check for latest virtualBox deb file)
Installation steps: https://www.virtualbox.org/wiki/Linux_Downloads
wget https://download.virtualbox.org/virtualbox/6.1.4/virtualbox-6.1_6.1.4-136177~Ubuntu~bionic_amd64.deb
sudo dpkg -i virtualbox-6.1_6.1.4-136177~Ubuntu~bionic_amd64.deb
3. Install Vagrant:
Download and Install Vagrant on your platform
https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb
sudo dpkg -i vagrant_2.2.7_x86_64.deb
When you hit virtualbox command on your terminal it should popup with oracle VM virtualBox manager application.
Also check the vagrant is all set.
$ vagrant --version
Vagrant 2.2.7
git clone https://github.com/rupin147/kubernetes_ubuntu_vagrant_setup
cd kubernetes_ubuntu_vagrant_setup/
vagrant up
Once the vagrant up command execution is completed.
$ vagrant status
Current machine states:
master-1 running (virtualbox)
worker-1 running (virtualbox)
worker-2 running (virtualbox)
VM | VM Name | Purpose | IP Address |
master-1 | kubernetes-master-1 | Master | 192.168.5.11 |
worker-1 | kubernetes-slave-1 | Worker | 192.168.5.21 |
worker-2 | kubernetes-slave-2 | Worker | 192.168.5.22 |
SSH to the nodes
From the directory you ran the vagrant up
command, run vagrant ssh <vm>
for example vagrant ssh master-1
.
Note: Use VM field from the above table and not the vm name itself.
Run vagrant ssh <vm> Always from the same directory where your your Vagrant was installed beause it creates a .vagrant directory under same path in which private key are present, else it will not work $ vagrant ssh master-1 Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-76-generic x86_64)Last login: Fri Feb 21 17:34:13 2020 from 10.0.2.2 vagrant@master-1:~$ kubectl get nodes NAME STATUS ROLES AGE VERSION master-1 Ready master 33m v1.17.3 worker-1 Ready 17m v1.17.3 worker-2 Ready 8m3s v1.17.3 vagrant@master-1:~$
Run kubectl command from vagrant user not from the root user.
kubectl run nginx --image=nginx
SSH Using SSH Client Tools
Private Key Path: .vagrant/machines/<machine name>/virtualbox/private_key
Username: vagrant