Install and run Oracle VM VirtualBox 7 virtualization environment with Vagrant

Tram Ho

If you are a programmer, software developer, software tester, designer, one fine day a project team comes in and you test the software on your machine, you have to build the same system. But for your computer, for convenience of development and testing, and to limit the questions “Why can’t my machine run, but your machine can’t”, then we can use Vagrant to synchronize the development environment. develop

What is Vagrant?

Vagrant is a tool for working with virtual environments and in most cases this means working with virtual machines. Vagrant provides a simple and easy-to-use command client to manage these environments and an interpreter for text-based definitions of what each environment should look like, called vagrantfiles. Vagrant is open source, which means anyone can download, modify it, and share it freely.

Although many virtual machine programmers provide their own command line interfaces, and technically provisioning virtual machines through these programs can be done directly or through shell scripts, the Another advantage provided by adding an extra layer is simplicity, cross-system interoperability and A more consistent approach that can theoretically be used with any virtual environment running on any any other system.

By providing a common text-based format for working with virtual machines, your environment can be defined in code, making it easy to backup, modify, share, and manage with control. revision control. It also means that instead of sharing an entire virtual machine image, which can be many gigabytes, every time a change is made to the configuration, a simple text file can only share a few kilobytes.

IPHostnamevCPURAMDISK core2G50G core2G50G core2G50G core2G50G core2G50G core2G50G core2G50G

Install Vagrant

Step 1: We install Oracle VM VirtualBox 7

Please refer to article 2.1

Step 2: Install Vagrant

We go to the vagrant homepage to download the installation file depending on the operating system, then we will choose that installation file.

Screenshot 2023-03-11 at 16.00.36.png

Step 3: After successful installation, create the file Vagrantfile

Screenshot 2023-03-11 at 16.15.57.png

Step 4: Configure the network

Here I create 2 networks public_network and private_network

  • public_network: Fail to connect to the Internet
  • private_network: Can’t connect to the Internet, can only connect to VirtualBox’s internal LAN

Step 5: Vagrant up

After creating, we use the Vagrant up command to run the virtualized environment

Depending on your network and configuration, this step is about 30 -> 60p

Then you open Oracle VM VirtualBox and see if the virtual machines have been created and started

Step 5: Vagrant ssh and join nodes to master

So successfully started, continue to ssh into the machine microk8s-master-01 with the command

Continue to create tokens to connect to the microk8s cluster

Screenshot 2023-03-11 at 16.54.15.png

then we ssh into the microk8s-master-02 and microk8s-master-03 to join the master

Screenshot 2023-03-11 at 19.47.59.png

We use the command microk8s join to connect 2 machines to cum master

Screenshot 2023-03-11 at 19.55.20.png

Screenshot 2023-03-11 at 19.55.50.png

We use the command microk8s kubectl get no to check if 2 nodes master 01 vs master 02 have joined

Screenshot 2023-03-11 at 19.56.57.png

So the master cluster has joined successfully, now we do it with the worker cluster, then we ssh into the machines microk8s-worker-01 , microk8s-worker-02 , microk8s-worker-03 , microk8s-worker-04 to join to worker machines

Screenshot 2023-03-11 at 20.00.07.png

Screenshots 2023-03-11 at 20.00.33.png

Screenshot 2023-03-11 at 20.00.52.png

Screenshot 2023-03-11 at 20.01.22.png

After successfully logging into the workers, go to the microk8s-master-01 and type the command **microk8s add-node **

We use token with ip and add –worker at the end, and apply to all worker machines

Screenshot 2023-03-11 at 20.15.24.png

We use the command microk8s kubectl get no on master 01 to check if the woker nodes are connected.

So we have successfully created a virtual machine and connected 3 masters with 4 workers

Thank you for following my article, if you find it interesting, please give me an upvote to have more motivation to share more useful articles.

Share the news now

Source : Viblo