VOOZH about

URL: https://thenewstack.io/tutorial-install-a-highly-available-k3s-cluster-at-the-edge/

⇱ Tutorial: Install a Highly Available K3s Cluster at the Edge - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2020-08-21 11:30:10
Tutorial: Install a Highly Available K3s Cluster at the Edge
feature,tutorial,

Tutorial: Install a Highly Available K3s Cluster at the Edge

Aug 21st, 2020 11:30am by Janakiram MSV
👁 Featued image for: Tutorial: Install a Highly Available K3s Cluster at the Edge
Feature image via Pixabay.

This is the last part of the tutorial in the K3s series. In the previous tutorial, we have seen how to set up a multinode etcd cluster. We will leverage the same infrastructure for setting up and configuring a highly available Kubernetes cluster based on K3s.

Kubernetes Clusters in High Availability Mode

The control plane of the Kubernetes cluster is mostly stateless. The only stateful component of the control plane is the etcd database, which acts as the single source of truth for the entire cluster. The API server acts as the gateway to the etcd database through which both internal and external consumers access and manipulate the state.

It is important that the etcd database is configured in HA mode to ensure that there is no single point of failure. There are two options for configuring the topology of a highly available (HA) Kubernetes clusters that depend on how etcd is setup.

The first topology is based on the stacked cluster design where each node runs an etcd instance along with the control plane. Each control plane node runs an instance of the kube-apiserver, kube-scheduler, and kube-controller-manager. The kube-apiserver is exposed to worker nodes using a load balancer.

Each control plane node creates a local etcd member and this etcd member communicates only with the kube-apiserver of this node. The same applies to the local kube-controller-manager and kube-scheduler instances.

This topology demands a minimum of three stacked control plane modes for a HA Kubernetes cluster. Kubeadm, the popular cluster installation tool uses this topology to configure a Kubernetes cluster.

👁 Image

The second topology uses an external etcd cluster installed and managed on a completely different set of hosts.

In this topology, each control plane node runs an instance of the kube-apiserver, kube-scheduler, and kube-controller-manager where each etcd host communicates with the kube-apiserver of each control plane node.

👁 Image

This topology requires twice the number of hosts as the stacked HA topology. A minimum of three hosts for control plane nodes and three hosts for etcd nodes are required for an HA cluster with this topology.

For more information on bootstrapping a cluster, refer to the official Kubernetes documentation.

K3s in a Highly Available Mode

Since K3s is mostly deployed at the edge with limited hardware resources, it may not be possible to run the etcd database on dedicated hosts. The deployment architecture closely mimics the stacked topology except that the etcd database is configured beforehand.

👁 Image

For this walkthrough, I am using bare-metal infrastructure running on Intel NUC hardware with the below mapping:

👁 Image

Refer to the previous part of this tutorial series to install and configure etcd on the first three nodes with IP addresses 10.0.0.60, 10.0.0.61, and 10.0.0.62.

Installing K3s Servers

Let’s start by installing the servers in all the nodes where etcd is installed. SSH into the first node, and set the below environment variables. This assumes that you followed the steps explained in the previous tutorial to configure the etcd cluster.

export K3S_DATASTORE_ENDPOINT='https://10.0.0.60:2379,https://10.0.0.61:2379,https://10.0.0.62:2379'
export K3S_DATASTORE_CAFILE='/etc/etcd/etcd-ca.crt'
export K3S_DATASTORE_CERTFILE='/etc/etcd/server.crt'
export K3S_DATASTORE_KEYFILE='/etc/etcd/server.key'

These environment variables instruct K3s installer to utilize the existing etcd database for state management.

Next, we will populate the K3S_TOKEN with a token that’s used by the agents to join the cluster.

export K3S_TOKEN="secret_edgecluster_token"

We are ready to install the server in the first node. Run the below command to start the process.

curl -sfL https://get.k3s.io | sh -

Repeat these steps in node-2 and node-3 to launch additional servers.

At this point, you have a three-node K3s cluster that runs the control plane and etcd components in a highly available mode.

sudo kubectl get nodes

👁 Image

You can check the status of the service with the below command:

sudo systemctl status k3s.service

👁 Image

Installing K3s Agents

With the control plane up and running, we can easily add worker nodes or agents to the cluster. We just need to make sure that we use the same token that was associated with the servers.

SSH into one of the worker nodes and run the commands.

export K3S_TOKEN="secret_edgecluster_token"
export K3S_URL=https://10.0.0.60:6443

The environment variable, K3S_URL is a hint to the installer to configure the node as an agent connected to an existing server.

Finally, run the same script as we did in the previous step.

curl -sfL https://get.k3s.io | sh -

👁 Image

Check if the new node is added to the cluster.

👁 Image

Congratulations! You have successfully installed a highly available K3s cluster backed an external etcd database.

Verifying the etcd Database

Let’s make sure that the K3s cluster is indeed using the etcd database for state management.

We will launch a simple Nginx pod in the K3s cluster.

sudo kubectl run nginx --image nginx --port 80
sudo kubectl get pods

👁 Image

The pod spec and the status should be stored in the etcd database. Let’s try to retrieve that through the etcdctl CLI. Install the jq utility to parse the JSON output.

Since the output is encoded in base64, we will decode it via the base64 tool.

etcdctl --endpoints https://10.0.0.61:2379 \
--cert /etc/etcd/server.crt \
--cacert /etc/etcd/etcd-ca.crt \
--key /etc/etcd/server.key get /registry/pods/default/nginx \
--prefix=true -w json | jq -r .kvs[].value | base64 -d

👁 Image

The output shows that the pod has an associated key and value in the etcd database. The special characters are not shown correctly but it does show us enough data about the pod.

This tutorial series demonstrates how to set up and configure Rancher Labs’ K3s at the edge in a highly available mode.

Janakiram MSV’s Webinar series, “Machine Intelligence and Modern Infrastructure (MI2)” offers informative and insightful sessions covering cutting-edge technologies. Sign up for the upcoming MI2 webinar at http://mi2.live.

TRENDING STORIES
Janakiram MSV (Jani) is a practicing architect, research analyst, and advisor to Silicon Valley startups. He focuses on the convergence of modern infrastructure powered by cloud-native technology and machine intelligence driven by generative AI. Before becoming an entrepreneur, he spent...
Read more from Janakiram MSV
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.