2022-07-03 16:19:22 -05:00
|
|
|
# Home Cluster
|
|
|
|
|
2022-07-05 15:53:37 -05:00
|
|
|
> **NOTE**: Scripts below are in `fish` shell.
|
|
|
|
|
2022-07-03 16:19:22 -05:00
|
|
|
## TODO
|
|
|
|
|
2022-07-05 14:20:27 -05:00
|
|
|
- **Netboot**: https://www.sidero.dev/v0.5/getting-started/prereq-dhcp/
|
|
|
|
- Can probably leverage `dnsmasq` on the router for this?
|
2022-07-03 16:19:22 -05:00
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
2022-07-05 14:20:27 -05:00
|
|
|
### Networking
|
2022-07-03 16:19:22 -05:00
|
|
|
|
|
|
|
- Prepare networking
|
|
|
|
- Internally:
|
|
|
|
- Add a DNS entry for the cluster endpoint (router's `/etc/hosts` + `dnsmasq`) to point to the initial node
|
|
|
|
- Externally:
|
|
|
|
- Add a DNS entry for the cluster endpoint to point to the router
|
|
|
|
- Setup the router to forward external requests to the initial node
|
2022-07-05 14:20:27 -05:00
|
|
|
|
|
|
|
### Setup Kubernetes Cluster
|
|
|
|
|
|
|
|
> **Source**: https://www.talos.dev/v1.1/introduction/getting-started/
|
|
|
|
|
2022-07-06 12:18:18 -05:00
|
|
|
```bash
|
|
|
|
#!/usr/bin/env fish
|
|
|
|
# these are my values, you will want your own
|
|
|
|
set CLUSTER_NAME 'home'
|
|
|
|
set CLUSTER_ENDPOINT 'https://kube-cluster.home.lyte.dev:6443'
|
|
|
|
set NODE_ADDR '10.0.0.101'
|
|
|
|
set AGE_KEY (pass age-key | rg '# public key: ' | awk '{printf $4}')
|
|
|
|
```
|
|
|
|
|
2022-07-05 15:53:37 -05:00
|
|
|
- Setup talos directory if needed
|
|
|
|
- `mkdir -p talos; cd talos`
|
2022-07-03 16:19:22 -05:00
|
|
|
- If you are not using _this_ configuration:
|
2022-07-05 15:53:37 -05:00
|
|
|
- `talosctl gen config "$CLUSTER_NAME" "$CLUSTER_ENDPOINT"`
|
2022-07-07 20:32:35 -05:00
|
|
|
- Edit files as needed, making sure only one of the controlplane nodes is the `endpoint` in the `talosconfig`
|
2022-07-06 12:18:18 -05:00
|
|
|
- `mv talosconfig talosconfig.yaml`
|
2022-07-05 15:53:37 -05:00
|
|
|
- Encrypt via `sops` with `age`
|
2022-07-06 12:18:18 -05:00
|
|
|
- `for f in *; sops yaml --encrypt --age-key "$AGE_KEY" --in-place "$f"; end`
|
2022-07-07 20:32:35 -05:00
|
|
|
- Setup the `talosctl` client to use your configuration
|
|
|
|
- `sops exec-file talosconfig.yaml 'talosctl config merge {}'`
|
|
|
|
- For each node in the cluster as specified in `talosconfig.yaml`, do the
|
|
|
|
following:
|
|
|
|
- Boot the Talos image on the node
|
|
|
|
- Disconnect boot media from the node after it's booted otherwise your
|
|
|
|
Ventoy will get wiped
|
|
|
|
- Apply the appropriate configuration to the node
|
|
|
|
- `sops exec-file (controlplane.yml|worker.yml) 'talosctl apply-config --insecure --nodes '"$NODE_ADDR"' --file {}'`
|
|
|
|
- This can take a moment to finish, but you can move on to the next node
|
|
|
|
while you wait
|
2022-07-03 16:19:22 -05:00
|
|
|
- Bootstrap the cluster
|
2022-07-05 15:53:37 -05:00
|
|
|
- `talosctl bootstrap --nodes "$NODE_ADDR"`
|
2022-07-03 16:19:22 -05:00
|
|
|
- You will need to wait a bit for Kubernetes to initialize
|
|
|
|
- Pull down the kubeconfig
|
|
|
|
- `talosctl kubeconfig`
|
|
|
|
|
|
|
|
Once the cluster has finished initializing _and starting up_, you should be
|
|
|
|
able to `kubectl get nodes`.
|
|
|
|
|
2022-07-05 14:20:27 -05:00
|
|
|
#### Adding Nodes
|
|
|
|
|
2022-07-07 20:32:35 -05:00
|
|
|
> **TODO**: This process is untested!
|
2022-07-03 16:19:22 -05:00
|
|
|
|
2022-07-05 15:53:37 -05:00
|
|
|
- Boot the Talos image on the target node
|
2022-07-06 19:59:33 -05:00
|
|
|
- Add the node to `talosconfig.yaml`
|
2022-07-07 20:32:35 -05:00
|
|
|
- `sops talos/talosconfig.yaml`
|
|
|
|
- Setup the `talosctl` client to use your configuration
|
|
|
|
- `sops exec-file talos/talosconfig.yaml 'talosctl config merge {}'`
|
|
|
|
- Apply the appropriate configuration to all nodes in the cluster
|
2022-07-03 16:19:22 -05:00
|
|
|
|
2022-07-06 19:59:33 -05:00
|
|
|
#### Removing Nodes
|
|
|
|
|
2022-07-07 20:32:35 -05:00
|
|
|
> **TODO**: This process is untested!
|
|
|
|
|
|
|
|
- Cordon and drain the node
|
|
|
|
- Remove the node from `talosconfig.yaml`
|
|
|
|
- `sops talos/talosconfig.yaml`
|
|
|
|
- Update the `talosctl` client to use your configuration
|
|
|
|
- `sops exec-file talos/talosconfig.yaml 'talosctl config merge {}'`
|
|
|
|
- Apply the appropriate configuration to all nodes in the cluster
|
|
|
|
- Power down the node
|
2022-07-06 19:59:33 -05:00
|
|
|
|
2022-07-05 14:20:27 -05:00
|
|
|
#### Untaint Masters
|
|
|
|
|
|
|
|
Since we're "frugal" (cheap) and we want to use all the hardware for all the
|
|
|
|
things:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
kubectl taint nodes --all node-role.kubernetes.io/master-
|
|
|
|
```
|
|
|
|
|
2022-07-06 19:59:33 -05:00
|
|
|
### Apply Manifests
|
2022-07-05 14:20:27 -05:00
|
|
|
|
2022-07-07 20:32:35 -05:00
|
|
|
Currently, all my manifests are managed from a single Kustomize:
|
|
|
|
|
2022-07-05 14:20:27 -05:00
|
|
|
```bash
|
2022-07-06 19:59:33 -05:00
|
|
|
kubectl apply -k manifests
|
2022-07-05 14:20:27 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
### Setting up GitOps
|
|
|
|
|
|
|
|
**TODO**
|
|
|
|
|
|
|
|
### Storage
|
2022-07-03 16:19:22 -05:00
|
|
|
|
2022-07-05 14:20:27 -05:00
|
|
|
**TODO**
|
2022-07-03 16:19:22 -05:00
|
|
|
|
|
|
|
## Load Balancing
|
|
|
|
|
|
|
|
I can _probably_ handle this with my router?
|
|
|
|
|
2022-07-05 14:20:27 -05:00
|
|
|
**TODO**
|