Homelab/README.md

55 lines
3.4 KiB
Markdown
Raw Normal View History

2024-02-06 20:36:51 +00:00
# Welcome to my Lab 👻
## What is this?
This is a repo that contains all the code and documentation for my homelab/server(s)
My servers run [Alpine Linux](https://www.alpinelinux.org/about/), chosen for it's small and lightweight footprint leaving more resources for my applications. [ZFS](https://openzfs.org/wiki/Main_Page) acts as the storage layer for my applications and data and provides various protections against data loss. (Backups are still important! Don't store anything in one spot unless you're willing to lose it.) New hosts can be configured with [Ansible](https://docs.ansible.com/ansible/latest/getting_started/index.html) and joined at the application layer.
Docker is used to containerize applications and they are deployed using [Nomad](https://www.nomadproject.io/). This repo has those job specs for you to build off of or utilize yourself. [Consul](https://www.consul.io/) is used for service discovery and service mesh. I use [Traefik](https://traefik.io/) as a reverse proxy to register and route traffic to the applications through tags in the nomad specs to expose the consul services to the outside world.
## Getting Started Yourself
### Host Init
The `host_init` directory contains the ansible playbooks to configure a new host as well as a [readme](./host_init/README.md) to guide you through how. You will need to make sure you have [installed Ansible](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html) if you want to use the playbooks.
On MacOS, you can install Ansible with [Homebrew](https://brew.sh/):
```bash
brew install ansible
```
Once all the playbooks complete, you should be able to access the following web interfaces:
| Service | URL |
| --- | --- |
| Consul | http://\<host>:8500 |
| Nomad | http://\<host>:4646 |
| Traefik | http://\<host>:8080 |
### host_config
This directory contains the configuration files for the nodes in your compute cluster. These files are copied to the host during the host init process. You can learn more about bootstrapping a host in the [host_init readme](./host_init/README.md).
These configs should be good starting points for you to build off of but you may need to make some changes to meet your requirements. (such as security policies, storage, etc.)
You should definitely verify the following fields are what you want:
- `node_name` in consul.hcl
- `bind_addr` in consul.hcl
- `client_addr` in consul.hcl
- `host_volume`s in nomad.hcl
### utils
Rather than update the configuration files on the remote host, you can write your changes to the files directly and use the `utils` directory to copy them to the remote host and restart the services with the new configuration. This is useful for making changes to the configuration files without having to run the host init process again or connecting to the host to make the changes manually.
To run the utils, you will need to have [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/installation_distros.html) installed. When you have ansible installed you can run the utils with the following generic command:
```bash
ansible-playbook -i root@<ipaddress>, ./utils/update<service>Config.yml
```
Be aware, that if you have an error it could cause the service to fail to start and you may need to connect to the host to look at the log files and fix the issue.
### Nomad Jobs
This is where the nomad job specs are stored. You can learn more about the job specs in the [nomad_jobs readme](./nomad_jobs/README.md).