apiVersion: apps/v1
kind: Deployment
metadata:
  name: socktop-webterm
  labels:
    app: socktop-webterm
spec:
  replicas: 3
  selector:
    matchLabels:
      app: socktop-webterm
  template:
    metadata:
      labels:
        app: socktop-webterm
    spec:
      # Use standard pod networking
      hostNetwork: false
      dnsPolicy: ClusterFirst

      containers:
        - name: webterm
          image: gt.wittyoneoff.com/jason/socktop-webterm:0.2.2
          imagePullPolicy: Always

          ports:
            - name: http
              containerPort: 8082
              protocol: TCP
            - name: agent
              containerPort: 3001
              protocol: TCP

          env:
            - name: TERM
              value: "xterm-256color"
            - name: TZ
              value: "America/New_York"
            - name: RUST_LOG
              value: "info"

          resources:
            limits:
              cpu: "2000m"
              memory: "1Gi"
            requests:
              cpu: "500m"
              memory: "256Mi"

          livenessProbe:
            httpGet:
              path: /
              port: 8082
            initialDelaySeconds: 10
            periodSeconds: 30
            timeoutSeconds: 5
            failureThreshold: 3

          readinessProbe:
            httpGet:
              path: /
              port: 8082
            initialDelaySeconds: 5
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 3

          volumeMounts:
            - name: config
              mountPath: /home/socktop/.config/socktop/profiles.json
              subPath: profiles.json
            - name: config
              mountPath: /home/socktop/.config/alacritty/alacritty.toml
              subPath: alacritty.toml
            - name: config
              mountPath: /home/socktop/.config/alacritty/catppuccin-frappe.toml
              subPath: catppuccin-frappe.toml
            - name: certs
              mountPath: /home/socktop/.config/socktop/certs
              readOnly: true

          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
                - ALL
            readOnlyRootFilesystem: false
            runAsNonRoot: false

      volumes:
        - name: config
          configMap:
            name: socktop-webterm-config
        - name: certs
          secret:
            secretName: socktop-webterm-certs
            optional: true

      restartPolicy: Always
