-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtaskfile.yaml
113 lines (100 loc) · 3.67 KB
/
taskfile.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
vars:
TALOS_CONTROLLER:
sh: talosctl config info --output json | jq --raw-output '.endpoints[]' | shuf -n 1
tasks:
generate:
desc: Generate Talos machine configurations
dir: "{{.TALOS_DIR}}"
env:
VAULT: '{{if eq .CLUSTER "main"}}Homelab{{else}}{{.CLUSTER}}{{end}}'
cmds:
- op run --env-file="./op.env" -- talhelper genconfig
sources:
- talconfig.yaml
- talsecret.yaml
generates:
- clusterconfig/*.yaml
- clusterconfig/talosconfig
apply-config:
desc: Apply Talos config on a node
dir: "{{.TALOS_DIR}}"
cmds:
- task: generate
- task: wait_for_health
vars: { TIMEOUT: 30s }
- talhelper gencommand apply -n {{.node}} | bash
requires:
vars: ["node"]
upgrade-talos:
desc: Upgrade Talos on a node
dir: "{{.TALOS_DIR}}"
cmds:
- task: generate
- task: wait_for_health
vars: { TIMEOUT: 30s }
- talhelper gencommand upgrade -n {{.node}} --extra-flags=--stage | bash
requires:
vars: ["node"]
upgrade-k8s:
desc: Upgrade Kubernetes
dir: "{{.TALOS_DIR}}"
cmds:
- task: generate
- task: wait_for_health
vars: { TIMEOUT: 30s }
- talosctl -n {{.TALOS_CONTROLLER}} etcd snapshot etcd.backup
- talhelper gencommand upgrade-k8s | bash
wait_for_health:
internal: True
desc: Wait for services in cluster to be healthy
cmds:
# Ensure CephCluster is healthy
- kubectl -n rook-ceph wait --for jsonpath='{.status.ceph.health}'='HEALTH_OK' --timeout {{ .TIMEOUT | default "30s" }} cephcluster rook-ceph
# Ensure CloudNative-PG cluster has 3 ready instances
- kubectl -n databases wait --for jsonpath='{.status.readyInstances}'='3' --timeout {{ .TIMEOUT | default "30s" }} cluster postgres16
- kubectl -n databases wait --for jsonpath='{.status.readyInstances}'='3' --timeout {{ .TIMEOUT | default "30s" }} cluster postgres17
bootstrap:
desc: Bootstrap Talos
cmds:
- task: :talos:generate
- task: :talos:bootstrap-apply-config
- task: :talos:bootstrap-etcd
- task: :talos:kubeconfig
- task: :talos:bootstrap-core-apps
bootstrap-apply-config:
desc: Apply Talos config on all nodes
dir: "{{.TALOS_DIR}}"
cmds:
- talhelper gencommand apply --extra-flags=--insecure | bash
bootstrap-etcd:
desc: Bootstrap etcd
cmds:
- until talosctl --nodes {{.TALOS_CONTROLLER}} bootstrap; do sleep 10; done
kubeconfig:
desc: Get an updated version of kubeconfig with updated/rotated certificates
cmds:
- talosctl kubeconfig ~/.kube/configs/main -n {{.TALOS_CONTROLLER}}
- kubectl config rename-context admin@main main
bootstrap-core-apps:
desc: Bootstrap core helm apps
cmds:
- until kubectl wait --for=condition=Ready=False nodes --all --timeout=600s; do sleep 10; done
- helmfile --file {{.CLUSTER_DIR}}/bootstrap/helmfile.yaml apply
- until kubectl wait --for=condition=Ready nodes --all --timeout=600s; do sleep 10; done
write-talos-amd64-to-usb:
desc: Write Talos image to USB drive to be used with Raspberry Pi 4
silent: true
cmds:
- "curl -LOC - https://factory.talos.dev/image/dafae93fc4a2c32184af894f78c74d04f1ccabd000f0d2b2bb951628c97ac5c8/v1.9.2/metal-amd64.raw.xz && xz -d metal-amd64.raw.xz"
- "diskutil list"
- |
echo "Path to USB drive:"
read path;
diskutil unmount ${path} || true
diskutil unmountDisk ${path} || true
echo "Writing image to: ${path}";
sudo dd if=metal-amd64.raw of=${path} bs=4m && sync
- "rm metal-amd64.raw"