---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ztpfw-ui
  name: ztpfw-ui
  namespace: $UI_NS
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: ztpfw-ui
  template:
    metadata:
      labels:
        app: ztpfw-ui
    spec:
      containers:
      - name: ztpfw-ui
        image: $UI_IMAGE
        imagePullPolicy: Always
        ports:
          - name: ui
            containerPort: 3000
            protocol: TCP
        volumeMounts:
          - name: certs-secret
            mountPath: "/app/certs"
            readOnly: true
        env:
          - name: BACKEND_PORT
            value: "3000"
          - name: FRONTEND_URL
            value: "$UI_APP_URL"
          - name: OAUTH2_CLIENT_ID
            value: "ztpfwoauth"
          - name: OAUTH2_REDIRECT_URL
            value: "$UI_APP_URL/login/callback"
          - name: OAUTH2_CLIENT_SECRET
            value: "ztpfwoauthsecret"
          - name: API_LOGGING_ENABLED
            value: "false" # or "true"
        livenessProbe:
          failureThreshold: 1
          httpGet:
            path: /livenessProbe
            port: ui
            scheme: HTTPS
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        readinessProbe:
          failureThreshold: 1
          httpGet:
            path: /readinessProbe
            port: ui
            scheme: HTTPS
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          requests:
            cpu: 3m
            memory: 40Mi
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext:
        runAsNonRoot: true
      terminationGracePeriodSeconds: 15
      volumes:
        - name: certs-secret
          secret:
            secretName: ztpfw-ui-tls
