Skip to content
Open
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
3 changes: 2 additions & 1 deletion opsroot.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"pgvector": "docker.io/pgvector/pgvector:pg16",
"kubegres": "docker.io/reactivetechio/kubegres:1.18",
"ferretdb": "ghcr.io/nuvolaris/ferretdb:1.6.0",
"rbacproxy": "registry.k8s.io/kubebuilder/kube-rbac-proxy:v0.14.1"
"rbacproxy": "registry.k8s.io/kubebuilder/kube-rbac-proxy:v0.14.1",
"tika": "docker.io/apache/tika:3.2.3.0-full"
}
}
}
15 changes: 10 additions & 5 deletions setup/nuvolaris/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,6 @@ tasks:
delete:
desc: no-op delete command

streamer:
desc: manage the streamer deployment

system-api:
desc: manage the system api deployment

add-user:
silent: true
Expand Down Expand Up @@ -305,3 +300,13 @@ tasks:
- echo "Login with:" ops ide login {{.USR}} "$APIHOST"
- echo "Password is saved in:" ~/.ops/{{.USR}}.password
- echo "Web URL is:" "$HOST"


streamer:
desc: manage the streamer deployment

system-api:
desc: manage the system api deployment

tika:
desc: manage the tika api deployment
2 changes: 2 additions & 0 deletions setup/nuvolaris/streamer/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ tasks:
- "{{.DRY}} kubectl -n nuvolaris apply -f _streamer.yaml"
#- cat _ingress.yaml
- "{{.DRY}} kubectl -n nuvolaris apply -f _ingress.yaml"
- ops util wait po/nuvolaris-streamer-api-0
- |
echo "Streamer API deployed with HOSTNAME: stream.${STREAMER_API_HOSTNAME} and OW_APIHOST: ${OW_APIHOST}"

Expand All @@ -81,6 +82,7 @@ tasks:
ignore_error: true
cmds:
- kubectl -n nuvolaris delete sts/nuvolaris-streamer-api ing/nuvolaris-streamer-api-ingress
- ops util wait po/nuvolaris-streamer-api-0 delete
- |
echo "Streamer API undeployed"

Expand Down
2 changes: 2 additions & 0 deletions setup/nuvolaris/system-api/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ tasks:
- kubectl -n nuvolaris apply -f "$OPS_ROOT/setup/nuvolaris/system-api/_ingress.yaml"
- task: install-toml
- task: install-secret
- ops util wait po/nuvolaris-system-api-0
- |
echo "Admin API deployed with HOSTNAME: ${SYS_API_HOSTNAME}/system"

Expand All @@ -115,6 +116,7 @@ tasks:
- task: remove-secret
- task: remove-toml
- kubectl -n nuvolaris delete sts/nuvolaris-system-api ing/nuvolaris-system-api-ingress svc/nuvolaris-system-api
- ops util wait po/nuvolaris-system-api-0 delete
- |
echo "System Admin API undeployed"

Expand Down
59 changes: 59 additions & 0 deletions setup/nuvolaris/tika/opsfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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:
VAR: ""
MSG: ""
VAL: ""
RETRY: 100
TIMEOUT: 15s
CONTEXT: ""
DRY: ""

env:
KUBECONFIG:
sh: |-
if test -e "$OPS_TMP/kubeconfig"
then echo "$OPS_TMP/kubeconfig"
else echo ~/.kube/config
fi

tasks:

deploy:
silent: true
desc: deploy tika
cmds:
- envsubst -i tika.yaml -o _tika.yaml
- kubectl -n nuvolaris apply -f _tika.yaml
- ops util wait po/tika-0
- |
echo "Tika deployed"

undeploy:
silent: true
desc: undeploy tika
ignore_error: true
cmds:
- kubectl -n nuvolaris delete sts/tika svc/tika cm/tika-config
- ops util wait po/tika-0 delete
- |
echo "Tika undeployed"



112 changes: 112 additions & 0 deletions setup/nuvolaris/tika/tika.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: tika-config
namespace: nuvolaris
data:
JAVA_OPTS: "-Xms256m -Xmx1g -Djava.awt.headless=true"
tika-config.xml: |
<properties>
<ocr>
<tesseractPath>/usr/bin/tesseract</tesseractPath>
<applyOcr>true</applyOcr>
<ocrStrategy>ocr_only</ocrStrategy>
<!-- o "ocr_and_text_extraction" se vuoi unire OCR e testo digitale -->
</ocr>
</properties>

