blob: 16d412ea4d9cb7ef8f4827f52293fea842b28f78 [file] [log] [blame]
# 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