This repository creates (currently) a 3-node Kubernetes on-premise cluster, 1 control plane and 2 data planes.
Instead of using learning tools such as Kind and Minikube, we can use a on-premise K8S cluster using virtual machines on your own host machine.
Why? Doing this way is more fun and more similar to how it is done in on-premises environments.
Of course this way it's more complicated, but it will be worth it.
Also, it is used Kubespray to configure the production-ready K8S cluster.
- ansible
- vagrant
- virtualbox
- make
- at least 8GB RAM
python3 -m pip install --user ansible
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant -y
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
sudo dnf -y install vagrant
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
sudo yum -y install vagrant
First of all, clone this repository:
git clone [email protected]:jonatas-lima/k8s-cluster.git --recurse-submodules
The created cluster will use *GB of RAM, so it's very likely that your machine will slow down a little.
Add your private SSH key path in SSH_KEY_PATH
variable on Vagrantfile
make cluster
Just log into the control plane and start playing with Kubernetes.
vagrant ssh control-plane-1
kubectl get node
k get pods -A # it will be created an alias 'k' to kubectl
# ...
make destroy
You can just run the playbook that creates a K8S cluster, just populate correctly on hosts.ini
cd ansible && ansible-playbook -i hosts.ini cluster.yml