Prepare Virtual Machine using Virtualbox and Ubuntu
Tags: kubernetes, virtualbox, ubuntu
Published: 2018-11-03 06:52:42

---
title: Prepare Virtual Machine using Virtualbox and Ubuntu
published: true
description: 
tags: #kubernetes,#virtualbox,#ubuntu
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q2p9gyw9x5r57bc0h38p.jpg
---
[image1]: https://thepracticaldev.s3.amazonaws.com/i/o4r7iptl0xos4cxizdgi.png "In the end"
[image2]: https://thepracticaldev.s3.amazonaws.com/i/ms7949bf014nnmhx6mbk.png "Create1"
[image3]: https://thepracticaldev.s3.amazonaws.com/i/37eypv0vb11ns294eqei.png "Create2"
[image4]: https://thepracticaldev.s3.amazonaws.com/i/09wude0rg0qg58hg9iu9.png "Create3"
[network]: https://thepracticaldev.s3.amazonaws.com/i/m5nxilmrzyber68rftzj.png "Network setup"
[storage]: https://thepracticaldev.s3.amazonaws.com/i/sc27y1ps1m7kikugv5wb.png "Storage setup"
[nodes]: https://thepracticaldev.s3.amazonaws.com/i/4fddk9wysfovzfu9fkew.png "All nodes"
[ubuntu1]: https://thepracticaldev.s3.amazonaws.com/i/1j12qxi66tkk1x2wjxo8.png "Setup1"
[ubuntu2]: https://thepracticaldev.s3.amazonaws.com/i/d0tsq1tvwkwaavliki2a.png "Setup2"
[ubuntu3]: https://thepracticaldev.s3.amazonaws.com/i/4hkuzvn3c7n10blwpopc.png "Hostname"
[ubuntu4]: https://thepracticaldev.s3.amazonaws.com/i/b5okajzglphrir9vylra.png "Username"
[ubuntu5]: https://thepracticaldev.s3.amazonaws.com/i/cr9qudcufjnja4r4p52f.png "Software"
[ubuntu6]: https://thepracticaldev.s3.amazonaws.com/i/gykthxw2j1pdva1up3ni.png "GRUB"

This post will guide you to create 4 virtual machine based on Ubuntu Server. One designated to be kubernetes master node and the other three as worker nodes.

This is part of [Setup your own kubernetes cluster on VMs](https://dev.to/pongsatt/setup-your-own-kubernetes-cluster-on-vms-5ln) series.

**Note:**
> This guide is based on Windows but since it's a virtual machine, others OS shouldn't be different

##Prerequisite:##
- Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
- Download [Ubuntu 16.04 Image for VirtualBox](https://www.virtualbox.org/wiki/Linux_Downloads) or [64bit Direct link](https://download.virtualbox.org/virtualbox/5.2.20/virtualbox-5.2_5.2.20-125813~Ubuntu~xenial_amd64.deb)
- Available 2GB of RAM per VM (4 nodes will need at 8GB). You can reduce number of nodes depending on your available RAM
- 10-30GB of disk space per VM (4 nodes will need around 100GB)


##In the end##
You will get something like this.

![At the end][image1]

#1. Create Virtual Machine#

We will create 4 virtual machines. 1 machine is for kubernetes master and the reset for worker node. They're all mostly the same except hostname. RAM and cpu can be adjusted based on your need. In theory, master node will need less resource comparing to worker node.

###1.1. Create New Virtual Machine###

   *Name:* k8smaster
   *Type:* linux
   *Memory:* 2048MB

![Step1][image2]

###1.2. Choose harddisk size###
  
   *Size:* 10GB

![Step2][image3]

![Done][image4]

#2. Prepare VM before install OS#

###2.1. Setup network###

We will use bridge network so we have the real network ip address that can talk to the outside world.

- Click "Settings" then "Network".
- Select "Attached to" as "Bridged Adapter"
- Click "Advance"
- Write down "MAC Address" to reserve IP address so that your IP will not change every time the VM restarted

![][network]

###2.2. Setup Ubuntu image to be installed###

- Click "Settings" then "Storage"
- Click "Adds optical drive" at the top right corner
- Select os image (.iso) you downloaded
- Click OK

![][storage]

#3. Create the rest VMs#

Repeat step 1 and 2 with below information
- Name: kubenode1, kubenode2, kubenode3
- RAM: 2048GB (or more)
- Disk: 32GB (or less)

![][nodes]

#4. Setup Ubuntu#

###4.1 Start VM (kubemaster)###

Click "Start" button icon.

Ubuntu setup screen will be shown as below.

![][ubuntu1]

Select "Install Ubuntu Server

![][ubuntu2]

###4.2 Set Hostname###

Follow instructions until this screen and fill "kubemaster" as hostname.

![][ubuntu3]

###4.3 Set user name###

Fill in "Full name", "username" and "password" as needed. Please make note these information.

![][ubuntu4]

###4.4 Other information###
- "Encrypt your home directory?" : No
- "Partition disk" : "Guided - use entire disk"
- "Write the changes to disks?" : Yes
- "HTTP proxy information" : leave blank (if you are outside company proxy)
- "How do you want to manage upgrades on this system?" : No automatic updates
- "Software selection" : select "OpenSSH server" (This is required if you want you connect to your server remotely using ssh command)

![][ubuntu5]

###4.5 Install GRUB boot loader###

Select "Yes" then "Finish Installation"

![][ubuntu6]

#5. Setup Ubuntu for the rest VMs#

Repeat step 4 for "kubenode1" to "kubenode3"

**Note:**
> - Don't forget to change hostname to "kubenode1" to "kubenode3" in step 4.2
> - Username and password can be the same for all VMs

#Summary#

Now, you have all the VMs with network and ready to setup kubernetes cluster in the [next step](https://dev.to/pongsatt/setup-kubernetes-cluster-using-kubeadm-hpb).