Skip to content

Commit e99ab11

Browse files
feat(post): automated k3s etcd and ansible
1 parent bd1eb1b commit e99ab11

File tree

2 files changed

+139
-3
lines changed

2 files changed

+139
-3
lines changed

_posts/2022-03-19-cloud-init-cloud-image.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Using Cloud Images and Cloud Init with Proxmox is easy, fast, efficient, and fun
1212

1313
📺 [Watch Video](https://www.youtube.com/watch?v=shiIi38cJe4)
1414

15-
## Intructions
15+
## Instructions
1616

1717
Choose your [Ubuntu Cloud Image](https://cloud-images.ubuntu.com/)
1818

@@ -28,7 +28,7 @@ Create a new virtual machine
2828
qm create 8000 --memory 2048 --core 2 --name ubuntu-cloud --net0 virtio,bridge=vmbr0
2929
```
3030

31-
Import the downloaded Ubuntut disk to local-lvm storage
31+
Import the downloaded Ubuntu disk to local-lvm storage
3232

3333
```bash
3434
qm importdisk 8000 focal-server-cloudimg-amd64.img local-lvm
@@ -46,7 +46,7 @@ Add cloud init drive
4646
qm set 8000 --ide2 local-lvm:cloudinit
4747
```
4848

49-
Make the clud init drive bootable and restrict BIOS to boot from disk only
49+
Make the cloud init drive bootable and restrict BIOS to boot from disk only
5050

5151
```bash
5252
qm set 8000 --boot c --bootdisk scsi0

_posts/2022-03-19-k3s-etcd-ansible.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
layout: post
3+
title: "Fully Automated K3S etcd High Availability Install"
4+
date: 2022-03-26 10:00:00 -0500
5+
categories: kubernetes k3s
6+
tags: k3s rancher etcd ansible cloud-image metallb kube-vip
7+
---
8+
9+
[![Fully Automated K3S etcd High Availability Install](https://img.youtube.com/vi/CbkEWcUZ7zM/0.jpg)](https://www.youtube.com/watch?v=CbkEWcUZ7zM "Fully Automated K3S etcd High Availability Install")
10+
11+
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 automated the entire process giving you an easy, repeatable way to create a k3s cluster that you can run in a few minutes.
12+
13+
A HUGE THANKS to our sponsor, Micro Center!
14+
15+
New Customers Exclusive – Get a Free 240gb SSD at Micro Center: https://micro.center/1043bc
16+
17+
📺 [Watch Video](https://www.youtube.com/watch?v=CbkEWcUZ7zM)
18+
19+
## Prep
20+
21+
First, you'll need Ansible installed. Here's an easy way to [install Ansible](https://docs.technotim.live/posts/ansible-automation/) and a video if you need.
22+
23+
Next, you'll need to fork and clone [the repo](https://github.com/techno-tim/k3s-ansible). While you're at it, give it a ⭐ too :).
24+
25+
## Installing k3s
26+
27+
Next, you'll want to copy the `sample` directory within the `inventory` directory.
28+
29+
```bash
30+
cp -R inventory/sample inventory/my-cluster
31+
```
32+
33+
Next, edit the `inventory/hosts.ini` to match your systems. DNS works here too.
34+
35+
```ini
36+
[master]
37+
192.168.30.38
38+
192.168.30.39
39+
192.168.30.40
40+
41+
[node]
42+
192.168.30.41
43+
192.168.30.42
44+
45+
[k3s_cluster:children]
46+
master
47+
node
48+
```
49+
50+
Edit `inventory/group_vars/all.yml` to your liking. See comments inline.
51+
52+
Start provisioning of the cluster using the following command:
53+
54+
```bash
55+
ansible-playbook site.yml -i inventory/hosts.ini
56+
```
57+
58+
After deployment control plane will be accessible via virtual ip address which is defined in `inventory/group_vars/all.yml` as `apiserver_endpoint`
59+
60+
## Removing
61+
62+
To remove k3s from the nodes
63+
64+
```bash
65+
ansible-playbook reset.yml -i inventory/hosts.ini
66+
```
67+
68+
## kube config
69+
To get access to your Kubernetes cluster and copy your kube config locally run:
70+
71+
```
72+
scp debian@master_ip:~/.kube/config ~/.kube/config
73+
```
74+
75+
## Testing your cluster
76+
77+
Be sure you can ping your VIP defined in `inventory/group_vars/all.yml` as `apiserver_endpoint`
78+
79+
```bash
80+
ping 192.168.30.222
81+
```
82+
83+
Getting nodes
84+
85+
```bash
86+
kubectl get nodes
87+
```
88+
89+
Deploying a sample `nginx` workload
90+
91+
```bash
92+
kubectl apply -f example/deployment.yml
93+
```
94+
95+
Check to be sure it was deployed
96+
97+
```bash
98+
kubectl describe deployment nginx
99+
```
100+
101+
102+
Deploying a sample `nginx` service with a `LoadBalancer`
103+
104+
```bash
105+
kubectl apply -f example/service.yml
106+
```
107+
108+
109+
Check service and be sure it has an IP from metal lb as defined in `inventory/group_vars/all.yml`
110+
111+
```bash
112+
kubectl describe service nginx
113+
```
114+
115+
Visit that url or curl
116+
117+
```bash
118+
curl http://192.168.30.80
119+
```
120+
121+
You should see the `nginx` welcome page.
122+
123+
124+
You can clean this up by running
125+
126+
```bash
127+
kubectl delete -f example/deployment.yml
128+
kubectl delete -f example/service.yml
129+
```
130+
131+
132+
## Links
133+
134+
⚙️ See all the hardware I recommend at <https://l.technotim.live/gear>
135+
136+
🚀 Don't forget to check out the [🚀Launchpad repo](https://l.technotim.live/quick-start) with all of the quick start source files

0 commit comments

Comments
 (0)