Hi Readers, Virtual machine is a compute resource that uses the virtual resource instead of a physical computer to run and deploy applications. One of the use cases of VMs could be providing one application resource to multiple users at once in a cost-efficient and flexible manner.
Why Virtual Machines?
Virtual machines behave like separate computers without being physically present and solve numerous requirements in a very cost-efficient way. They could be very powerful as per our use case with having highly efficient processors, RAMs and memory too. Although you need to pay for all this, definitely they are cheaper than the physical computer.
Setting up Virtual Machines
These machines can be set up manually using any virtualization technology like HyperV, Virtualbox, vmware etc.
There are several scenarios when spinning virtual machines manually could become a difficult task. For example In case if we need to set up 50 instances for our use case we will burst out if we are asked to do it manually.
So for that, In this blog series we will try to automate this process. But before moving to practical part, we should understand few things related to Virtual Machines and Vagrant.
In simple words, Vagrant is a virtual machine automation tool to manage it’s life cycle.
Virtual Machine Lifecycle
- While provisioning we allocate resources to the virtual machine and is ready to get started.
- While Staging virtual machine acquire the resources allocated while Provisioning and it is ready for first boot.
- Virtual Machine is started with full resources acquired by it.
- In case any internal occurred to the virtual machine, it undergoes maintenance. During this time it becomes unusable. When repairing is done, it again becomes usable.
- This stage is called by the user itself to suspend the virtual machine. It can be resumed from this state.
- The Stopping stage can be either called by user manually, or it can occur in case of any error encountered in VM. This is a temporary stage before Terminated.
Why Vagrant? Problems with manual setup of Virtual Machines.
- OS intallations are time consuming.
- A lot of repeated manual steps.
- Tough to replicate for multi VM infrastructure.
Benefit of Vagrant :
- No OS installation
- Create VM using Images(vagrant boxes)
- Manage VM with a Vagrantfile
- VM changes automatic through Vagrantfile
- Vagrant commands to manage VMs
- Provisioning VM/Executing commands and scripts.
Vagrant Cloud is a hub kind of thing from where we can get the various boxes for multiple OS. From our terminal we execute the Vagrant commands say vagrant init <boxname> using the box name from Vagrant cloud. When former command is successfully executed the Vagrantfile is created by itself. We can do provisioning of VM by updating Vagrantfile. After this when we do vagrant up, Vagrantfile will use the virtual-box to spin up the Virtual machines.
That’s all for this blog. Hope you found some information from this. In next blog we will do some hands on and spin up our fist virtual machine using Vagrant. In case of any queries you can contact me over my email id email@example.com.