Skip to content

jonatas-lima/k8s-cluster

Repository files navigation

K8S Cluster

This repository creates (currently) a 3-node Kubernetes on-premise cluster, 1 control plane and 2 data planes.

Motivation

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.

Before we start

Pre requisites

Ansible

python3 -m pip install --user ansible

Vagrant

Ubuntu based

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

Fedora

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

CentOS/RHEL

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

Managing your cluster

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.

Creating

Add your private SSH key path in SSH_KEY_PATH variable on Vagrantfile

make cluster

Interacting

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
# ...

Destroying

make destroy

Other use case

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published