-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathTaskfile.yml
executable file
·185 lines (170 loc) · 6.29 KB
/
Taskfile.yml
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
version: '3'
vars:
CYAN: tput setaf 6
RED: tput setaf 1
YELLOW: tput setaf 3
GREEN: tput setaf 2
BLUE: tput setaf 1
PURPLE: tput setaf 5
BG_B: tput setab 0
BOLD: tput bold
RESET: tput sgr0
CLEAR: tput reset
INT_REGISTRY: registry.localhost
PATH_ERROR: is not installed or correctly configured in PATH.
dotenv: ['.env']
silent: true
includes:
argocd: ./tasks/argocd.yaml
templates: ./tasks/templates.yaml
tools: ./tasks/tools.yaml
tasks:
clear:
cmds:
- sleep 0.1 && {{.CLEAR}}
highlight_bg:
cmds:
- |
sleep 0.1 && \
{{.CYAN}} && \
{{.BOLD}} && \
{{.BG_B}}
highlight_normal:
cmds:
- |
sleep 0.1 && \
{{.CYAN}} && \
{{.BOLD}}
reset:
cmds:
- |
sleep 0.1 && \
{{.RESET}}
help:
desc: Displays this message. Type 'task explain -- [command]' to have a in-depth explanation of each command
cmds:
- task: highlight_bg
- echo -e "If you want to understand more abount a command, type task explain -- [command]"
- task: reset
- task --list
default:
cmds:
- task: dns
- task: templates:gen
- task: start
- task: argocd:install
- task: certs
- task: argocd:secret
- task: argocd:password
- task: argocd:bridge
ignore_error: true
explain:
desc: Explains a certain Task command more in-detail
cmds:
- task {{.CLI_ARGS}} --summary
start:
desc: Starts your local k3d cluster.
preconditions:
- sh: "which k3d"
msg: "k3d {{.PATH_ERROR}}"
summary: |
Creating a k3d cluster
This command ensures the cluster on k3d will
be created with all the correct parameters, allowing
for a declarative setup that requires minimal intervention
to work. k3d is configured to automatically create an entry
on your KUBECONFIG file and update it to point towards the cluster.
All commands that create resources also are specific to the cluster
name configured on the file ('k3d-demo'), as to avoid creating those
resoures on non-local clusters that may be on KUBECONFIG file as well.
cmds:
- task: clear
- k3d cluster delete demo
- k3d cluster create --config config/cluster.yaml
- task: highlight_normal
- echo -e "\nYour cluster has been created. Type 'k3d cluster list' to confirm."
- task: reset
ignore_error: true
interactive: true
dns:
desc: Creates the DNS entry required for the local domain to work.
preconditions:
- sh: "which hostctl"
msg: "hostctl {{.PATH_ERROR}}"
summary: |
Configuring Local DNS configuration through hostctl
This command uses hostctl to manage entries on /etc/hosts on a
a cross operational system compatible way. This command should work
on all MacOS, Windows and Linux. It adds all the '*.k8s.localhost'
domains to your local DNS hosts file. It also makes it easy for the
user to reverse those changes, avoiding pollution on your hosts
(or equivalent) file.
cmds:
- task: clear
- sleep 0.01 && {{if eq OS "windows"}}hostctl add k8s -q < config/.etchosts{{else}}sudo hostctl add k8s -q < config/.etchosts{{end}}
- task: highlight_normal
- echo -e "Added 'k8s.localhost' and related domains to your hosts file!"
- task: reset
repos:
desc: Adds and updates all the required Helm repositories locally.
preconditions:
- sh: "which helm"
msg: "helm {{.PATH_ERROR}}"
cmds:
- task: clear
- task: highlight_bg
- echo -e "This will add new repositories to your local Helm\n"
- task: reset
- helm repo add chaos-mesh https://charts.chaos-mesh.org
- helm repo add hashicorp https://helm.releases.hashicorp.com
- helm repo add bitnami https://charts.bitnami.com/bitnami
- helm repo add external-dns https://kubernetes-sigs.github.io/external-dns/
- helm repo add nginx-stable https://helm.nginx.com/stable
- helm repo add hashicorp https://helm.releases.hashicorp.co
- helm repo add lwolf-charts http://charts.lwolf.org
- helm repo add emberstack https://emberstack.github.io/helm-charts
- helm repo add keyporttech https://keyporttech.github.io/helm-charts/
- helm repo add agones https://agones.dev/chart/stable
- helm repo add drone https://charts.drone.io
- helm repo add stakater https://stakater.github.io/stakater-charts
- helm repo add ananace-charts https://ananace.gitlab.io/charts
- helm repo add sealed-secrets https://bitnami-labs.github.io/sealed-secrets
- helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
- task: clear
- echo -e "This will add new repositories to your local Helm\n"
- task: highlight_normal
- echo -e "Finished adding repositories. Updating them now.\n"
- task: reset
- helm repo update
ignore_error: true
certs:
desc: Creates and uploads local certificates to the cluster as tls secrets
dir: config/tls
preconditions:
- sh: "which mkcert"
msg: "mkcert {{.PATH_ERROR}}"
- sh: "which kubectl"
msg: "kubectl {{.PATH_ERROR}}"
cmds:
- task: clear
- task: highlight_bg
- echo -e "Creating local certificates\n"
- task: reset
- rm cert.pem key.pem base/tls-secret.yaml ca.pem 2> /dev/null
- mkcert -install
- mkcert -cert-file cert.pem -key-file key.pem -p12-file p12.pem "*.k8s.localhost" k8s.localhost "*.localhost" ::1 127.0.0.1 localhost 127.0.0.1 "*.internal.localhost" "*.local" 2> /dev/null
- base64 {{if eq OS "darwin"}}-b{{else}}-w{{end}} 0 cert.pem > ca.pem
- task: highlight_bg
- echo -e "Creating certificate secrets on Kubernetes for local TLS enabled by default\n"
- task: reset
- kubectl config set-context --current --namespace=kube-system --cluster=k3d-demo
- kubectl create secret tls tls-secret --cert=cert.pem --key=key.pem --dry-run=client -o yaml >base/tls-secret.yaml
- kubectl apply -k ./
- task: highlight_bg
- echo -e "\nCertificate resources have been created.\n"
- task: reset
ignore_error: true
ns:system:
cmds:
- kubectl config set-context --current --namespace=kube-system --cluster=k3d-demo
ignore_error: true