diff --git a/opsroot.json b/opsroot.json index 75449381..6220ec7f 100644 --- a/opsroot.json +++ b/opsroot.json @@ -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" } } } diff --git a/setup/nuvolaris/opsfile.yml b/setup/nuvolaris/opsfile.yml index de44edb2..f18a0b91 100644 --- a/setup/nuvolaris/opsfile.yml +++ b/setup/nuvolaris/opsfile.yml @@ -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 @@ -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 diff --git a/setup/nuvolaris/streamer/opsfile.yml b/setup/nuvolaris/streamer/opsfile.yml index 9a0b6661..fa7429df 100644 --- a/setup/nuvolaris/streamer/opsfile.yml +++ b/setup/nuvolaris/streamer/opsfile.yml @@ -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}" @@ -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" diff --git a/setup/nuvolaris/system-api/opsfile.yml b/setup/nuvolaris/system-api/opsfile.yml index f5e1767b..8dff09bb 100644 --- a/setup/nuvolaris/system-api/opsfile.yml +++ b/setup/nuvolaris/system-api/opsfile.yml @@ -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" @@ -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" diff --git a/setup/nuvolaris/tika/opsfile.yml b/setup/nuvolaris/tika/opsfile.yml new file mode 100644 index 00000000..af97d06d --- /dev/null +++ b/setup/nuvolaris/tika/opsfile.yml @@ -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" + + + diff --git a/setup/nuvolaris/tika/tika.yaml b/setup/nuvolaris/tika/tika.yaml new file mode 100644 index 00000000..48c2cd64 --- /dev/null +++ b/setup/nuvolaris/tika/tika.yaml @@ -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: | + + + /usr/bin/tesseract + true + ocr_only + + + + +--- +# 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 diff --git a/util/docopts.md b/util/docopts.md index 1a928307..652ba34f 100644 --- a/util/docopts.md +++ b/util/docopts.md @@ -46,6 +46,8 @@ Usage: util edit [] util link-plugin util stdtext + util wait [] [] + util wait-pod [] [] ``` ## Commands @@ -73,6 +75,8 @@ Usage: - edit edit (with vscode) the current tasks or a plugin - link-plugin link the 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 diff --git a/util/opsfile.yml b/util/opsfile.yml index d1d1018e..b5a0531c 100644 --- a/util/opsfile.yml +++ b/util/opsfile.yml @@ -39,6 +39,7 @@ vars: else echo $AUTH fi + TIMEOUT: 10s # unused #USERNAME: # sh: | @@ -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=" + - | + 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 +