{{ if .Values.assets_inlet.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: assets-inlet
spec:
  replicas: 1
  selector:
    matchLabels:
      app: assets-inlet
  template:
    metadata:
      name: assets-inlet
      labels:
        app: assets-inlet
    spec:
{{ if .Values.local_user_id }}
      securityContext:
        runAsUser: {{ .Values.local_user_id }}
{{ end }}
      terminationGracePeriodSeconds: 1
      containers:
      - name: assets-inlet
        image: docker.io/goalprofit/assets-inlet:{{.Values.assets_inlet.version}}
        imagePullPolicy: Always
        volumeMounts:
        - mountPath: /data
          name: customer
          subPath: data/assets-inlet
        env:
          - name: API_SERVICE
            value: http://server-api:8080
          - name: SERVICE_LOGIN
            valueFrom:
              secretKeyRef:
                name: secret-service
                key: username
                optional: false
          - name: SERVICE_PASSWORD
            valueFrom:
              secretKeyRef:
                name: secret-service
                key: password
                optional: false

          - name: AWS_ACCESS_KEY_ID
            valueFrom:
              secretKeyRef:
                name: aws
                key: key_id
                optional: false
          - name: AWS_SECRET_ACCESS_KEY
            valueFrom:
              secretKeyRef:
                name: aws
                key: access_key
                optional: false
          - name: AWS_REGION
            valueFrom:
              secretKeyRef:
                name: aws
                key: region
                optional: false
          - name: AWS_BUCKET_NAME
            valueFrom:
              secretKeyRef:
                name: aws
                key: bucket_name
                optional: false
          - name: AWS_CLOUDFRONT_URL
            valueFrom:
              secretKeyRef:
                name: aws
                key: cloudfront_url
                optional: false
          - name: GQL_DIST_DOMAIN_NAME
            value: "{{.Values.assets_inlet.gql_dist_domain_name}}"
          - name: GQL_DIST_ENTITY_NAME
            value: "{{.Values.assets_inlet.gql_dist_entity_name}}"
      imagePullSecrets:
      - name: regcred

      volumes:
      - name: customer
        {{ include "app.customer_volume" . | nindent 8}}
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: assets-inlet
spec:
  type: ClusterIP
  selector:
    app: assets-inlet
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
{{ end }}