apiVersion: apps/v1
kind: Deployment
metadata:
  name: central-dashboard
  labels:
    helm.sh/chart: {{ include "deploykf-dashboard.labels.chart" . }}
    app.kubernetes.io/name: {{ include "deploykf-dashboard.labels.name" . }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    app.kubernetes.io/component: central-dashboard
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "deploykf-dashboard.labels.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
      app.kubernetes.io/managed-by: {{ .Release.Service }}
      app.kubernetes.io/component: central-dashboard
  template:
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "deploykf-dashboard.labels.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
        app.kubernetes.io/managed-by: {{ .Release.Service }}
        app.kubernetes.io/component: central-dashboard
    spec:
      {{- if .Values.centralDashboard.image.pullSecret }}
      imagePullSecrets:
        - name: {{ .Values.centralDashboard.image.pullSecret }}
      {{- end }}
      nodeSelector: {}
      affinity: {}
      tolerations: []
      serviceAccountName: central-dashboard
      securityContext: {}
      containers:
        - name: central-dashboard
          image: {{ .Values.centralDashboard.image.repository }}:{{ .Values.centralDashboard.image.tag }}
          imagePullPolicy: {{ .Values.centralDashboard.image.pullPolicy }}
          securityContext:
            runAsUser: {{ .Values.centralDashboard.image.uid }}
            runAsGroup: {{ .Values.centralDashboard.image.gid }}
          {{- if .Values.centralDashboard.resources }}
          resources:
            {{- toYaml .Values.centralDashboard.resources | nindent 12 }}
          {{- end }}
          env:
            - name: USERID_HEADER
              value: {{ .Values.deployKF.kubeflow.useridHeader | quote }}
            - name: USERID_PREFIX
              value: ""
            - name: PROFILES_KFAM_SERVICE_HOST
              value: "kfam-api.{{ .Release.Namespace }}.svc.{{ .Values.deployKF.clusterDomain }}"
            - name: PROFILES_KFAM_SERVICE_PORT
              value: "8081"
            - name: REGISTRATION_FLOW
              value: {{ .Values.centralDashboard.registrationFlow | quote }}
            - name: DASHBOARD_CONFIGMAP
              value: "central-dashboard-config"
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
            - name: http
              containerPort: 8082
              protocol: TCP
          livenessProbe:
            initialDelaySeconds: 15
            periodSeconds: 30
            httpGet:
              path: /healthz
              port: http
          readinessProbe:
            httpGet:
              path: /healthz
              port: http