Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 16 additions & 42 deletions setup/docker/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ tasks:
- envsubst -i kind.yaml -o _kind.yaml
- >
kind create cluster
--kubeconfig="$OPS_TMP/kubeconfig"
--wait=1m --name=nuvolaris
--wait=2m --name=nuvolaris
--config=_kind.yaml
- |
docker exec nuvolaris-control-plane mkdir -p /etc/containerd/certs.d/127.0.0.1:32000
Expand All @@ -79,12 +78,16 @@ tasks:
skip_verify = true
EOF'
docker exec nuvolaris-control-plane systemctl restart containerd
kind export kubeconfig -n nuvolaris --kubeconfig "$OPS_TMP/kubeconfig"
echo "waiting for kind ready..."
retry -t 100 -m 600 test -e $OPS_TMP/kubeconfig
retry kubectl --kubeconfig $OPS_TMP/kubeconfig cluster-info

ingress:
silent: true
cmds:
- >
kubectl --kubeconfig="$OPS_TMP/kubeconfig"
retry kubectl --kubeconfig="$OPS_TMP/kubeconfig"
apply -f ingress-deploy.yaml

check-space:
Expand All @@ -93,38 +96,6 @@ tasks:
cmds:
- uv run space.py

preload:
silent: true
desc: preload the Apache OpenServerless images in docker to speed up the cluster creation
ignore_errors: true
status:
- config SKIP_PRELOAD_IMAGES
cmds:
- |
for image in "$IMAGES_STREAMER" "$IMAGES_OPERATOR" "$IMAGES_CONTROLLER"
do
docker pull "$image" --platform "linux/{{ARCH}}"
if ! kind load docker-image "$image" --name {{.CLUSTER}}
then
echo "*** Cannot preload images. You can disable preload with ops -config SKIP_PRELOAD_IMAGES=1"
echo "*** Workaround on Docker Desktop: disable 'Use containerd for pulling and storing images' on General"
echo "*** WARNING! If you skip preload, it can take a lot of time before the system starts. Be patient."
exit 1
fi
docker rmi "$image"
done
- |
jq -r '.runtimes[][]
| select(.default == true)
| .image
| "\(.prefix)/\(.name):\(.tag)"' <$OPS_ROOT/runtimes.json \
| rg apache/openserverless-runtime \
| while read -r image; do
docker pull "$image" --platform "linux/{{ARCH}}"
kind load docker-image "$image" --name "{{.CLUSTER}}"
docker rmi "$image"
done

clean-all:
silent: true
desc: remove all images and containers from docker
Expand All @@ -141,13 +112,16 @@ tasks:
silent: true
desc: create the Apache OpenServerless cluster in Docker
cmds:
- ops util freeze docker-load
- task: cluster
- ops util freeze kind-load
- task: ingress
- cp "$OPS_TMP/kubeconfig" "$OPS_TMP/kind-{{.CLUSTER}}.kubeconfig"
status:
- kind get clusters | rg {{.CLUSTER}}
- |
if kind get clusters | rg {{.CLUSTER}}
then kind export kubeconfig --name {{.CLUSTER}} --kubeconfig "$OPS_TMP/kubeconfig"
else
ops util freeze docker-load
ops setup docker cluster
ops util freeze kind-load
ops setup docker ingress
fi
- cp "$OPS_TMP/kubeconfig" "$OPS_TMP/kind-{{.CLUSTER}}.kubeconfig"

delete:
silent: true
Expand Down
4 changes: 0 additions & 4 deletions setup/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ tasks:
task check-ports PORTS="{{ .PORTS }}"
fi
{{.RUN}} ops setup docker create
if test -z {{.__skip_preload_images}}
then
{{.RUN}} ops setup docker preload
fi
{{.RUN}} ops setup kubernetes create
{{.RUN}} ops setup nuvolaris login
config STATUS_LAST=devcluster
Expand Down
2 changes: 0 additions & 2 deletions util/docopts.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Usage:
util ingress-type
util edit [<plugin>]
util link-plugin <plugin>
util docker-proxy [<port>] [<host>] [--remove]
```

## Commands
Expand All @@ -70,7 +69,6 @@ Usage:
- ingress-type return the ingress type
- edit edit (with vscode) the current tasks or a plugin
- link-plugin link the <plugin> in current directory to the global list
- docker-proxy launch (or remove) in docker a proxy listening in public <port> (default 8080) to the <host> (default devel.miniops.me)
```

## Options
Expand Down
18 changes: 8 additions & 10 deletions util/freeze/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ vars:
sh: >
awk '/image:/{print $2}' $OPS_ROOT/setup/docker/kind.yaml | tee _docker.lst


tasks:

