-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTaskfile.yml
412 lines (354 loc) · 10.1 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
version: '3'
vars:
G: ""
N: ""
T: ""
P: ""
BASETAG: 0.1.0-incubating
KUBE:
sh: ./detect.sh
NS: "nuvolaris"
PREFIX: ""
TAG:
dotenv:
- .env
includes:
d:
taskfile: TaskfileDev.yml
t:
taskfile: TaskfileTest.yml
b:
taskfile: TaskfileBuild.yml
o:
taskfile: TaskfileOlaris.yml
kind:
taskfile: clusters/kind.yml
dir: clusters
eks:
taskfile: clusters/eks.yml
dir: clusters
aks:
taskfile: clusters/aks.yml
dir: clusters
lks:
taskfile: clusters/lks.yml
dir: clusters
gke:
taskfile: clusters/gke.yml
dir: clusters
mik:
taskfile: clusters/microk8s.yml
dir: clusters
k3s:
taskfile: clusters/k3s.yml
dir: clusters
osh:
taskfile: clusters/openshift.yml
dir: clusters
sys:
taskfile: actions/system.yml
dir: actions
talos:
taskfile: clusters/talos-gcp.yml
dir: clusters
tasks:
default:
- task: use
setup:
deps:
- update-files-from-openwhisk
- ssh-key
- configure-env
cmds:
- mkdir -p ~/.kube ; touch ~/.kube/config
- poetry install
status:
- test -e $GOBIN/kopf
env: env
watch: watch kubectl -n {{.NS}} get nodes,pod,svc,pvc,ingress
watch-osh: watch kubectl -n {{.NS}} get nodes,pod,svc,pvc,route
watch-cert: watch kubectl -n {{.NS}} get ingress,ClusterIssuers,Certificates,CertificateRequests,Orders,Challenges
watch-pod: watch kubectl -n {{.NS}} get po,job --no-headers
logs: >
rm -f nuvolaris-operator.log ;
kubectl -n nuvolaris logs pod/nuvolaris-operator -f | tee nuvolaris-operator.log
cli:
- task: d:cli
run:
- task: sys:prepare
- task: t:permission
- task: d:run
irun:
- task: instance
- task: d:run
permission:
- task: t:permission
operator:
- task: t:operator
instance:
- task: t:instance
instance-wfx:
- task: d:instance-wfx
instance-and-log:
- task: d:instance
- kubectl -n nuvolaris logs pod/nuvolaris-operator -f
mongo:
- task: t:mongo
minio:
- task: t:minio
postgres:
- task: t:postgres
minimal:
#- task: permission
- task: operator
- task instance WHISK=minimal
- task: config
- task: hello
all:
- task: permission
- task: operator
- task: instance
- task: config
- task: hello
- task: redis
- task: mongo
- task: minio
- task: postgres
config:
- task: t:config
hello:
- task: t:hello
redis:
- task: t:redis
workflow:
- kubectl -n nuvolaris apply -f tests/workflow-test.yaml
defin:
- task: d:defin
# old., to be removed
image-tag:
- git tag -d $(git tag)
- git tag -f {{.P}}{{.BASETAG}}.$(date +%y%m%d%H%M)
- env PAGER= git tag
# configure env
configure-env:
cmds:
- |
if ! test -e .env
then echo "please copy .env.dist in .env and add the keys"
fi
# update configuration files from openwhisk source
update-files-from-openwhisk:
ignore_error: true
cmds:
- |
cp -v ../nuvolaris/nuvolaris-controller/openwhisk/ansible/files/*.json nuvolaris/files
cp -v ../nuvolaris/nuvolaris-controller/openwhisk/bin/wskadmin tools/cli/wsk/wskadmin.py
cp -v ../nuvolaris/nuvolaris-controller/openwhisk/tools/admin/*.py tools/cli/wsk
sources:
- ../nuvolaris/nuvolaris-controller/openwhisk/ansible/files/*.json
- ../nuvolaris/nuvolaris-controller/openwhisk/bin/wskadmin
- ../nuvolaris/nuvolaris-controller/openwhisk/tools/admin/*.py
generates:
- nuvolaris/files/*.json
- nuvolaris/tools/cli/wsk/*.py
# generate ssh keys
ssh-key:
cmds:
- test -f clusters/id_rsa || ssh-keygen -b 2048 -t rsa -f clusters/id_rsa -q -N ""
- ssh-keygen -y -f clusters/id_rsa >clusters/id_rsa.pub
clean:
cmds:
- cmd: kubectl -n nuvolaris delete wsku --all
ignore_error: true
- cmd: kubectl -n nuvolaris delete kubegres --timeout=60s
ignore_error: true
- cmd: kubectl -n nuvolaris delete milvus --timeout=60s
ignore_error: true
- cmd: kubectl -n nuvolaris delete wsk/controller --grace-period=0 --timeout=5s
ignore_error: true
- cmd: task defin
ignore_error: true
- cmd: kubectl -n nuvolaris delete all --all --grace-period=0
ignore_error: true
- cmd: kubectl -n nuvolaris delete pvc --all --grace-period=0
ignore_error: true
- cmd: kubectl -n nuvolaris delete ing --all --grace-period=0
ignore_error: true
- cmd: kubectl -n nuvolaris delete cm/config --grace-period=0
ignore_error: true
- cmd: kubectl delete clusterissuers/letsencrypt-issuer
ignore_error: true
utest:
cmds:
- |
for test in nuvolaris/{{.T}}*.py
do echo "*** [{{.KUBE}}] $test"
poetry run python3 -m doctest $test {{.CLI_ARGS}}
done
silent: true
iclean: rm -f deploy/*/kustomization.yaml deploy/*/__* deploy/*/*_generated.yaml
itest:
cmds:
- task: iclean
- |
kubectl apply -f deploy/nuvolaris-permissions
rm -f _failed.txt
for test in tests/{{.T}}*.ipy tests/{{.KUBE}}/{{.T}}*.ipy
do
if test -e "$test"
then echo "*** [{{.KUBE}}] $test"
rm -f deploy/*/kustomization.yaml deploy/*/__*
if poetry run ipython $test {{.CLI_ARGS}}
then echo "OK: $test"
else echo "FAIL: $test"
echo $test >>_failed.txt
fi
fi
done
if test -e _failed.txt
then echo "*** FAILED TESTS:"
cat _failed.txt
fi
silent: true
dtest:
cmds:
- task: permission
- task: operator
- task: instance
- task: actions
actions:
- task: t:config
- task: t:hello
- task: t:redis
- task: t:echo
test:
- task: clean
- task: utest
- task: itest
- task: dtest
debug:
- poetry run ipython profile create
- cp test_profile.ipy ~/.ipython/profile_default/startup/
- task: uitest
all-kubes:
cmds:
- |-
if test -z "{{.CLI_ARGS}}"
then echo 'use "task all-kubes -- <target> runs the target against all the available kubes'
else for cfg in clusters/*.kubeconfig
do /usr/games/cowsay -f duck $(basename $cfg .kubeconfig) 2>/dev/null
cp -v $cfg ~/.kube/config >/dev/null
task {{.CLI_ARGS}}
done
fi
silent: true
kube-test:
cmds:
- task dtest 2>/dev/null >/dev/null
use:
cmds:
- |-
if test -z "{{.N}}"
then echo "*** current: {{.KUBE}}"
ls clusters/*.kubeconfig | sort | awk '{ print NR, $0 }'
echo "*** select with 'task #'"
else CFG="$(ls -1 clusters/*.kubeconfig | tail +{{.N}} | head -1)"
cp $CFG ~/.kube/config
echo "cluster: $(./detect.sh)"
kubectl get nodes
fi
silent: true
build-and-load:
- task: b:build-and-load
build-and-push:
- task: b:build-and-push
buildx-and-push:
- task: b:buildx-and-push
docker-login:
- task: b:docker-login
# openserverless-operator section
tag:
silent: true
desc: generate a new tag based on the current time
cmds:
- git tag -d $(git tag) || true
- git tag -f {{.BASETAG}}.$(date +%y%m%d%H%M)
- env PAGER= git tag
install-registry:
desc: install a local registry
cmds:
- sudo cp registries.yaml /etc/rancher/k3s/registries.yaml
- sudo systemctl restart k3s
- helm repo add twuni https://helm.twun.io
- >
helm install docker-registry twuni/docker-registry
--namespace kube-system
--set image.tag=2.8.3
--set service.type=NodePort
--set service.nodePort=30050
status:
- kubectl -n kube-system get po -l app=docker-registry | grep docker-registry
tag-commit-push:
desc: tag, commit and push to your default upstream repo (see README.md)
cmds:
- task: tag
- git commit -m "{{.TAG}}" -a || true
- git push || true
kaniko-build:
desc: build in current kubernetes with Kaniko
env:
TAG:
sh: git describe --tags --abbrev=0 2>/dev/null || echo latest
cmds:
- test -n "$GITHUB_USER" || true "did you configure your .env?"
- envsubst <kaniko-build.yaml >_kaniko-build.yaml
- kubectl -n default delete job/kaniko-build || true
- kubectl -n default apply -f _kaniko-build.yaml
- kubectl wait po --for=condition=ready -l app=kaniko-build -n default
build-logs:
desc: show logs of the latest build
cmds:
- kubectl -n default logs -l app=kaniko-build -f
build:
desc: build the operator image
cmds:
- task: install-registry
- task: tag-commit-push
- task: kaniko-build
- task: build-logs
deploy:
desc: deploy the current operator image
env:
TAG:
sh: git describe --tags --abbrev=0 2>/dev/null || echo latest
cmds:
- envsubst <operator-deploy.yaml >_operator-deploy.yaml
- kubectl apply -f _operator-deploy.yaml
shell:
- kubectl -n nuvolaris exec --stdin --tty {{.POD}} -- /bin/bash
1: task use N=1
2: task use N=2
3: task use N=3
4: task use N=4
5: task use N=5
6: task use N=6
7: task use N=7
8: task use N=8
9: task use N=9