Posts How to Install a k3s Cluster with k3sup
Post
Cancel

How to Install a k3s Cluster with k3sup

How to Install a k3s Cluster with k3sup

In this tutorial, we’ll walk you through the process of installing a k3s cluster using k3sup (pronounced “ketchup”). k3sup is a simple and fast way to bootstrap a k3s cluster, whether it’s on local hardware, in the cloud, or on a remote edge device.

Prerequisites

Ensure you have a Linux environment with SSH access to the servers where you want to set up the k3s cluster. If you’re using Windows, refer to the Releases page on GitHub for additional instructions.

Step 1: Install k3sup

First, let’s install k3sup. You can do this by running the following command:

1
2
curl -sLSf https://get.k3sup.dev | sh
sudo install k3sup /usr/local/bin/

This command will download and install k3sup to your local machine.

Step 2: Create the Master Node

In Kubernetes, the master node is responsible for managing the cluster, including the scheduling of workloads and management of resources. We will now set up the master node for our k3s cluster.

Export the Master Node IP

Export the IP address of your server (master node):

1
export SERVER_IP=159.65.25.233

Install k3s on the Master Node

Run the following command to install k3s on the master node:

1
k3sup install --ip $SERVER_IP --user root --local-path=./kubeconfig

This command will install k3s on the specified server and save the kubeconfig file to the current directory.

Test the Master Node

Once the installation is complete, you can test your k3s cluster by exporting the kubeconfig file and checking the node status:

1
2
export KUBECONFIG=`pwd`/kubeconfig
kubectl get node -o wide

You should see the master node listed as “Ready” with details about the node.

Step 3: Extend the Cluster with Worker Nodes

To extend your cluster and increase its capacity, you can add additional worker nodes. Let’s add two worker nodes to our cluster.

Export the Worker Node IPs

Export the IP addresses of the worker nodes:

1
2
3
4
5
6
7
# Worker node 1
export IP=159.65.22.30
k3sup join --ip $IP --server-ip $SERVER_IP --user root

# Worker node 2
export IP=159.65.29.53
k3sup join --ip $IP --server-ip $SERVER_IP --user root

These commands will add the worker nodes to the cluster, allowing them to run workloads.

Step 4: Verify the Cluster

After adding the worker nodes, you can verify the status of your cluster:

1
kubectl get node

You should see all nodes listed as “Ready”.

Conclusion

By following these steps, you’ve successfully installed a k3s cluster with a master node and added worker nodes using k3sup. This setup allows you to easily manage and scale your Kubernetes environment.

If you ever need to re-download the kubeconfig file, you can do so by running the k3sup install --skip-install command. This will copy the kubeconfig file to your local machine without reinstalling k3s on the server.


We hope this tutorial has been helpful. If you have any questions or suggestions, please leave a comment below!

This post is licensed under CC BY 4.0 by the author.