{{ if .Values.pimsync.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pimsync
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pimsync
  template:
    metadata:
      name: pimsync
      labels:
        app: pimsync
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: pimsync
        image: docker.io/goalprofit/pimsync:{{.Values.pimsync.version}}
        imagePullPolicy: Always
        env:
        - name: PIM_API_URL
          value: {{.Values.pim_api_url}}
        - 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: ADMIN_LOGIN
          valueFrom:
            secretKeyRef:
              name: secret-admin
              key: username
              optional: false
        - name: ADMIN_PASSWORD
          valueFrom:
            secretKeyRef:
              name: secret-admin
              key: password
              optional: false
      imagePullSecrets:
      - name: regcred
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: pimsync
spec:
  type: ClusterIP
  selector:
    app: pimsync
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
{{ end }}