docker-list:
Expand Down Expand Up @@ -46,7 +45,7 @@ tasks:
if test -e "$file"
then echo "already saved $img.{{ARCH}} "
else echo ">>> Saving: $img"
if docker pull "$img"
if docker pull --platform linux/{{ARCH}} "$img"
then echo "OK: save $file"
else echo "*** FAIL: pull $img"
fi
Expand All @@ -58,7 +57,7 @@ tasks:
done

kind-save:
silent: false
silent: true
desc: list images in kindes
env:
CLU: "{{.KIND_CLUSTER}}"
Expand All @@ -75,8 +74,8 @@ tasks:
file={{.IMAGES}}/kind/"$(base64 -e "$img")"
if test -e "$file"
then echo "already saved $img"
else echo ">>> Saving: $img"
if ! docker pull "$img"
else echo ">>> Saving: {{ARCH}} $img"
if ! docker pull --platform linux/{{ARCH}} "$img"
then echo "*** FAIL pull $img" ; continue
fi
if ! docker save "$img" -o "$file"
Expand Down Expand Up @@ -140,16 +139,15 @@ tasks:
desc: load disk images in kind
cmds:
- |
N=0
for file in {{.IMAGES}}/kind/*
do
N=$(($N+1))
printf "\rKind: loading images: [$(seq 1 $N | awk '{printf "#"}')]"
#echo $file
b64="$(basename "$file")"
img="$(base64 -d "${b64#*-}")"
kind load image-archive "$file" -n {{.CLUSTER}} --nodes {{.CLUSTER}}-control-plane
echo "Kind: loading $img"
docker exec -i {{.CLUSTER}}-control-plane ctr --namespace=k8s.io images import --snapshotter=overlayfs - < "$file"
done
echo 'Images loaded:'
- task: kind-list
status:
- test -z "$(ls {{.IMAGES}}/kind/* 2>/dev/null)"

Expand Down
18 changes: 9 additions & 9 deletions util/kube/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ env:
tasks:

waitfor:
desc: wait for an object matching a condition
desc: wait for an object matching a condition
silent: true
cmds:
- test -n "{{.OBJ}}" || die "use OBJ=<pod/pod-name>"
Expand All @@ -42,14 +42,14 @@ tasks:
N=0
RES=false
while [[ $N -lt {{.RETRY}} ]]
do
do
if kubectl -n nuvolaris wait --for="{{.FOR}}" "{{.OBJ}}" --timeout="{{.TIMEOUT}}s"
then RES=true; break
then RES=true; break
else echo "$((N++)) Waiting {{.OBJ}} for {{.FOR}}"
sleep "{{.SLEEP}}s"
fi
done
$RES
$RES

wait:
desc: wait for a value matching the given jsonpath on the specific resources under the namespace nuvolaris
Expand All @@ -61,17 +61,17 @@ tasks:
N=0
RES=false
while [[ $N -lt {{.RETRY}} ]]
do
do
MATCHING_VALUE="$(kubectl -n nuvolaris get {{.OBJECT}} -o jsonpath='{{.JSONPATH}}')"
if [[ -z "$MATCHING_VALUE" ]]
then
then
echo "$((N++)) Waiting for {{.JSONPATH}} to be non empty value"
sleep 5
else
else
RES=true; break
fi
done
$RES
$RES

export:
desc: exporting NAMEd kubeconfig to specified FILE
Expand All @@ -80,7 +80,7 @@ tasks:
- test -e "$OPS_TMP/{{.NAME}}.kubeconfig" || die "no {{.NAME}} kubeconfig"
- |
FILE="$(realpath {{.FILE}})"
cp "$OPS_TMP/kubeconfig" "$FILE"
cp "$OPS_TMP/kubeconfig" "$FILE"

import:
desc: importing FILE to the NAMEd kubeconfig
Expand Down
27 changes: 0 additions & 27 deletions util/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,33 +279,6 @@ tasks:
exit 1
fi

docker-proxy:
desc: create in docker a proxy to expose miniops.me (or others)
silent: true
vars:
PORT: '{{or ._port_ "8080"}}'
HOST: '{{or ._host_ "devel.miniops.me"}}'
NGINX_CONF: >
server {
listen 80;
location / {
proxy_pass http://nuvolaris-control-plane:80;
proxy_set_header Host {{.HOST}};
}
}
cmds:
- |
if {{.__remove}}
then docker rm docker-proxy-{{.PORT}} -f
else
if docker run -d --name docker-proxy-{{.PORT}} -p {{.PORT}}:80 --network kind nginx:alpine sh -c \
"echo '{{.NGINX_CONF}}' > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
then echo "docker-proxy started on port {{.PORT}} to http://{{.HOST}}"
else echo "Cannot start docker-proxy-{{.PORT}} - either the port is busy or another instance is running, remove it"
fi
fi


freeze:
desc: freeze util