This part of the documentation is about creating, updating and maintaining the kubernetes cluster with ansible.
We are not going to go into what is going to be installed in the cluster, except networking.
We have two load balancers that proxy the traffic to our cluster.
They are gong to proxy control panel traffic to the master nodes, and the rest of the traffic to the worker nodes through our private network.
We are going to run a minimum of three Master Nodes. Later we can add more if we need, or scale them up.
Important things to keep in mind:
- It is very important to keep them in an odd number, so we can have a majority vote when it comes to the cluster state.
- Treat them very carefully. If we mess them up, the cluster is in real troubble.
- Make sure to take down a node for maintenance in a proper way. Read more about that here.
We are going to use Hetzner Root Servera aka. dedicated servers for our worker nodes. Here we are going to get A LOT more power for our money.
This part is a bit different from the other parts. The first node is going to be the one that sets up the cluster, and the other nodes are going to join it.
- Upadte the configurations in
./group_vars
,./host_vars
and./inventory.yaml
Make sure to change the filename in./host_vars
to mach the name of the host in./inventory.yaml
. - Run the playbooks in order:
./playbooks/01-kubernetes-common.yaml
and./playbooks/02-kubernetes-master-init.yaml
To run kubectl on your local machine, run
scp root@master1.<domain>:/etc/kubernetes/admin.conf ~/.kube/config
Make sure to update the with your domain name.
Check the kubernetes status:
kubectl get pods -n kube-system
kubectl get pods -n kube-flannel
kubectl get nodes
Adding nodes to the cluster is very easy. You just need to run the following command:
./playbooks/03-kubernetes-join-nodes.yaml --limit "master1.<domain>,worker1.<domain>"
Be sure to change the limit to the main master node and the new node you want to add.
After the process is complete, you should see a new node in the kubernetes cluster.
kubectl get nodes
kubectl drain <node-name> --ignore-daemonsets
kubectl delete node <node-name>
If you want to add the node to this or some other cluster, then you need to run
kubeadm reset
first.
If you have set limit to hosts, then make sure to not exclude the master node.