{{- if .Values.consoleFrontend.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "astron-agent.fullname" . }}-console-frontend
  labels:
    {{- include "astron-agent.labels" . | nindent 4 }}
    app.kubernetes.io/component: console-frontend
spec:
  replicas: {{ .Values.consoleFrontend.replicaCount }}
  selector:
    matchLabels:
      {{- include "astron-agent.selectorLabels" . | nindent 6 }}
      app.kubernetes.io/component: console-frontend
  template:
    metadata:
      labels:
        {{- include "astron-agent.selectorLabels" . | nindent 8 }}
        app.kubernetes.io/component: console-frontend
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      containers:
      - name: console-frontend
        image: "{{ .Values.global.imageRegistry }}/{{ .Values.consoleFrontend.image }}:{{ .Values.global.astronAgentVersion }}"
        imagePullPolicy: {{ .Values.global.imagePullPolicy }}
        env:
        - name: CONSOLE_CASDOOR_URL
          value: {{ printf "%s:%d" .Values.global.hostBaseAddress (.Values.casdoor.service.nodePort | int) | quote }}
        - name: CONSOLE_CASDOOR_ID
          value: {{ .Values.consoleFrontend.env.casdoorId | quote }}
        - name: CONSOLE_CASDOOR_APP
          value: {{ .Values.consoleFrontend.env.casdoorApp | quote }}
        - name: CONSOLE_CASDOOR_ORG
          value: {{ .Values.consoleFrontend.env.casdoorOrg | quote }}
        ports:
        - name: http
          containerPort: {{ .Values.consoleFrontend.service.port }}
          protocol: TCP
        livenessProbe:
          tcpSocket:
            port: http
          initialDelaySeconds: 30
          periodSeconds: 30
          timeoutSeconds: 10
          failureThreshold: 6
        readinessProbe:
          tcpSocket:
            port: http
          initialDelaySeconds: 10
          periodSeconds: 10
          timeoutSeconds: 5
          failureThreshold: 6
        resources:
          {{- toYaml .Values.consoleFrontend.resources | nindent 10 }}
{{- end }}
