{{- if .Values.front.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.name }}-front
  labels:
    app: front
spec:
  replicas: {{ .Values.front.replicaCount }}
  selector:
    matchLabels:
      app: front
  template:
    metadata:
      labels:
        app: front
    spec:
      imagePullSecrets:
        - name: takima-school-registry
      securityContext:
        runAsUser: 101
        runAsGroup: 101

      containers:
      - name: front
        image: {{ .Values.front.image.repository }}:{{ .Values.front.image.tag }}
        imagePullPolicy: Always
        ports:
          - containerPort: 8080
        resources:
          requests:
            memory: "32M"
            cpu: "0.1"
          limits:
            memory: "128M"
            cpu: "1"
        startupProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 3
          periodSeconds: 1
          successThreshold: 1
          failureThreshold: 5
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          periodSeconds: 3
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          httpGet:
            path: /health
            port: 8080
          periodSeconds: 1
          successThreshold: 1
          failureThreshold: 3
        securityContext:
          allowPrivilegeEscalation: false
        
        env: 
          - name: API_URL
            valueFrom:
              configMapKeyRef:
                name: {{ .Values.name }}-front
                key: API_URL
{{- end }}