{{ if .Values.optimization.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: optimization
spec:
  replicas: 1
  selector:
    matchLabels:
      app: optimization
  template:
    metadata:
      name: optimization
      labels:
        app: optimization
    spec:
      containers:
      - name: optimization
        image: goalprofit/optimization:{{.Values.optimization.version}}
        imagePullPolicy: Always
        ports:
          - containerPort: 5000
        readinessProbe:
          tcpSocket:
            port: 5000
          initialDelaySeconds: 5
          periodSeconds: 10
        livenessProbe:
          tcpSocket:
            port: 5000
          initialDelaySeconds: 10
          periodSeconds: 20
        env:
        - name: OMP_NUM_THREADS
          value: "{{.Values.optimization.num_cpus}}"
        - name: PORT
          value: "5000"
      imagePullSecrets:
      - name: regcred
      {{ include "app.affinity" . | nindent 6}}
---
apiVersion: v1
kind: Service
metadata:
  name: optimization
spec:
  type: ClusterIP
  selector:
    app: optimization
  ports:
    - protocol: TCP
      port: 5000
      targetPort: 5000
{{ end }}
