{{ if .Values.api_router.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-router
spec:
  replicas: 1
  selector:
    matchLabels:
      app: api-router
  template:
    metadata:
      name: api-router
      labels:
        app: api-router
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: api-router
        image: docker.io/goalprofit/api-router:{{.Values.api_router.version}}
        imagePullPolicy: Always
        volumeMounts:
        - mountPath: /data
          name: customer
          subPath: data/api-router
        ports:
          - containerPort: 8080
          - containerPort: 9090
          - containerPort: 8088
      imagePullSecrets:
      - name: regcred
        
      volumes:
      - name: customer
        {{ include "app.customer_volume" . | nindent 8}}
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: api-router
spec:
  type: ClusterIP
  selector:
    app: api-router
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
    - name: metrics
      protocol: TCP
      port: 9090
      targetPort: 9090
    - name: health
      protocol: TCP
      port: 8088
      targetPort: 8088
{{ end }}