-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTaskfile.yml
More file actions
141 lines (123 loc) · 4.29 KB
/
Taskfile.yml
File metadata and controls
141 lines (123 loc) · 4.29 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
# https://taskfile.dev
version: "3"
set: [errexit, nounset, pipefail]
env:
KUBECONFIG: "{{.ROOT_DIR}}/private/kubeconfig"
REPO_ROOT: "{{.ROOT_DIR}}"
vars:
CONFIG_FILE: "{{.ROOT_DIR}}/config.yaml"
REQUIRED_CLIS: [gcloud, kubectl, kubelogin, yq, helm, helmfile, yamale]
includes:
test:
taskfile: ./Taskfile.test.yml
flatten: true
optional: true
tasks:
init:
deps:
- task: config:lint
cmds:
- cmd: bash command -V {{.ITEM}}
for:
var: REQUIRED_CLIS
- task: helmfile:init
- task: helmfile:lint
- task: helmfile:build
install:
cmds:
- task: kind:create
- task: apply
apply:
deps:
- task: config:lint
cmds:
- task: kubeconfig:set-context:kind
- task: helmfile:apply
diff:
deps:
- task: config:lint
- task: kubeconfig:set-context:kind
cmds:
- task: helmfile:diff
sync:
deps:
- task: config:lint
- task: kubeconfig:set-context:kind
cmds:
- task: helmfile:sync
config:lint:
silent: true
cmds:
- cmd: yamale -s "{{.ROOT_DIR}}/config.schema.yaml" "{{.CONFIG_FILE}}"
- defer: rm -f "{{.ROOT_DIR}}/private/gcp-credentials.yaml"
- cmd: test -f "{{.ROOT_DIR}}/private/gcp-credentials.json" || (echo ERROR\:\ private/gcp-credentials.json not found && exit 1)
- cmd: yq -o=yaml "{{.ROOT_DIR}}/private/gcp-credentials.json" > "{{.ROOT_DIR}}/private/gcp-credentials.yaml"
- cmd: yamale -s "{{.ROOT_DIR}}/private/gcp-credentials.schema.yaml" "{{.ROOT_DIR}}/private/gcp-credentials.yaml"
get:urls:
deps:
- task: kubeconfig:set-context:gke
cmd: >-
kubectl get ingress -A -o yaml | yq '.items[] | {(.metadata.name): ((select(.spec.tls != null) | "https://" // "http://") + .spec.rules[].host + .spec.rules[].http.paths[].path)}'
kubeconfig:set-context:gke:
deps:
- task: kubeconfig:update:gke
cmd: kubectl config set-context "$(yq '.cluster_name' {{.CONFIG_FILE}})"
kubeconfig:set-context:kind:
deps:
- task: kubeconfig:update:kind
cmd: kubectl config set-context $(yq '.name' "{{.ROOT_DIR}}/kind.yaml")
kubeconfig:update:gke:
deps:
- task: gcp:init
cmd: gcloud container clusters get-credentials "$(yq '.cluster_name' {{.CONFIG_FILE}})"
kubeconfig:update:kind:
cmd: kind export kubeconfig --quiet --name $(yq '.name' "{{.ROOT_DIR}}/kind.yaml")
gcp:init:
deps:
- task: config:lint
silent: true
cmds:
- cmd: gcloud config set project "$(yq '.project' {{.CONFIG_FILE}})"
- cmd: gcloud config set compute/region "$(yq '.region' {{.CONFIG_FILE}})"
uninstall:
deps:
- task: gcp:init
ignore_error: true
cmds:
- defer: rm -f "{{.KUBECONFIG}}"
- task: kubeconfig:set-context:gke
- cmd: kubectl delete workloadidentities.gcp.livewyer.io -A --all --interactive=false --now && sleep 60
- cmd: gcloud iam service-accounts delete crossplane
- cmd: kubectl delete pkg.crossplane.io -A --all --interactive=false --now
- cmd: kubectl -n argocd delete appset $(yq '. | keys - ["argocd"] | .[]' ${REPO_ROOT}/packages/addons/values.yaml) --interactive=false --now
- cmd: kubectl -n argocd delete app $(kubectl -n argocd get app -o yaml | yq '.items[] | select(.metadata.labels.addonName!="argocd").metadata.name') --interactive=false --now
- task: kubeconfig:set-context:kind
- cmd: kubectl -n argocd delete appset cnoe argocd --interactive=false --now && sleep 300
- task: helmfile:destroy
- task: kind:delete
kind:create:
cmd: kind create cluster --config "{{.ROOT_DIR}}/kind.yaml"
kind:delete:
cmd: kind delete cluster --name $(yq '.name' "{{.ROOT_DIR}}/kind.yaml")
helmfile:init:
cmd: helmfile init {{.CLI_ARGS}}
helmfile:lint:
cmd: helmfile lint {{.CLI_ARGS}}
helmfile:diff:
cmd: helmfile diff {{.CLI_ARGS}}
helmfile:build:
cmd: helmfile build {{.CLI_ARGS}}
helmfile:apply:
cmd: helmfile apply {{.CLI_ARGS}}
helmfile:list:
cmd: helmfile list {{.CLI_ARGS}}
helmfile:status:
cmd: helmfile status {{.CLI_ARGS}}
helmfile:template:
cmd: helmfile template {{.CLI_ARGS}}
helmfile:deps:
cmd: helmfile deps {{.CLI_ARGS}}
helmfile:sync:
cmd: helmfile sync {{.CLI_ARGS}}
helmfile:destroy:
cmd: helmfile destroy {{.CLI_ARGS}}