---
# StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: tika
namespace: nuvolaris
labels:
app: tika
spec:
serviceName: tika
replicas: 1
selector:
matchLabels:
app: tika
updateStrategy:
type: RollingUpdate
template:
metadata:
labels:
app: tika
spec:
containers:
- name: tika
image: ${IMAGES_TIKA}
imagePullPolicy: IfNotPresent
#args:
# - "-config"
#s - "/tika-config/tika-config.xml"
ports:
- containerPort: 9998
name: http
env:
- name: JAVA_OPTS
valueFrom:
configMapKeyRef:
name: tika-config
key: JAVA_OPTS
readinessProbe:
tcpSocket:
port: 9998
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 6
livenessProbe:
tcpSocket:
port: 9998
initialDelaySeconds: 30
periodSeconds: 20
failureThreshold: 3
resources:
requests:
cpu: "250m"
memory: "512Mi"
limits:
cpu: "1000m"
memory: "2Gi"
volumeMounts:
- name: tika-config
mountPath: /tika-config
- name: tika-data
mountPath: /data
volumes:
- name: tika-config
configMap:
name: tika-config
volumeClaimTemplates:
- metadata:
name: tika-data
labels:
app: tika
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi

---
# Service
apiVersion: v1
kind: Service
metadata:
name: tika
namespace: nuvolaris
labels:
app: tika
spec:
type: ClusterIP
selector:
app: tika
ports:
- port: 9998
targetPort: 9998
protocol: TCP
name: http
4 changes: 4 additions & 0 deletions util/docopts.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Usage:
util edit [<plugin>]
util link-plugin <plugin>
util stdtext <text>
util wait <object> [<cond>] [<retry>]
util wait-pod <file> <selector> [<cond>] [<retry>]
```

## Commands
Expand Down Expand Up @@ -73,6 +75,8 @@ Usage:
- edit edit (with vscode) the current tasks or a plugin
- link-plugin link the <plugin> in current directory to the global list
- stdtext standardize the text to the text convetions of the underlying platform (windows/unix)
- wait wait for an object to be ready
- wait-pod wait for a pod to be ready and save its name in a file
```

## Options
Expand Down
69 changes: 69 additions & 0 deletions util/opsfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ vars:
else
echo $AUTH
fi
TIMEOUT: 10s
# unused
#USERNAME:
# sh: |
Expand Down Expand Up @@ -313,3 +314,71 @@ tasks:
cmds:
- bun stdtext.js {{OS}} "{{._text_}}"


wait:
desc: wait for an object to reach a condition
silent: true
vars:
COND: '{{or ._cond_ "true"}}'
RETRY: '{{or ._retry_ "100"}}'
OBJECT: "{{._object_}}"
status:
- test "{{.COND}}" != "true"
env:
BAR:
sh: printf "%*s" {{.RETRY}} "" | tr ' ' '#'
cmds:
- test -n "{{.OBJECT}}" || die "use OBJECT=<to-wait-for>"
- |
N=0
RES=false
while [[ $N -lt {{.RETRY}} ]]
do printf "\rwaiting for {{.OBJECT}} available: [${BAR:0:$((N++))}]"
if kubectl -n nuvolaris get "{{.OBJECT}}" >/dev/null 2>&1
then RES=true ; break
fi
sleep {{.TIMEOUT}}
done
printf "\n"
$RES
- |
N=0
RES=false
while [[ $N -lt {{.RETRY}} ]]
do
printf "\rwaiting for {{.OBJECT}} ready: [${BAR:0:$((N++))}]"
if kubectl -n nuvolaris wait --for=condition=Ready "{{.OBJECT}}" --timeout={{.TIMEOUT}} >/dev/null 2>&1
then RES=true ; break
fi
done
printf "\n"
$RES

wait-pod:
desc: wait for a pod to be available - leave the result in FILE
silent: true
vars:
COND: '{{or ._cond_ "true"}}'
RETRY: '{{or ._retry_ "100"}}'
SELECTOR: "{{._selector_}}"
FILE: "{{._file_}}"
status:
- test "{{.COND}}" != "true"
env:
BAR:
sh: printf "%*s" {{.RETRY}} "" | tr ' ' '#'
cmds:
- |
cd "$OPS_PWD"
N=0
RES=false
while [[ $N -lt {{.RETRY}} ]]
do printf "\rwaiting for pod {{.SELECTOR}}: [${BAR:0:$((N++))}]"
if kubectl -n nuvolaris get po -l {{.SELECTOR}} -o jsonpath='{.items[0].metadata.name}' >{{.FILE}} 2>/dev/null
then RES=true ; break
fi
sleep {{.TIMEOUT}}
done
printf "\n"
$RES