-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
132 lines (107 loc) Β· 4.28 KB
/
Taskfile.yaml
File metadata and controls
132 lines (107 loc) Β· 4.28 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
version: '3'
dotenv: ['.env']
env:
SOPS_AGE_KEY_FILE: "{{.ROOT_DIR}}/keys.txt"
vars:
REPO_URL: "https://github.com/notDroid/HarmonyChat"
VERSION:
sh: "yq '.version' config.yaml"
K8S_ENV: '{{.K8S_ENV | default "local"}}' # IMPORTANT: set through .env or CLI flag
K8S_CACHE_DIR: '.cache-k8s/{{.K8S_ENV}}'
TF_CACHE_DIR: '.cache-terraform/{{.K8S_ENV}}'
CONFIG_HELMFILE_VALUES: >-
--state-values-file ../../environments/{{.K8S_ENV}}/values.yaml
--state-values-file ../../environments/{{.K8S_ENV}}/secrets.yaml
HELMFILE_ENV: '{{if eq .K8S_ENV "local"}}local{{else}}remote{{end}}'
HELMFILE_CMD: "helmfile -e {{.HELMFILE_ENV}} {{.CONFIG_HELMFILE_VALUES}} --skip-deps"
tasks:
default:
silent: true
cmds: [task --list-all]
# --------------------------------------------------------------------------
# 1. SECRETS
# --------------------------------------------------------------------------
secrets:setup:
desc: "π SECRETS: Configure .sops.yaml with new age key"
cmds:
- uv run scripts/setup_sops.py
secrets:generate:
desc: "π SECRETS: Generate a new secrets.yaml file for the target K8S_ENV"
cmds:
- uv run scripts/generate_secrets.py {{.K8S_ENV}}
secrets:encrypt:
desc: "π SOPS: Encrypt secrets.yaml in place"
cmds:
- sops -e -i environments/{{.K8S_ENV}}/secrets.yaml
secrets:decrypt:
desc: "π SOPS: Decrypt secrets.yaml in place"
cmds:
- sops -d -i environments/{{.K8S_ENV}}/secrets.yaml
# --------------------------------------------------------------------------
# 2. INFRASTRUCTURE
# --------------------------------------------------------------------------
infra:fetch:
desc: "π INFRA: Fetch all templates from app-repo"
cmds:
- task: infra:fetch:k8s
- task: infra:fetch:tf
infra:fetch:k8s:
desc: "π INFRA: Fetch k8s templates from app-repo"
cmds:
- >-
uv run scripts/fetch-k8s.py "{{.REPO_URL}}@{{.VERSION}}"
--cache-dir "{{.K8S_CACHE_DIR}}"
{{if eq .K8S_ENV "local"}}${LOCAL_INFRA_PATH:+--local-path "$LOCAL_INFRA_PATH"}{{end}}
infra:fetch:tf:
desc: "π INFRA: Fetch tf templates from app-repo"
cmds:
- >-
uv run scripts/fetch-terraform.py "{{.REPO_URL}}@{{.VERSION}}"
--cache-dir "{{.TF_CACHE_DIR}}"
{{if eq .K8S_ENV "local"}}${LOCAL_INFRA_PATH:+--local-path "$LOCAL_INFRA_PATH"}{{end}}
infra:clean:
desc: "π§Ή Clean cache directories"
cmds: [rm -rf .cache-k8s/ .cache-terraform/]
infra:render:
desc: "π INFRA: Render environment .gotmpl files to rendered-values/"
dir: "{{.K8S_CACHE_DIR}}"
cmds:
- mkdir -p ../../environments/{{.K8S_ENV}}/rendered-values
- "helmfile -e {{.HELMFILE_ENV}} {{.CONFIG_HELMFILE_VALUES}} --skip-deps write-values --output-file-template='../../environments/{{.K8S_ENV}}/rendered-values/{{`{{.Release.Name}}`}}.yaml'"
infra:sync:
desc: "π INFRA: Sync template and generated values"
cmds:
- task: infra:clean
- task: infra:fetch
- task: infra:render
# --------------------------------------------------------------------------
# 3. ARGOCD
# --------------------------------------------------------------------------
argocd:ui:
desc: Port-forward ArgoCD UI to localhost:8080
cmds:
- kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
- kubectl port-forward svc/argocd-server -n argocd 8080:443
# --------------------------------------------------------------------------
# 4. Terraform
# --------------------------------------------------------------------------
tf:init:
desc: "π TF: Initialize Terragrunt for the target K8S_ENV"
dir: terraform/environments/{{.K8S_ENV}}
cmds:
- terragrunt init
tf:plan:
desc: "π TF: Plan Terragrunt infrastructure for the target K8S_ENV"
dir: terraform/environments/{{.K8S_ENV}}
cmds:
- terragrunt plan
tf:apply:
desc: "π TF: Apply Terragrunt infrastructure for the target K8S_ENV"
dir: terraform/environments/{{.K8S_ENV}}
cmds:
- terragrunt apply
tf:destroy:
desc: "π TF: Destroy Terragrunt infrastructure for the target K8S_ENV"
dir: terraform/environments/{{.K8S_ENV}}
cmds:
- terragrunt destroy