How to Update a k3s Cluster
Updating a k3s cluster can be straightforward when you follow the correct steps. This tutorial will guide you through the process of updating the master node and joining worker nodes to the updated cluster.
Prerequisites
Ensure you have k3sup
installed on your system. If not, you can install it by following the instructions on the k3sup GitHub repository.
Step-by-Step Solution
1. Update the Master Node
First, you need to update the master node of your k3s cluster. Execute the following command to reinstall the k3s server on your master node:
1
2
3
4
5
6
7
8
# Export the IP of the master node
export SERVER_IP=192.168.1.32
# Define the user
export USER=root
# Run the install command to update the master node
k3sup install --ip $SERVER_IP --user $USER
This command will reinstall the k3s master, ensuring it is up to date.
2. Join Worker Nodes to the Updated Cluster
After updating the master node, you need to rejoin your worker nodes to the cluster. Follow the steps below to join each worker node:
1
2
3
4
5
6
7
8
9
10
11
12
# Export the IPs of the worker nodes
export AGENT_1_IP=192.168.1.33
export AGENT_2_IP=192.168.1.34
export AGENT_3_IP=192.168.1.35
# Define the user
export USER=root
# Join the worker nodes to the updated master node
k3sup join --ip $AGENT_1_IP --server-ip $SERVER_IP --user $USER
k3sup join --ip $AGENT_2_IP --server-ip $SERVER_IP --user $USER
k3sup join --ip $AGENT_3_IP --server-ip $SERVER_IP --user $USER
These commands will rejoin the worker nodes to the updated master node, ensuring that your cluster remains consistent.
Common Troubleshooting
-
Connection Errors
If you encounter connection errors when joining a worker node, make sure the worker node’s IP address and SSH credentials are correct.
-
Permission Issues
If you encounter permission errors, ensure you have root access or use
sudo
before executing the commands. -
Download Issues
1
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
Conclusion
By following these steps, you can successfully update your k3s cluster and rejoin your worker nodes to the updated master node. This process ensures that your cluster is running the latest version of k3s with all nodes properly connected.
If you experience any issues, consult the official k3s documentation or seek assistance from Kubernetes communities.
We hope this tutorial has been helpful. If you have any questions or suggestions, please leave a comment below!