-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
249 lines (221 loc) Β· 6.65 KB
/
Taskfile.yml
File metadata and controls
249 lines (221 loc) Β· 6.65 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
vars:
# Default version to upgrade to - can be overridden with VERSION=x.x.x
TALOS_UPGRADE_VERSION: v1.10.6
tasks:
default:
cmds:
- task --list
up:
desc: Brings up the entire system in order.
cmds:
- task: 00-bootstrap
- task: 01-proxmox
- task: 02-system
- task: 03-base
vars:
STEPS: >-
00-bootstrap
01-proxmox
02-system
03-base
teardown:
desc: Tears down the entire system.
cmds:
- task: 03-base-teardown
- task: 02-system-teardown
- task: 01-proxmox-teardown
- task: 00-bootstrap-teardown
rebuild:
desc: Rebuilds the entire system from scratch.
cmds:
- task: teardown
- task: up
00-bootstrap:
desc: Sets up the initial bootstrap configuration.
cmds:
- task: terraform-up
vars:
DIR: 00-bootstrap
01-proxmox:
desc: Deploys the Proxmox-related configuration.
cmds:
- task: terraform-up
vars:
DIR: 01-proxmox
02-system:
desc: Applies the system-level configuration.
cmds:
- task: terraform-up
vars:
DIR: 02-system
- until talosctl health; do echo 'Waiting for system to be healthy...'; sleep 5; done
03-base:
desc: Deploys the base configuration for the cluster.
cmds:
- task: terraform-up
vars:
DIR: 03-base
00-bootstrap-teardown:
desc: Tears down the bootstrap configuration.
cmds:
- task: terraform-down
vars:
DIR: 00-bootstrap
01-proxmox-teardown:
desc: Tears down the Proxmox-related configuration.
cmds:
- task: terraform-down
vars:
DIR: 01-proxmox
02-system-teardown:
desc: Tears down the system-level configuration.
cmds:
- task: terraform-down
vars:
DIR: 02-system
03-base-teardown:
desc: Tears down the base configuration for the cluster.
cmds:
- task: terraform-down
vars:
DIR: 03-base
init-macos:
desc: Initialize a macOS workstation with dependencies
cmds:
- brew install {{.DEPS}} {{.CLI_ARGS}}
preconditions:
- sh: command -v brew
msg: |
Homebrew is not installed.
vars:
DEPS: >-
go-task/tap/go-task
kubectl
kustomize
helm
terraform
talosctl
k9s
yq
jq
terraform-up:
internal: true
dir: "{{.DIR}}"
cmds:
- terraform init
- terraform apply -auto-approve
terraform-down:
internal: true
dir: "{{.DIR}}"
cmds:
- terraform destroy -auto-approve
# Internal helper tasks
get-controller-ips:
silent: true
cmds:
- cd 01-proxmox && terraform output -json controller_nodes | jq -r 'to_entries[].value.address_ipv4'
get-worker-ips:
silent: true
cmds:
- cd 01-proxmox && terraform output -json worker_nodes | jq -r 'to_entries[].value.address_ipv4'
get-all-ips:
silent: true
cmds:
- task: get-controller-ips
- task: get-worker-ips
get-upgrade-image:
silent: true
cmds:
- |
VERSION="{{.VERSION | default .TALOS_UPGRADE_VERSION}}"
SCHEMATIC_ID=$(cd 01-proxmox && terraform output -raw talos_image_factory_schematic | cut -d'/' -f3 | cut -d':' -f1)
echo "factory.talos.dev/nocloud-installer/${SCHEMATIC_ID}:${VERSION}"
upgrade-node-from-ip:
requires:
vars: [IP]
cmds:
- task: upgrade-node
vars:
NODE: "{{.IP}}"
upgrade-node:
desc: "Upgrade a specific Talos node"
requires:
vars: [NODE]
cmds:
- echo "Upgrading node {{.NODE}}..."
- |
IMAGE=$(task get-upgrade-image)
echo "Using image: $IMAGE"
talosctl upgrade --nodes {{.NODE}} --image "$IMAGE"
upgrade-controllers:
desc: "Upgrade all controller nodes sequentially"
cmds:
- echo "Upgrading controller nodes..."
- |
task get-controller-ips | while read -r ip; do
echo "Upgrading controller node: $ip"
task upgrade-node-from-ip IP="$ip"
done
upgrade-workers:
desc: "Upgrade all worker nodes sequentially"
cmds:
- echo "Upgrading worker nodes..."
- |
task get-worker-ips | while read -r ip; do
echo "Upgrading worker node: $ip"
task upgrade-node-from-ip IP="$ip"
done
upgrade-all:
desc: "Upgrade all nodes sequentially (controllers first, then workers)"
cmds:
- task: upgrade-controllers
- task: upgrade-workers
check-upgrade-status:
desc: Check the current Talos version on all nodes
cmds:
- |
echo "π Checking Talos versions on all nodes..."
cd 01-proxmox && terraform output -json | jq -r '
(.controller_nodes.value // {}) as $controllers |
(.worker_nodes.value // {}) as $workers |
([$controllers, $workers] | add | to_entries[] | .value.address_ipv4)
' | sort -u | while IFS= read -r node; do
if [ -n "$node" ]; then
echo "Checking node $node..."
talosctl version --nodes "$node" || echo "Failed to get version for $node"
fi
done
health-check:
desc: Perform comprehensive health check of the cluster
cmds:
- echo "π₯ Performing cluster health check..."
- echo "Checking Talos cluster health..."
- talosctl health
- echo "Checking Kubernetes cluster info..."
- kubectl cluster-info
- echo "Checking node status..."
- kubectl get nodes -o wide
- echo "Checking system pods..."
- kubectl get pods -n kube-system
check-versions:
desc: Check current and available Talos versions
cmds:
- |
echo "π Current Talos version on nodes:"
cd 01-proxmox && terraform output -json | jq -r '
(.controller_nodes.value // {}) as $controllers |
(.worker_nodes.value // {}) as $workers |
([$controllers, $workers] | add | to_entries[] | .value.address_ipv4)
' | sort -u | while IFS= read -r node; do
if [ -n "$node" ]; then
echo "Node $node:"
talosctl version --nodes "$node" --short 2>/dev/null || echo " Failed to get version"
fi
done
- echo ""
- echo "π¦ Configured upgrade version{{":"}} {{.TALOS_UPGRADE_VERSION}}"
- echo ""
- echo "π Latest Talos releases (check https://github.com/siderolabs/talos/releases):"
- curl -s https://api.github.com/repos/siderolabs/talos/releases | jq -r '.[0:5][] | "\(.tag_name) - \(.published_at | split("T")[0])"' || echo "Failed to fetch latest releases"