snapshot of 82e970afb581494c2d30c99b177f854ed4a00f96 Annotations recorded against the manifests that run this cluster. https://github.com/janpuc/home-ops

bootstrap/mod.just

1 set default-list
2 set default-script
3 set no-exit-message
4 set quiet
5 set script-interpreter := ['bash', '-euo', 'pipefail']
6 set shell := ['bash', '-euo', 'pipefail', '-c']
7
8 controller := `talosctl config info -o yaml | yq -r -e '.endpoints[0]'`
9 nodes := `talosctl config info -o yaml | yq -r -e '.nodes | join (" ")'`
10
11 [confirm('Bootstrap cluster? [y|N]')]
12 [doc('Bootstrap a Talos & Kubernetes cluster end-to-end')]
13 cluster: nodes k8s (kubeconfig "node") base apps kubeconfig
14
15 [private]
16 nodes:
17 just log info "Running stage..." "stage" "{{ recipe_name() }}"
18 for n in {{ nodes }}; do
19 if ! op=$(just --yes talos apply-node "$n" --insecure 2>&1); then
20 if [[ "$op" == *"certificate required"* ]]; then
21 just log info "Talos already configured, skipping apply of config" "stage" "{{ recipe_name() }}" "node" "$n"
22 continue
23 fi
24 just log fatal "Failed to apply Talos configuration" "stage" "{{ recipe_name() }}" "node" "$n" "output" "$op"
25 fi
26 done
27
28 [private]
29 k8s:
30 just log info "Running stage..." "stage" "{{ recipe_name() }}"
31 until op=$(talosctl -n "{{ controller }}" bootstrap 2>&1 || true) && [[ "$op" == *"AlreadyExists"* ]]; do
32 just log info "Kubernetes bootstrap in progress. Retrying in 5 seconds..." "stage" "{{ recipe_name() }}"
33 sleep 5
34 done
35
36 [private]
37 kubeconfig lb="cilium":
38 just log info "Running stage..." "stage" "{{ recipe_name() }}"
39 if ! talosctl kubeconfig -n "{{ controller }}" -f --force-context-name main {{ justfile_dir() }}; then
40 just log fatal "Failed to fetch kubeconfig" "stage" "{{ recipe_name() }}"
41 fi
42 if [[ "{{ lb }}" != "cilium" ]]; then
43 if ! kubectl config set-cluster main --server "https://{{ controller }}:6443"; then
44 just log fatal "Failed to set kubectl cluster server address" "stage" "{{ recipe_name() }}"
45 fi
46 fi
47
48 [private]
49 base: ready
50 just log info "Running stage..." "stage" "{{ recipe_name() }}"
51 if ! kustomize build {{ source_directory() }}/kustomize/personal | just template - | kubectl apply --server-side --force-conflicts -f -; then
52 just log fatal "Failed to apply personal manifests" "stage" "{{ recipe_name() }}"
53 fi
54 if ! helmfile -f "{{ source_directory() }}/helmfile/crds.yaml" template -q | yq ea -r -e 'select(.kind == "CustomResourceDefinition")' | kubectl apply --server-side --force-conflicts -f -; then
55 just log fatal "Failed to apply base crds" "stage" "{{ recipe_name() }}"
56 fi
57
58 [private]
59 apps:
60 just log info "Running stage..." "stage" "{{ recipe_name() }}"
61 if ! helmfile -f "{{ source_directory() }}/helmfile/apps.yaml" sync --hide-notes; then
62 just log fatal "Failed to sync helmfile" "stage" "{{ recipe_name() }}"
63 fi
64
65 [private]
66 ready:
67 just log info "Running stage..." "stage" "{{ recipe_name() }}"
68 if ! kubectl wait nodes --for=condition=Ready=True --all --timeout=10s &>/dev/null; then
69 until kubectl wait nodes --for=condition=Ready=False --all --timeout=10s &>/dev/null; do
70 just log info "Nodes not available, waiting for nodes to be available. Retrying in 5 seconds..." "stage" "{{ recipe_name() }}"
71 sleep 5
72 done
73 fi

Find an annotation

Search file paths, rationale, kinds, and authors.

↑↓ moveEnter openEsc close