{{- if .Values.backend.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "pinepods.fullname" . }}-backend
  labels:
    {{- include "pinepods.labels" . | nindent 4 }}
    app.kubernetes.io/component: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      {{- include "pinepods.selectorLabels" . | nindent 6 }}
      app.kubernetes.io/component: backend
  template:
    metadata:
      labels:
        {{- include "pinepods.selectorLabels" . | nindent 8 }}
        app.kubernetes.io/component: backend
    spec:
      containers:
        - name: backend
          image: "{{ .Values.backend.image.repository }}:{{ .Values.backend.image.tag }}"
          imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
          ports:
            - name: http
              containerPort: {{ .Values.backend.service.port }}
              protocol: TCP
          envFrom:
            - secretRef:
                name: {{ include "pinepods.fullname" . }}-backend
{{- end }}