apiVersion: apps/v1
kind: Deployment
metadata:
  name: backend
  labels:
    app: backend
    {{- include "common.labels" . | nindent 4 }}
spec:
  replicas: 2
  minAvailable: 2
  selector:
    matchLabels:
      app: backend
      {{- include "common.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        app: backend
        {{- include "common.selectorLabels" . | nindent 8 }}
    spec:
      containers:
        - name: backend
          image: {{ .Values.images.backend }}
          env:
            - name: SERVER_PORT
              value: "8080"
            - name: CLICKHOUSE
              value: "clickhouse:9000"
            - name: NATS
              value: "nats://nats:4222"
            - name: DATABASE_URL
              value: {{ .Values.postgres.db_url | quote }}
            - name: TEAMCITY_TOKEN
              valueFrom:
                secretKeyRef:
                  name: ij-perf-data-tc
                  key: token
            - name: YOUTRACK_TOKEN
              value: {{ .Values.youtrack.token | quote }}
          resources:
            requests:
              cpu: "0.5"
              memory: "1Gi"
            limits:
              cpu: "1"
              memory: "1.5Gi"
          ports:
            - containerPort: 8080
          readinessProbe:
            httpGet:
              path: /health-check
              port: 8080
          livenessProbe:
            httpGet:
              path: /health-check
              port: 8080
      imagePullSecrets:
        - name: ghcr
---
apiVersion: v1
kind: Service
metadata:
  name: backend
  labels:
    app: backend
    {{- include "common.labels" . | nindent 4 }}
spec:
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
  selector:
    app: backend
    {{- include "common.selectorLabels" . | nindent 4 }}