Adding a Node
There are a few steps to adding a new worker node to the Cluster.
- Install Base OS (eg: Ubuntu 22.04)
- Install Ansible Host SSH Key onto the new node.
- Include k8s-node# in the Ansible
hosts
workers. - Include node in
nodes
section ofgateway-install / defaults / main.yaml
. - Run
gateway-install
andbuild-k8s-cluster
playbooks.
Step 1 - Install Base OS
Method A - Using the PXE Network Installer
The easiest method for adding a new k8s cluster node is to use the pre-configured PXE Installer.
Method B - Manually Install Ubuntu Host OS
You can manually provision the node with Ubuntu 22.04 Server and then attach it to the cluster subnet and run an Ansible Playbook to add it to the k8s cluster. In this scenario, you would start from Step 6 in PXE Installer: Copying over the Ansible Host SSH Keys.
Ensure that you remove /etc/hostname file from the node before connecting it to the cluster subnet. (See dnsmasq: hostname from dhcp for more details)
Step 2 - Install Ansible Host SSH Key
From the Ansible host, install the SSH key to allow Ansible playbook to run. (This is using SSH JumpHost to provision Ansible Playbook on a Worker Node, via the Gateway Device.)
ansible-host#> ssh-copy-id -i ~/.ssh/id_rsa.pub -o \
ProxyCommand="ssh -W %h:%p ubuntu@192.168.1.xxx (Gateway Device)" ubuntu@k8s-node7
If this does not work (eg: permission denied), you can log in from the Gateway Device to the new node and add the Ansible Host’s SSH key in ~/.ssh/authorized_keys
file manually.
Step 3 - Update Ansible hosts
Ensure the following section of the hosts
file spans k8s-node[1-7] and nodes
map in gateway-install / defaults / main.yaml
.
[workers]
k8s-node[2:7] ansible_user=ubuntu ansible_ssh_private_key_file=~/.ssh/id_rsa
Step 4 - Use gateway-install Ansible Playbook
Add the new k8s worker nodes defined in gateway-install / defaults / main.yaml
Example shows k8s-node7 being added to the known-nodes list.
# Known nodes on cluster network
nodes:
...
- name: "k8s-node7"
mac: "6c:4b:90:57:04:5e"
static_ip: "192.168.57.37"
model: "lenovo thinkcentre M910q i7"
Step 5 - Run playbooks
The new node is added to various ansible files, there are two playbooks to run.
-
Run the
gateway-install
playbook and this will setup the ecosystem to allow it to connect to the Cluster subnet. -
Run the
build-k8s-cluster
(with{"reset_cluster":False}
) Role to include the node as a k8s worker node and leave the rest untouched.
Once these playbooks have run, you should be able to see the new node join the k8s cluster.
gateway-device #> ssh ubuntu@k8s-control-plane-node
k8s-control-plane-node #> sudo su - kube
k8s-control-plane-node #> kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-control-plane-node Ready control-plane 6h32m v1.25.5
k8s-node2 Ready <none> 6h32m v1.25.5
k8s-node3 Ready <none> 6h32m v1.25.5
k8s-node4 Ready <none> 6h32m v1.25.5
k8s-node5 Ready <none> 6h32m v1.25.5
k8s-node6 Ready <none> 6h32m v1.25.5
k8s-node7 Ready <none> 0h32m v1.25.5