Kubernetes Setup Using Ansible and Vagrant
2021-08-28 21:20:42

## Introduction

This project came up because of the need to have a development environment for trying out Kubernetes operators at work where we didn’t have any Kubernetes cluster that we might use for testing purposes, so starting with something that you can run locally and make highly customizable sounded like a good approach to start with.

My first try was to start using Kubernetes that comes with Docker in Mac, its nice and usually enough for trying stuff but in this specific case where I needed to install Trident it didn’t work, so that was an opportunity for trying something else and moving to mimic the most similar setup possible that we can find in our production clusters. That pointed me for using Vagrant that allow you to customize your underlaying OS, more personalizable options and could give us more confidence when testing everything.

“Googling” over all the Internet (as usual when you have are dealing with something new and you want to start with good context) I found out https://kubernetes.io/blog/2019/03/15/kubernetes-setup-using-ansible-and-vagrant/, well two years in software development means a lot of stuff have changed and might be deprecated but something that is backed up for Kubernetes official community can’t be wrong so I decided to give this a try.

As expected, there was a lot of stuff that didn’t work at the time of writing but I took this as a challenge and wanted to invest some time for updating what was needed for bringing it back to life.

Prerequisites:

• virtualbox (6.1.26 r145957 (Qt5.6.3))
• vagrant (2.2.18)
• ansible ([core 2.11.4])
• python (3.9.6)
• kubectl

• git clone https://github.com/borjatur/kubernetes-using-ansible-vagrant.git
• cd kubernetes-using-ansible-vagrant
• vagrant up
• export KUBECONFIG=kubernetes-setup/output/config
• kubectl cluster-info
• enjoy!

## Beyong the basics

• vagrant suspend (suspend all vm’s saving its own state so can be resumed later on with just vagrant up)
• vagrant halt (destroy all vm’s)
• IMAGE_NAME makes OS configurable (Vagrantfile)
• WORKER_NODES makes the number of worker nodes configurable (Vagrantfile)
2021-08-28 21:20:42