{{ if .Values.server_api.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: server-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: server-api
  template:
    metadata:
      name: server-api
      labels:
        app: server-api
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: server-api
        image: docker.io/goalprofit/server-api:{{.Values.server_api.version}}
        imagePullPolicy: Always
        volumeMounts:
        - mountPath: /data
          name: customer
          subPath: data/server-api
        env:
          - name: SERVICE_LOGIN
            valueFrom:
              secretKeyRef:
                name: secret-admin
                key: username
                optional: false
          - name: SERVICE_PASSWORD
            valueFrom:
              secretKeyRef:
                name: secret-admin
                key: password
                optional: false
          - name: QUERY_CORES
            value: "{{.Values.server_api.query_cores}}"
          - name: QUERY_TIME_LOGGING
            value: "{{.Values.server_api.query_time_logging}}"
          - name: QUERY_LOGGING
            value: "{{.Values.server_api.query_logging}}"
      imagePullSecrets:
      - name: regcred
        
      volumes:
      - name: customer
        {{ include "app.customer_volume" . | nindent 8}}
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: server-api
spec:
  type: ClusterIP
  selector:
    app: server-api
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
{{ end }}