Repository navigation
Expand file tree
/
Copy pathTaskfile.yml
More file actions
131 lines (115 loc) · 3.82 KB
/
Copy pathTaskfile.yml
File metadata and controls
131 lines (115 loc) · 3.82 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
version: "3"
vars:
CLUSTER_NAME: tekfoundry
K3D_CONFIG: infra/k3d/cluster.yaml
GITHUB_OWNER: EpicMandM
GITHUB_REPO: tekfoundry
FLUX_PATH: clusters/local
AGE_KEY_FILE: .secrets/age.agekey
SOPS_AGE_SECRET: sops-age
tasks:
default:
cmds:
- go-task --list
cluster:provision:
desc: Create k3d cluster
cmds:
- k3d cluster create --config {{.K3D_CONFIG}}
status:
- k3d cluster list -o json | grep -q '"name":"{{.CLUSTER_NAME}}"'
cluster:destroy:
desc: Delete k3d cluster
cmds:
- k3d cluster delete {{.CLUSTER_NAME}}
ignore_error: true
cluster:reprovision:
desc: Recreate k3d cluster
cmds:
- task: cluster:destroy
- task: cluster:provision
cluster:status:
desc: Cluster status
cmds:
- k3d cluster list
- kubectl get nodes -o wide
flux:bootstrap:
desc: Bootstrap Flux
cmds:
- |
export GITHUB_TOKEN="${GITHUB_TOKEN:-$(gh auth token)}"
flux bootstrap github \
--owner={{.GITHUB_OWNER}} \
--repository={{.GITHUB_REPO}} \
--branch=main \
--path={{.FLUX_PATH}} \
--personal \
--token-auth \
--components-extra=image-reflector-controller,image-automation-controller
flux:check:
desc: Flux health
cmds:
- flux check
flux:reconcile:
desc: Reconcile Flux
cmds:
- flux reconcile source git flux-system -n flux-system
- flux reconcile kustomization flux-system -n flux-system
flux:status:
desc: Flux resources
cmds:
- flux get all -A
sops:age:keygen:
desc: Generate age key
status:
- test -f {{.AGE_KEY_FILE}}
cmds:
- mkdir -p .secrets
- age-keygen -o {{.AGE_KEY_FILE}}
sops:age:secret:
desc: Install age key in cluster
deps: [sops:age:keygen]
cmds:
- |
kubectl -n flux-system create secret generic {{.SOPS_AGE_SECRET}} \
--from-file=age.agekey={{.AGE_KEY_FILE}} \
--dry-run=client -o yaml | kubectl apply -f -
sops:encrypt:
desc: Encrypt Secret (FILE=...)
requires:
vars: [FILE]
cmds:
- SOPS_AGE_KEY_FILE={{.AGE_KEY_FILE}} sops --encrypt --in-place "{{.FILE}}"
sops:decrypt:
desc: Decrypt Secret (FILE=...)
requires:
vars: [FILE]
cmds:
- SOPS_AGE_KEY_FILE={{.AGE_KEY_FILE}} sops --decrypt "{{.FILE}}"
cloudflare:waf:pac:
desc: Sync GitHub webhook IPs into Cloudflare WAF
cmds:
- |
set -euo pipefail
eval "$(rg -m1 '^export CF_API_TOKEN=' "${HOME}/.bashrc" || true)"
eval "$(rg -m1 '^export CF_ZONE_ID=' "${HOME}/.bashrc" || true)"
: "${CF_API_TOKEN:?export CF_API_TOKEN in ~/.bashrc}"
: "${CF_ZONE_ID:=32fb42a4b7c8d4c3d1e043be5dd7dc94}"
export CF_API_TOKEN CF_ZONE_ID
python3 hack/cloudflare-pac-waf.py
cloudflare:secret:
desc: SOPS-encrypt cloudflare-api secret from ~/.bashrc
cmds:
- |
set -euo pipefail
eval "$(rg -m1 '^export CF_API_TOKEN=' "${HOME}/.bashrc" || true)"
eval "$(rg -m1 '^export CF_ZONE_ID=' "${HOME}/.bashrc" || true)"
: "${CF_API_TOKEN:?export CF_API_TOKEN in ~/.bashrc}"
: "${CF_ZONE_ID:=32fb42a4b7c8d4c3d1e043be5dd7dc94}"
PAC_HOSTNAME="$(SOPS_AGE_KEY_FILE={{.AGE_KEY_FILE}} sops -d infra/network/cloudflared/config.yaml | sed -n 's/.*hostname: //p' | head -1)"
: "${PAC_HOSTNAME:?PAC hostname missing from cloudflared config}"
kubectl -n tekfoundry create secret generic cloudflare-api \
--from-literal=CF_API_TOKEN="${CF_API_TOKEN}" \
--from-literal=CF_ZONE_ID="${CF_ZONE_ID}" \
--from-literal=PAC_HOSTNAME="${PAC_HOSTNAME}" \
--dry-run=client -o yaml > infra/ci/cloudflare-api.secret.yaml
SOPS_AGE_KEY_FILE={{.AGE_KEY_FILE}} sops --encrypt --in-place infra/ci/cloudflare-api.secret.yaml