apiVersion: apps/v1
kind: Deployment
metadata:
  name: mdtodo
  namespace: unidesk
  labels:
    app.kubernetes.io/name: mdtodo
    app.kubernetes.io/part-of: unidesk
    unidesk.ai/deployment-mode: k3sctl-managed
    unidesk.ai/instance-id: D601
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: mdtodo
      unidesk.ai/instance-id: D601
  template:
    metadata:
      labels:
        app.kubernetes.io/name: mdtodo
        app.kubernetes.io/part-of: unidesk
        unidesk.ai/deployment-mode: k3sctl-managed
        unidesk.ai/instance-id: D601
        unidesk.ai/node-id: D601
    spec:
      nodeSelector:
        unidesk.ai/node-id: D601
      terminationGracePeriodSeconds: 15
      containers:
        - name: mdtodo
          image: unidesk-mdtodo:d601
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 4267
          env:
            - name: HOST
              value: "0.0.0.0"
            - name: PORT
              value: "4267"
            - name: MDTODO_ROOT_DIR
              value: "/workspace"
            - name: LOG_FILE
              value: "/var/log/unidesk/mdtodo.jsonl"
            - name: UNIDESK_DEPLOY_SERVICE_ID
              value: "mdtodo"
            - name: UNIDESK_DEPLOY_REPO
              value: "https://github.com/pikasTech/unidesk"
            - name: UNIDESK_DEPLOY_COMMIT
              value: "replace-with-deploy-env-commit"
            - name: UNIDESK_DEPLOY_REQUESTED_COMMIT
              value: "replace-with-deploy-env-commit"
            - name: UNIDESK_LOG_RETENTION_BYTES
              value: "512MiB"
          volumeMounts:
            - name: workspace
              mountPath: /workspace
            - name: logs
              mountPath: /var/log/unidesk
          readinessProbe:
            httpGet:
              path: /health
              port: http
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 12
          livenessProbe:
            httpGet:
              path: /live
              port: http
            periodSeconds: 10
            timeoutSeconds: 3
            failureThreshold: 6
          startupProbe:
            httpGet:
              path: /live
              port: http
            periodSeconds: 5
            timeoutSeconds: 3
            failureThreshold: 30
          resources:
            requests:
              cpu: 50m
              memory: 96Mi
            limits:
              memory: 512Mi
      volumes:
        - name: workspace
          hostPath:
            path: /home/ubuntu/cq-deploy/.state/mdtodo-workspace
            type: Directory
        - name: logs
          hostPath:
            path: /home/ubuntu/cq-deploy/.state/mdtodo/logs
            type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
  name: mdtodo
  namespace: unidesk
  labels:
    app.kubernetes.io/name: mdtodo
    app.kubernetes.io/part-of: unidesk
    unidesk.ai/deployment-mode: k3sctl-managed
spec:
  type: ClusterIP
  selector:
    app.kubernetes.io/name: mdtodo
    unidesk.ai/instance-id: D601
  ports:
    - name: http
      port: 4267
      targetPort: http
