Skip to content

Deploy Minikube Using Vagrant and Ansible on VirtualBox – Infrastructure as Code

Avatar photo

Okay, you started learning kubernetes; maybe you are following some courses or documentations. Some of the courses are arranged with FREE labs where you can do hands-on labs and test your knowledge. And you can also use the FREE labs around, like kubernetes labs in Thatโ€™s more than enough, but what if you want to test more on kubernetes clusters other than lab arrangements ?

IMPORTANCE NOTE: Since the minikube supports several drivers (Including podman, virtualbox, docker etc), I have stopped using minikube inside a Vagrant + VirtualBox VM. Hence I am not maintaining this Vagrant use case folder as well.

Find FREE OpenShift Hands on Labs here.

Sometimes, you have situations like you need to test the latest kubernetes version or kubectl version and those FREE labs are not yet ready with those versions. So what, you can easily set up your own kubernetes cluster on your laptop or workstation. But, setting up a full kubernetes cluster is not required in most cases as we have a minimal version of kubernetes called minikube.

So, what is minikube ?

Minikube is a tool to run a kubernetes cluster locally, that means on your laptop or inside a virtual machine. Minikube will run a single node kubernetes cluster on your machine with almost all features you want to try on an actual kubernetes cluster; like DNS, NodePorts,ConfigMaps and Secrets, then kubernetes Dashboard, Container Runtime like Docker, CRI-O, and containerd, and also enabling CNI or Container Network Interface, ingress, yes almost all items you need your hands get dirty.

Is it easy to install minikube ?

Not really and depends on your experience with virtual machines or docker configurations. If you check the minikube installation document, you will find very few steps but it’s not actually.

You can spin up a minikube cluster inside a virtual machine like virtualbox, hyperkit, hyperv, vmware or kvm. Or you can install minikube directly on a physical machine like your laptop or workstation, using --driver=none. But that needs docker to be installed on that machine as kubernetes components will run as docker containers.

A Simple Solution

Letโ€™s say, we need to spin up a minikube cluster whenever we need, quickly and without any hurdles, then we can mix up some of the solutions and implement this minikube as Infrastructure as Code or IaC. We will use vagrant to provision the virtual machine, then we will use Ansible as a provisioner and install all those required packages. For this demo, we will use VirtualBox as a hypervisor, but you may try with any other hypervisor or public cloud solutions.

Why Vagrant

Vagrant is one of the easiest tools to provision infrastructure or virtual machines in a single workflow and this is available for Windows, MacOS, Linux, Debian, Centos etc.

Why Ansible

Ansible is super simple and powerful in terms of its usage. Once you start using Ansible, you will realize that this is simpler than shell script. Please note, Ansible is not natively available for Windows yet and you might need some extra setup like cygwin to achieve this in a windows environment. Later I will share the shell script version of the same but for this demo we will use Vagrant + Ansible.

Why Infrastructure as Code

We will not go in details as our focus is on minikube cluster setup. But just to add, you have several reasons to implement IaC.

  • Your infrastructure will be defined and changes will be transparent. Every time you create the infrastructure, it will be consistent. For example, you can share your infrastructure code to your colleague or different team and they can implement their own infrastructure in a consistent way; like I am sharing my Vagrantfile with you for this minikube demo.
  • Less risk because everything about your infrastructure is already visible on your code and any engineer can easily handle it; means less dependence on an engineer.
  • It will increase efficiency as you can focus on actual things like coding or designing rather than setting up your infrastructure every time.

In this video, I will explain how to create a minikube cluster very quickly with the help of vagrant and Ansible, that means you will not be required to run a lot of configurations to start the cluster.

Questions ? Please ask in comment box and I will try my best to


The views expressed and the content shared in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.

Avatar photo
Gineesh Madapparambath is the founder of techbeatly and he is the co-author of The Kubernetes Bible, Second Edition. and the author of ๐—”๐—ป๐˜€๐—ถ๐—ฏ๐—น๐—ฒ ๐—ณ๐—ผ๐—ฟ ๐—ฅ๐—ฒ๐—ฎ๐—น-๐—Ÿ๐—ถ๐—ณ๐—ฒ ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ผ๐—ป. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan -


5 Responses

  1. […] Also read : Deploy Minikube Using Vagrant and Ansible on VirtualBox โ€“ Infrastructure as Code […]

  2. […] Read : How to Install a minikube on GCP or Install minikube using Vagrant and VirtualBox […]

  3. […] Read : Creating a Kubernetes Cluster using Vagrant and Ansible […]

  4. jackson berg says:

    Thanks for letting me know how to deploy minikube. I was just searching around google and i found this article with the instructions. Thanks a lot.

  5. […] it from scratch) then try automated IaC (Infrastructure as Code) methods using minikube, Kind, Vagrant, Ansible or […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.