Lab 2: Automate the K3s clusters deployment with Ansible
Starting a local Kubernetes cluster in our home lab environment may become complicated if we use kubeadm or any other distributions.
I seek to establish a Kubernetes cluster that operates seamlessly within an Ansible-driven ecosystem, allowing for scripted control over the cluster's nodes. This setup enables the automation of both the construction and decommissioning of nodes within the cluster, providing the flexibility to manage its lifecycle as required.
Therefore, I chose k3s-ansible
to build my on-premise Kubernetes cluster.
Continue later...
Post-Deployment
After the deployment, you may need to get a copy of kube config file from each of the master nodes.
Run the following commands
Please replace k3s-master-node01 with the hostname or IP addresses of your master node. You may need to repeat the command if you have more than one master node.
Please also replace the following parameters in each of the kube config file, so that when you run $ kubectl config get-context
you will see the name of the nodes correctly.
Example config file:
Then, test the connectivity with the following command
My results:
Last updated