---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tika-ui
  namespace: web
  labels:
    name: tika-ui
    app: ui
spec:
  replicas: 1
  revisionHistoryLimit: 1
  selector:
    matchLabels:
      app: ui
  template:
    metadata:
      annotations:
        prometheus.io/scrape: 'true'
        filter.by.port.name: 'true'
      labels:
        app: ui
    spec:
      affinity:
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 90
              preference:
                matchExpressions:
                - key: kubernetes.io/arch
                  operator: In
                  values:
                  - amd64
            - weight: 10
              preference:
                matchExpressions:
                - key: kubernetes.io/arch
                  operator: In
                  values:
                  - arm64
      containers:
        - name: server
          image: ghcr.io/saidsef/tika-document-to-text:server-latest
          imagePullPolicy: Always
          ports:
          - name: tcp-server
            containerPort: 7071
            protocol: TCP
          - name: http-monitoring
            containerPort: 7072
            protocol: TCP
          resources:
            requests:
              cpu: 300m
              memory: 2Gi
            limits:
              cpu: 500m
              memory: 2Gi
          livenessProbe:
            tcpSocket:
              port: tcp-server
            initialDelaySeconds: 10
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          readinessProbe:
            tcpSocket:
              port: tcp-server
            initialDelaySeconds: 10
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 3
            timeoutSeconds: 5
          securityContext:
            allowPrivilegeEscalation: false
            # user/group: nobody
            runAsGroup: 65534
            runAsUser: 65534
            runAsNonRoot: true
            readOnlyRootFilesystem: false
            capabilities:
              drop:
                - ALL
              add:
                - NET_BIND_SERVICE
                - SYS_TIME
        - name: ui
          image: ghcr.io/saidsef/tika-document-to-text:ui-latest
          imagePullPolicy: Always
          env:
          - name: HOST
            value: "127.0.0.1"
          - name: HOST_PORT
            value: "7071"
          ports:
            - name: http-ui
              containerPort: 8080
              protocol: TCP
          resources:
            requests:
              cpu: 50m
              memory: 512Mi
            limits:
              cpu: 100m
              memory: 1Gi
          livenessProbe:
            tcpSocket:
              port: http-ui
            initialDelaySeconds: 5
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 2
            timeoutSeconds: 3
          readinessProbe:
            httpGet:
              port: http-ui
              path: /healthz
              scheme: "HTTP"
            initialDelaySeconds: 5
            periodSeconds: 5
            successThreshold: 1
            failureThreshold: 2
            timeoutSeconds: 3
          securityContext:
            allowPrivilegeEscalation: false
            # user/group: nobody
            runAsGroup: 65534
            runAsUser: 65534
            runAsNonRoot: true
            readOnlyRootFilesystem: false
            capabilities:
              drop:
                - ALL
              add:
                - NET_BIND_SERVICE
                - SYS_TIME
