generated from onedr0p/cluster-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
executable file
·85 lines (73 loc) · 3.19 KB
/
Taskfile.yaml
File metadata and controls
executable file
·85 lines (73 loc) · 3.19 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
---
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: '3'
set: [pipefail]
shopt: [globstar]
vars:
BOOTSTRAP_DIR: '{{.ROOT_DIR}}/bootstrap'
KUBERNETES_DIR: '{{.ROOT_DIR}}/kubernetes'
SCRIPTS_DIR: '{{.ROOT_DIR}}/scripts'
TALOS_DIR: '{{.ROOT_DIR}}/talos'
PRIVATE_DIR: '{{.ROOT_DIR}}/.private'
TALOSCONFIG: '{{.ROOT_DIR}}/talos/clusterconfig/talosconfig'
env:
KUBECONFIG: '{{.ROOT_DIR}}/kubeconfig'
SOPS_AGE_KEY_FILE: '{{.ROOT_DIR}}/age.key'
TALOSCONFIG: '{{.TALOSCONFIG}}'
includes:
bootstrap: .taskfiles/bootstrap
talos: .taskfiles/talos
tasks:
default: task --list
reconcile:
desc: Force Flux to pull in changes from your Git repository
cmd: flux --namespace flux-system reconcile kustomization flux-system --with-source
preconditions:
- test -f {{.KUBECONFIG}}
- which flux
generate:deps:
desc: Generate Mermaid dependency graph and check for cycles
env:
PUPPETEER_EXECUTABLE_PATH: ~/.cache/puppeteer/chrome/linux-131.0.6778.204/chrome-linux64/chrome
cmds:
- pnpm add -D @mermaid-js/mermaid-cli
- pnpm dlx puppeteer@23.11.1 browsers install chrome
- python3 scripts/generate_deps.py
# sources:
# - kubernetes/apps/**/*.yaml
# generates:
# - DEPENDENCIES.md
volsync:validate:
desc: Check for VolSync PVC cache size mismatches, missing cache PVCs, and orphaned PVCs
silent: true
cmds:
- |
echo "🔍 Validating VolSync ReplicationSources for cache size mismatches..."
kubectl get replicationsource -A -o json | jq -r '.items[] | [.metadata.namespace, .metadata.name, .spec.restic.cacheCapacity] | @tsv' | while IFS=$'\t' read -r ns name expected; do
pvc="volsync-${name}-cache"
actual=$(kubectl get pvc "$pvc" -n "$ns" -o jsonpath="{.status.capacity.storage}" 2>/dev/null || echo "missing")
if [ "$actual" = "missing" ]; then
echo "❌ [ReplicationSource $ns/$name] Cache PVC '$pvc' not found"
elif [ "$actual" != "$expected" ]; then
echo "⚠️ [ReplicationSource $ns/$name] Expected cache=$expected, but PVC=$actual"
else
echo "✅ [ReplicationSource $ns/$name] Cache size matches ($actual)"
fi
done
echo ""
echo "🔍 Checking for orphaned VolSync cache PVCs (no matching ReplicationSource or ReplicationDestination)..."
found_orphans=0
for ns in $(kubectl get ns -o jsonpath='{.items[*].metadata.name}'); do
for pvc in $(kubectl get pvc -n "$ns" -o name | grep '^persistentvolumeclaim/volsync-' || true); do
base=$(echo "$pvc" | sed 's|persistentvolumeclaim/volsync-||; s|-cache||')
rs_exists=$(kubectl get replicationsource "$base" -n "$ns" --ignore-not-found)
rd_exists=$(kubectl get replicationdestination "$base" -n "$ns" --ignore-not-found)
if [ -z "$rs_exists" ] && [ -z "$rd_exists" ]; then
echo "🧹 [Orphaned PVC] $ns/$pvc has no matching ReplicationSource or ReplicationDestination"
found_orphans=1
fi
done
done
if [ "$found_orphans" -eq 0 ]; then
echo "✅ No orphaned VolSync PVCs found."
fi