apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
  labels:
    app: assets
  name: assets
  namespace: {{ .Release.Namespace }}
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: assets
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "false"
      creationTimestamp: null
      labels:
        app: assets
    spec:
      containers:
      - image: "{{ .Values.image.registry }}/assets:{{ .Values.image.tag }}"
        imagePullPolicy: IfNotPresent
        name: assets
        resources:
          requests:
            memory: "200Mi"
            cpu: "200m"
          limits:
            memory: "1000Mi"
            cpu: "500m"
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        env:
        - name: DATABASE_URL
          valueFrom:
            secretKeyRef:
              name: assets
              key: DATABASE_URL
        - name: POSTGRES_USER
          valueFrom:
            secretKeyRef:
              name: assets
              key: POSTGRES_USER
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: assets
              key: POSTGRES_PASSWORD
        - name: STORAGE_PROVIDER
          value: "minio"
        - name: S3_ENDPOINT
          value: "minio:80"
        - name: S3_SECURE
          value: "false"
        - name: S3_ACCESS_KEY
          valueFrom:
            secretKeyRef:
              name: assets
              key: S3_ACCESS_KEY
        - name: S3_SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: assets
              key: S3_SECRET_KEY
        - name: SERVICE_CONVERT_TXT
          value: "http://convert/text/import"
        - name: SERVICE_CONVERT_PDF
          value: "http://convert/pdf/import"
        - name: JWT_SECRET
          valueFrom:
            secretKeyRef:
              name: assets
              key: JWT_SECRET
        command: ["/bin/sh"]
        args: ["-c", "alembic upgrade afa33cc83d57 && alembic upgrade fe5926249504 && alembic upgrade 0f6c859c1d1c && alembic upgrade head && uvicorn assets.main:app --host 0.0.0.0 --port 8080 --root-path /api/v1/assets"]
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
