{{ if .Values.orm.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: orm
spec:
  replicas: {{ .Values.orm.replicas }}
  selector:
    matchLabels:
      app: orm
  template:
    metadata:
      name: orm
      labels:
        app: orm
    spec:
      terminationGracePeriodSeconds: 1
      containers:
      - name: orm
        image: docker.io/goalprofit/orm:{{.Values.orm.version}}
        imagePullPolicy: Always
        resources:
          limits:
            memory: "{{.Values.orm.ram_limit}}"
          requests:
            memory: 1Gi
        env:
          - name: OLAP_USER
            valueFrom:
              secretKeyRef:
                name: secret-admin
                key: username
                optional: false
          - name: OLAP_PASSWORD
            valueFrom:
              secretKeyRef:
                name: secret-admin
                key: password
                optional: false
        volumeMounts:
        - mountPath: /app/data
          name: customer
          subPath: data/orm
      imagePullSecrets:
      - name: regcred
        
      volumes:
      - name: customer
        {{ include "app.customer_volume" . | nindent 8}}
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: orm
spec:
  type: ClusterIP
  selector:
    app: orm
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 3000
{{ end }}