Skip to content

Commit 062cdd5

Browse files
committed
refactor!: switch dev environment from Vagrant to k3d
1 parent 9c243c6 commit 062cdd5

14 files changed

+94
-125
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.vagrant/
21
.venv/
32
book/
43

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ They can't capture all of the project's features, but they are sufficient to get
223223

224224
## Get Started
225225

226-
- [Try it out on a VM](https://homelab.khuedoan.com/try-on-a-vm.html) without any hardware
226+
- [Try it out locally](https://homelab.khuedoan.com/try-locally.html) without any hardware
227227
- [Deploy on real hardware](https://homelab.khuedoan.com/deployment) for real workload
228228

229229
## Roadmap

docs/book.toml

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ title = "Khue's Homelab"
88
[output.html]
99
git-repository-url = "https://github.com/khuedoan/homelab"
1010
edit-url-template = "https://github.com/khuedoan/homelab/edit/master/docs/{path}"
11+
12+
# TODO deprecate this after 6 months
13+
[output.html.redirect]
14+
"/try-on-a-vm.html" = "/try-locally.html"

docs/src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Summary
22

33
- [Introduction](introduction.md)
4-
- [Try on a VM](try-on-a-vm.md)
4+
- [Try locally](try-locally.md)
55
- [Deployment](./deployment/README.md)
66
- [Provisioning flow](./deployment/provisioning-flow.md)
77
- [Prerequisites](./deployment/prerequisites.md)

docs/src/deployment/configuration.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ it's the source of truth for my homelab, so you'll need to fork it to make it yo
77

88
## Choose the environment
99

10-
| Environment | Branch | Recommended setup |
11-
| ----------- | -------- | ----------------------------- |
12-
| Production | `master` | Real hardware |
13-
| Development | `dev` | A single Vagrant VM |
10+
| Environment | Branch | Recommended setup |
11+
| ----------- | -------- | ------------------------------------- |
12+
| Production | `master` | Real hardware |
13+
| Development | `dev` | A local [k3d](https://k3d.io) cluster |
1414

1515
For example, if you're trying out the dev VM, use the development environment:
1616

docs/src/deployment/dns.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Because everyone DNS setup are different, DNS automation is not in the scope of
55

66
Some options for DNS config (choose one):
77

8-
- Use nip.io (suitable for a test environment)
8+
- Use [nip.io](https://nip.io) (suitable for a test environment)
99
- Change the DNS config in your router
1010
- Change the DNS config at your domain registrar (doesn't work with the [`home.arpa`](https://datatracker.ietf.org/doc/html/rfc8375) domain)
1111

@@ -17,7 +17,7 @@ Before continuing to the next section for some examples, run this command to get
1717

1818
## Use nip.io
1919

20-
TODO
20+
Preconfigured in the `dev` branch.
2121

2222
## In your router
2323

docs/src/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
{{#include ../../README.md:introduction}}
44

5-
Continue to the next section to try on a VM, or skip to the deployment guide to deploy on real hardware.
5+
Continue to the next section to try locally, or skip to the deployment guide to deploy on real hardware.

docs/src/try-locally.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Try locally
2+
3+
## Caveats compare to production environment
4+
5+
The development cluster doesn't have the following features:
6+
7+
- There is no valid domain name, hence no SSL certificates (some services require valid SSL certificates)
8+
- Only accessible on the host machine
9+
- No backup
10+
<!-- TODO more caveats here -->
11+
12+
Please keep in mind that the development cluster may be unstable and things may break (it's for development after all).
13+
14+
## Prerequisites
15+
16+
Host machine:
17+
18+
- OS: Linux (Windows and macOS are untested)
19+
- Recommended hardware specifications:
20+
- CPU: 4 cores
21+
- RAM: 16 GiB
22+
23+
Install the following packages:
24+
25+
- `docker`
26+
- `make`
27+
28+
Clone the repository (follow the [configuration guide](./deployment/configuration.md) if you want to customize it):
29+
30+
```sh
31+
git clone https://github.com/khuedoan/homelab
32+
git checkout dev
33+
```
34+
35+
## Build
36+
37+
Open the tools container:
38+
39+
```sh
40+
make tools
41+
```
42+
43+
Build a development cluster and bootstrap it:
44+
45+
```
46+
make
47+
```
48+
49+
Look for the dashboard URL in the command output.
50+
51+
## Clean up
52+
53+
Delete the cluster:
54+
55+
```sh
56+
k3d cluster delete homelab-dev
57+
```

docs/src/try-on-a-vm.md

-54
This file was deleted.

metal/Makefile

-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,3 @@ cluster:
2020
console:
2121
ansible-console \
2222
--inventory inventories/${env}.yml
23-
24-
vagrant:
25-
vagrant up

metal/Vagrantfile

-47
This file was deleted.

metal/inventories/dev.yml

-11
This file was deleted.

metal/k3d-dev.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: k3d.io/v1alpha4
2+
kind: Simple
3+
metadata:
4+
name: homelab-dev
5+
image: docker.io/rancher/k3s:v1.23.4-k3s1
6+
servers: 3
7+
agents: 0
8+
options:
9+
k3s:
10+
extraArgs:
11+
- arg: --disable=local-storage
12+
nodeFilters:
13+
- server:*
14+
- arg: --disable=traefik
15+
nodeFilters:
16+
- server:*
17+
- arg: --disable-cloud-controller
18+
nodeFilters:
19+
- server:*
20+
subnet: 172.28.0.0/16

tools/Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ RUN pacman --sync --refresh --noconfirm \
3434
sudo \
3535
terraform
3636

37+
# TODO better way to install k3d?
38+
RUN curl -L https://github.com/k3d-io/k3d/releases/download/v5.4.1/k3d-linux-amd64 > /usr/local/bin/k3d \
39+
&& chmod +x /usr/local/bin/k3d
40+
3741
# TODO https://github.com/ansible-collections/community.docker/issues/216
3842
RUN pip install docker-compose

0 commit comments

Comments
 (0)