

Fully Automated K3S etcd High Availability Install
source link: https://techno-tim.github.io/posts/k3s-etcd-ansible/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Fully Automated K3S etcd High Availability Install
Setting up k3s is hard. That’s why we made it easy. Today we’ll set up a High Availability K3s cluster using etcd, MetalLB, kube-vip, and Ansible. We’ll automate the entire process giving you an easy, repeatable way to create a k3s cluster that you can run in a few minutes.
A HUGE THANKS to our sponsor, Micro Center!
New Customers Exclusive – Get a Free 240gb SSD at Micro Center: https://micro.center/1043bc
First, you’ll need Ansible installed. Here’s an easy way to install Ansible and a video if you need.
Next, you’ll need to fork and clone the repo. While you’re at it, give it a ⭐ too :).
Installing k3s
Next, you’ll want to copy the sample
directory within the inventory
directory.
cp -R inventory/sample inventory/my-cluster
Next, edit the inventory/my-cluster/hosts.ini
to match your systems. DNS works here too.
[master]
192.168.30.38
192.168.30.39
192.168.30.40
[node]
192.168.30.41
192.168.30.42
[k3s_cluster:children]
master
node
Edit inventory/my-cluster/group_vars/all.yml
to your liking. See comments inline.
The variables I used in the video are below but…
Note: These are for an advanced use case. There isn’t a one size fits all setting for everyone and their needs, I would try using k3s without these before changing. This could have undesired effects like nodes going offline, pods jumping or being removed, etc… This might come at the cost of stability
extra_server_args: "--no-deploy servicelb --no-deploy traefik --write-kubeconfig-mode 644 --kube-apiserver-arg default-not-ready-toleration-seconds=30 --kube-apiserver-arg default-unreachable-toleration-seconds=30 --kube-controller-arg node-monitor-period=20s --kube-controller-arg node-monitor-grace-period=20s --kubelet-arg node-status-update-frequency=5s"
extra_agent_args: "--kubelet-arg node-status-update-frequency=5s"
It’s best to start using these args, and optionally include traefik
if you want it installed with k3s
extra_server_args: "--no-deploy servicelb --no-deploy traefik"
extra_agent_args: ""
Start provisioning of the cluster using the following command:
ansible-playbook site.yml -i inventory/my-cluster/hosts.ini
note: add –ask-pass –ask-become-pass if you are using password SSH login
After deployment control plane will be accessible via virtual ip address which is defined in inventory/my-cluster/group_vars/all.yml
as apiserver_endpoint
Removing
To remove k3s from the nodes. These nodes should be rebooted afterwards due to VIP still being present
ansible-playbook reset.yml -i inventory/my-cluster/hosts.ini
kube config
To get access to your Kubernetes cluster and copy your kube config locally run:
scp debian@master_ip:~/.kube/config ~/.kube/config
Testing your cluster
Be sure you can ping your VIP defined in inventory/my-cluster/group_vars/all.yml
as apiserver_endpoint
ping 192.168.30.222
Getting nodes
kubectl get nodes
Deploying a sample nginx
workload
kubectl apply -f example/deployment.yml
Check to be sure it was deployed
kubectl describe deployment nginx
Deploying a sample nginx
service with a LoadBalancer
kubectl apply -f example/service.yml
Check service and be sure it has an IP from metal lb as defined in inventory/my-cluster/group_vars/all.yml
kubectl describe service nginx
Visit that url or curl
curl http://192.168.30.80
You should see the nginx
welcome page.
You can clean this up by running
kubectl delete -f example/deployment.yml
kubectl delete -f example/service.yml
Troubleshooting
Be sure to see this post on how to troubleshoot common problems
Links
⚙️ See all the hardware I recommend at https://l.technotim.live/gear
🚀 Don’t forget to check out the 🚀Launchpad repo with all of the quick start source files
Recommend
-
151
README.md pg_auto_failover
-
15
[Submitted on 28 Dec 2020] Towards Fully Automated Manga Translation Download PDF We tackle the problem of...
-
5
CoWin-Vaccine-Notifier Automated Python Script to retrieve vaccine slots availability and get notified when a slot is available. pre requisite
-
10
How to install Devtron over k3s August 27th 2021 new story6
-
20
How to Install etcd on Ubuntu 18.04Etcd is a simple, reliable, fast and secure open source key-value store written in Go. It uses the Raft consensus algorithm to manage a highly-available replicated log....
-
7
Install an on-premises k3s Cluster 6 days ago2022-02-14T00:00:00+01:00 by Wolfgang Ofner Using cloud technologies is amazing and makes a developer’s life so much easier. Lately, I have to work with an on...
-
11
How to Install etcd on Ubuntu 22.04|20.04|18.04|16.04Etcd is a simple, reliable, fast and secure open source key-value store written in Go. It uses the Raft consensus algorithm to manage a highly-availabl...
-
5
Install Azure Arc on an On-premises k3s Cluster Posted May 30, 2022 Updated May 27, 2022 by By Wolfgang Ofner 8 min read
-
8
Giridharan Ravisankar December 5, 2022 6 minute...
-
4
k3s的etcd备份 January 10, 2023 如果你使用的是嵌入式的etcd,k3s 是支持直接备份自己的etcd snapshot到s3的,具体...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK