kind: Deployment
apiVersion: apps/v1
metadata:
  name: immich-server
  namespace: immich
  labels:
    app: immich-server
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: immich-server
  template:
    metadata:
      labels:
        app: immich-server
      annotations:
        k8s.v1.cni.cncf.io/networks: |
          [{
            "name": "multus-iot",
            "namespace": "default",
            "mac": "2e:f8:57:99:6e:31",
            "ips": ["192.168.1.192/24"]
          }]
    spec:
      securityContext:
        fsGroup: 100
        fsGroupChangePolicy: OnRootMismatch
      serviceAccountName: default
      dnsPolicy: ClusterFirst
      initContainers:
        - name: postgresql-isready
          image: "docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0"
          imagePullPolicy: Always
          env:
            - name: POSTGRES_USER
              valueFrom:
                configMapKeyRef:
                  name: immich-env
                  key: DB_USERNAME
            - name: POSTGRES_DB
              valueFrom:
                configMapKeyRef:
                  name: immich-env
                  key: DB_DATABASE_NAME
          command:
            - /bin/sh
            - -c
            - until pg_isready -U "${POSTGRES_USER}" -d "dbname=${POSTGRES_DB}"
              -h immich-database -p 5432 ; do sleep 2 ; done
          resources:
            limits:
              cpu: "100m"
              memory: "128Mi"
            requests:
              cpu: "50m"
              memory: "64Mi"
      containers:
        - name: immich-server
          image: "ghcr.io/immich-app/immich-server:release"
          imagePullPolicy: Always
          securityContext:
            runAsUser: 1001
            runAsGroup: 100
          ports:
            - containerPort: 3001
          env:
            - name: DB_PASSWORD
              valueFrom:
                configMapKeyRef:
                  name: immich-env
                  key: DB_PASSWORD
          envFrom:
            - configMapRef:
                name: immich-env
                optional: false
          livenessProbe:
            failureThreshold: 120
            httpGet:
              path: /server/ping
              port: 2283
            initialDelaySeconds: 10
            periodSeconds: 120
            timeoutSeconds: 1
          readinessProbe:
            failureThreshold: 120
            httpGet:
              path: /server/ping
              port: 2283
            initialDelaySeconds: 10
            periodSeconds: 120
            timeoutSeconds: 1
          # resources:
          #   limits:
          #     cpu: "500m"
          #     memory: "512Mi"
          #   requests:
          #     cpu: "250m"
          #     memory: "256Mi"
          volumeMounts:
            - name: library
              mountPath: /usr/src/app/upload
              subPath: library
            - name: ext-library
              mountPath: /photos
          # securityContext:
#            runAsUser: 1001
#            runAsGroup: 1000
#            fsGroup: 2000
      volumes:
        - name: library
          persistentVolumeClaim:
            claimName: immich-library-pvc
        - name: ext-library
          persistentVolumeClaim:
            claimName: immich-photos-pvc
