-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathTaskfile.yml
More file actions
523 lines (462 loc) · 13.5 KB
/
Copy pathTaskfile.yml
File metadata and controls
523 lines (462 loc) · 13.5 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
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# 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:
# fixed to 0.1.0-incubating - overridable with MY_BASETAG env var
sh: echo "${MY_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:
desc: alias for "use" (show/select the current kubernetes cluster)
cmds:
- task: use
setup:
desc: setup the local development environment (deps, ssh key, env config, poetry)
deps:
- update-files-from-openwhisk
- ssh-key
- configure-env
cmds:
- mkdir -p ~/.kube ; touch ~/.kube/config
- poetry install
status:
- test -e $GOBIN/kopf
env:
desc: print the current environment variables
cmds:
- env
watch:
desc: watch nodes, pods, services, pvcs and ingresses in the namespace
cmds:
- watch kubectl -n {{.NS}} get nodes,pod,svc,pvc,ingress
watch-osh:
desc: watch nodes, pods, services, pvcs and routes (OpenShift) in the namespace
cmds:
- watch kubectl -n {{.NS}} get nodes,pod,svc,pvc,route
watch-cert:
desc: watch cert-manager resources (ingress, issuers, certificates, orders, challenges)
cmds:
- watch kubectl -n {{.NS}} get ingress,ClusterIssuers,Certificates,CertificateRequests,Orders,Challenges
watch-pod:
desc: watch pods and jobs in the namespace
cmds:
- watch kubectl -n {{.NS}} get po,job --no-headers
logs:
desc: tail the operator logs to nuvolaris-operator.log
cmds:
- >
rm -f nuvolaris-operator.log ;
kubectl -n nuvolaris logs pod/nuvolaris-operator -f | tee nuvolaris-operator.log
cli:
desc: run the interactive development CLI
cmds:
- task: d:cli
run:
desc: prepare system actions, apply permissions and run the operator locally
cmds:
- task: sys:prepare
- task: t:permission
- task: d:run
irun:
desc: deploy an instance and run the operator locally
cmds:
- task: instance
- task: d:run
permission:
desc: apply the nuvolaris permissions
cmds:
- task: t:permission
operator:
desc: deploy the operator
cmds:
- task: t:operator
instance:
desc: deploy an openwhisk instance
cmds:
- task: t:instance
instance-wfx:
desc: deploy an openwhisk instance with workflow extension
cmds:
- task: d:instance-wfx
instance-and-log:
desc: deploy an instance and follow the operator logs
cmds:
- task: d:instance
- kubectl -n nuvolaris logs pod/nuvolaris-operator -f
mongo:
desc: run the mongo integration test
cmds:
- task: t:mongo
minio:
desc: run the minio integration test
cmds:
- task: t:minio
postgres:
desc: run the postgres integration test
cmds:
- task: t:postgres
minimal:
desc: deploy operator and a minimal instance, then run hello test
cmds:
#- task: permission
- task: operator
- task instance WHISK=minimal
- task: config
- task: hello
all:
desc: full end-to-end setup and test of all services
cmds:
- task: permission
- task: operator
- task: instance
- task: config
- task: hello
- task: redis
- task: mongo
- task: minio
- task: postgres
config:
desc: configure ops wsk properties for the deployed instance
cmds:
- task: t:config
hello:
desc: run the hello world test action
cmds:
- task: t:hello
redis:
desc: run the redis integration test
cmds:
- task: t:redis
workflow:
desc: apply the workflow test manifest
cmds:
- kubectl -n nuvolaris apply -f tests/workflow-test.yaml
defin:
desc: remove finalizers to force-delete the wsk controller resource
cmds:
- task: d:defin
# old., to be removed
image-tag:
desc: "[deprecated] generate and force a new git tag based on the current time"
cmds:
- git tag -d $(git tag)
- git tag -f {{.P}}{{.BASETAG}}.$(date +%y%m%d%H%M)
- env PAGER= git tag
# configure env
configure-env:
desc: check that .env exists (copy from .env.dist if missing)
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:
desc: update configuration files copied from the openwhisk source repo
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:
desc: generate an ssh key pair for cluster access if missing
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:
desc: delete all deployed resources in the nuvolaris namespace
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:
desc: run python doctests for nuvolaris modules (T=filter)
cmds:
- |
for test in nuvolaris/{{.T}}*.py
do echo "*** [{{.KUBE}}] $test"
poetry run python3 -m doctest $test {{.CLI_ARGS}}
done
silent: true
iclean:
desc: remove generated kustomization and generated deploy files
cmds:
- rm -f deploy/*/kustomization.yaml deploy/*/__* deploy/*/*_generated.yaml
itest:
desc: run ipython integration tests against the current kube (T=filter)
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:
desc: deploy permissions, operator and instance, then run the actions tests
cmds:
- task: permission
- task: operator
- task: instance
- task: actions
actions:
desc: run config, hello, redis and echo action tests
cmds:
- task: t:config
- task: t:hello
- task: t:redis
- task: t:echo
test:
desc: run the full test suite (clean, unit, integration, deploy tests)
cmds:
- task: clean
- task: utest
- task: itest
- task: dtest
debug:
desc: set up an ipython debug profile and run the ui integration test
cmds:
- poetry run ipython profile create
- cp test_profile.ipy ~/.ipython/profile_default/startup/
- task: uitest
all-kubes:
desc: run a task against every configured kube (usage - task all-kubes -- <target>)
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:
desc: run dtest quietly, discarding all output
cmds:
- task dtest 2>/dev/null >/dev/null
use:
desc: "list available kubeconfigs, or switch to the one matching N"
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:
desc: build the operator image and load it into the local kind cluster
cmds:
- task: b:build-and-load
build-and-push:
desc: build the operator image and push it to the registry
cmds:
- task: b:build-and-push
buildx-and-push:
desc: build the operator image (multi-arch) and push it to the registry
cmds:
- task: b:buildx-and-push
docker-login:
desc: log in to the docker registry
cmds:
- 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:
desc: open an interactive shell in the given pod (POD=name)
cmds:
- kubectl -n nuvolaris exec --stdin --tty {{.POD}} -- /bin/bash
1:
cmds:
- task use N=1
2:
cmds:
- task use N=2
3:
cmds:
- task use N=3
4:
cmds:
- task use N=4
5:
cmds:
- task use N=5
6:
cmds:
- task use N=6
7:
cmds:
- task use N=7
8:
cmds:
- task use N=8
9:
cmds:
- task use N=9