Skip to content

Bootstrap

Takes freshly installed Talos nodes all the way to a self-managing Flux cluster, and provisions a fresh Docker host, such as the TrueNAS server, with its stacks. Everything is driven by bootstrap/mod.just.

Prerequisites

  • A clone of this repo, with mise installed and activated and mise install run
  • A signed-in 1Password CLI (op). Every op:// reference is resolved at apply time with op inject.
  • A valid talosconfig at the repo root, generated with just talos gen-talosconfig (see Talos → talosconfig). The controller endpoint and node list are derived from talosctl config info, so nothing is hardcoded.
  • The UDM BGP config and static DNS records in place. k8s.internal only works once Cilium is running, so bootstrap talks to the controller's node IP until then.
  • Nodes booted into Talos maintenance mode, for example from a Bootimus PXE boot or an ISO from just talos download-image <version>.

Cluster

just bootstrap cluster
graph LR
    nodes --> k8s --> kubeconfig --> base --> apps --> store-configs --> drop-helm-owners
  1. nodes: renders each node's Talos config (templates plus 1Password injection) and applies it with talosctl apply-config --insecure. Nodes that are already configured are skipped.
  2. k8s: runs talosctl bootstrap against the controller, retrying until etcd reports that the cluster exists.
  3. kubeconfig: fetches the kubeconfig and rewrites the server to the controller's node IP, because the generated https://k8s.internal:6443 points at a Cilium VIP that doesn't exist yet.
  4. base: waits for every apiserver to answer /readyz and for nodes to register (they stay Ready=False until the CNI is up), then applies:
    • kustomize/: bootstrap Secrets rendered through op inject (1Password Connect credentials and token, Cloudflare tunnel ID) plus their namespaces, so no controller deadlocks on a missing Secret
    • helmfile/crds.yaml: CRDs extracted from upstream charts (envoy-gateway, grafana-operator, kopiur, kube-prometheus-stack)
  5. apps: helmfile sync of the minimal release chain Flux needs before it can take over:

    cilium → coredns → spegel → cert-manager → external-secrets →
    onepassword-connect → flux-operator → flux-instance
    

    The kubeconfig is then fetched again, so its endpoint is back to k8s.internal.

  6. store-configs: uploads kubeconfig and talosconfig to the cluster item in 1Password (see Client configs).

  7. drop-helm-owners: waits until Flux reports each helmfile release's HelmRelease Ready (up to 15 minutes each), then removes the helm field manager from every object in that release (see Field managers).

Once flux-instance is healthy, Flux reconciles kubernetes/ and manages the same releases from then on.

Field managers

Helm 4 server-side applies the helmfile releases as field manager helm, and has no option to name it differently. When Flux takes the releases over, helm-controller applies as helm-controller and leaves the helm entry in place. A field that a later chart version stops rendering then stays on the object, because helm still owns it: in October 2026 a Spegel annotation outlived the chart version that set it, and in November 2026 a Cilium upgrade failed on a leftover init container without an image.

The drop-helm-owners stage removes the helm entry so helm-controller is the only owner. It only touches objects that helm-controller already manages; others are logged as a warning. Re-run it on its own if that happens, or if the stage timed out:

just bootstrap drop-helm-owners [timeout]

The patches change only metadata.managedFields, so nothing restarts. Objects applied with kubectl apply --server-side in the base stage need no cleanup: Flux's kustomize-controller removes the kubectl field manager by itself.

Every stage is safe to re-run

If bootstrap fails partway, fix the issue and run just bootstrap cluster again.

Single source of truth

The helmfiles define no chart versions or values of their own. Each release's chart and version are read from the app's ocirepository.yaml, and its values from the app's helmrelease.yaml, under kubernetes/apps/ (see bootstrap/kubernetes/helmfile/templates/). Bootstrap therefore installs exactly what Flux will reconcile later, and Renovate only updates one place.

Data

Bootstrap restores no application data itself. As Flux deploys each app, its PVC is populated from the latest Kopiur snapshot, and CNPG clusters recover from Barman. Pods stay Pending until their volume is restored. See Backups → Deploy-or-restore.

Verifying

kubectl get nodes                                  # all Ready
flux get ks -A | grep -v True                      # nothing stuck
kubectl -n rook-ceph exec deploy/rook-ceph-tools -- ceph status
curl -k https://k8s.internal:6443/livez

Client configs

kubeconfig and talosconfig are kept on the cluster item in the Homelab 1Password vault, each in its own section with the expiry date of its client certificate:

Section Fields
(none) next expiry (date): the earliest of the two expires dates
Kubernetes kubeconfig (file), expires (date)
Talos talosconfig (file), expires (date)

To operate an existing cluster from a new machine, clone the repo, run mise install, sign in to op, then:

just bootstrap restore-configs

This restores both files to the repo root with mode 0600. Files that already match are left alone, and a local file that differs is only overwritten after a prompt. A new cluster has nothing to restore yet: generate its talosconfig with just talos gen-talosconfig, and bootstrap creates the kubeconfig.

just bootstrap store-configs [files...]

Uploads the local kubeconfig and talosconfig to that item, replacing the attachments in place, or only the files named (for example just bootstrap store-configs kubeconfig). It also sets each section's expires date to the expiry date of the file's client certificate, and then next expiry to the earliest of the two. Files whose attachment and date already match are skipped, and a missing file is an error. just bootstrap cluster runs this as its last stage. Run it by hand whenever either file changes outside bootstrap. restore-configs and store-configs both log each file's expiry date.

Both client certificates expire after a year. Renew them with just talos gen-kubeconfig and just talos gen-talosconfig (see Talos → Client configs); both store the new file and its expiry date in 1Password.

Expiry alerts

1Password allows one expiry alert per item, so it goes on next expiry, which follows whichever certificate expires first: edit the item in the 1Password app, open Set expiry alert under next expiry and choose 2 weeks before. The CLI can't set alerts, so this is a one-time step in the app. The alert survives store-configs updating the date and moves with it.

The cluster item must be a Secure Note

store-configs updates the attachments with op item edit, which validates the whole item. A Password item with an empty password fails with Password item requires ps value, and 1Password can't change an item's category, so recreate it as a Secure Note with the sections above. A Document item doesn't work either: it holds a single file.

Docker hosts

just bootstrap docker <host>

<host> is the name shared by the host's directories and inventory group:

Path Purpose
docker/<host>/ The compose stacks doco-cd deploys
bootstrap/docker/<host>/bootstrap.yaml Ansible playbook that provisions the host
<host> group in ansible/inventory.yaml The host's address and connection variables, including ansible_become_password as a 1Password lookup

The recipe runs the host's playbook against the inventory. An unknown host fails and lists the available ones.

For the NAS (just bootstrap docker nas), the playbook provisions TrueNAS, writes doco-cd's secrets and starts doco-cd from docker/nas/00-doco-cd, which then reconciles the docker/nas/ stacks, including its own. Nothing in bootstrap/ is used again until the next provisioning.

To add a host, create those three pieces. Secrets are read with the community.general.onepassword lookup. The become password only lives in memory for the run and never sits on disk; the secrets a playbook hands to the host (on the NAS, doco-cd's 1pw_token, api_keys and webhook_secret in its config directory) are written there as files. Lookups are lazy, so each playbook resolves them once in a Gather secrets set_fact task at the start; without it, op would run on every task that uses them.