apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "mikrotik-portal.fullname" . }}-frontend
  labels:
    {{- include "mikrotik-portal.frontendLabels" . | nindent 4 }}
spec:
  replicas: {{ .Values.frontend.replicaCount }}
  selector:
    matchLabels:
      {{- include "mikrotik-portal.frontendSelectorLabels" . | nindent 6 }}
  template:
    metadata:
      labels:
        {{- include "mikrotik-portal.frontendSelectorLabels" . | nindent 8 }}
    spec:
      containers:
        - name: frontend
          image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag }}"
          imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          resources:
            {{- toYaml .Values.frontend.resources | nindent 12 }}
          livenessProbe:
            httpGet:
              path: /nginx-health
              port: http
            initialDelaySeconds: 10
            periodSeconds: 10
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /nginx-health
              port: http
            initialDelaySeconds: 5
            periodSeconds: 5
            failureThreshold: 3
---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "mikrotik-portal.fullname" . }}-frontend
  labels:
    {{- include "mikrotik-portal.frontendLabels" . | nindent 4 }}
spec:
  type: {{ .Values.frontend.service.type }}
  ports:
    - port: {{ .Values.frontend.service.port }}
      targetPort: http
      protocol: TCP
      name: http
  selector:
    {{- include "mikrotik-portal.frontendSelectorLabels" . | nindent 4 }}
