apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "kubeapps.dashboard.fullname" . }}
  labels:{{ include "kubeapps.extraAppLabels" . | nindent 4 }}
    app: {{ template "kubeapps.dashboard.fullname" . }}
spec:
  replicas: {{ .Values.dashboard.replicaCount }}
  selector:
    matchLabels:
      app: {{ template "kubeapps.dashboard.fullname" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/dashboard-config.yaml") . | sha256sum }}
      labels:
        app: {{ template "kubeapps.dashboard.fullname" . }}
        app.kubernetes.io/name: {{ template "kubeapps.name" . }}
        release: {{ .Release.Name }}
        app.kubernetes.io/instance: {{ .Release.Name }}
        chart: {{ template "kubeapps.chart" . }}
        helm.sh/chart: {{ template "kubeapps.chart" . }}
    spec:
{{- include "kubeapps.imagePullSecrets" . | indent 6 }}
      {{- if .Values.dashboard.affinity }}
      affinity: {{- include "kubeapps.tplValue" (dict "value" .Values.dashboard.affinity "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.dashboard.nodeSelector }}
      nodeSelector: {{- include "kubeapps.tplValue" (dict "value" .Values.dashboard.nodeSelector "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.dashboard.tolerations }}
      tolerations: {{- include "kubeapps.tplValue" (dict "value" .Values.dashboard.tolerations "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.securityContext.enabled }}
      securityContext:
        fsGroup: {{ .Values.securityContext.fsGroup }}
        runAsUser: {{ .Values.securityContext.runAsUser }}
      {{- end }}
      containers:
        - name: dashboard
          image: {{ template "kubeapps.image" (list .Values.dashboard.image .Values.global) }}
          imagePullPolicy: {{ .Values.dashboard.image.pullPolicy | quote }}
          {{- if .Values.dashboard.livenessProbe }}
          livenessProbe: {{- toYaml .Values.dashboard.livenessProbe | nindent 12 }}
          {{- end }}
          {{- if .Values.dashboard.readinessProbe }}
          readinessProbe: {{- toYaml .Values.dashboard.readinessProbe | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: vhost
              mountPath: /opt/bitnami/nginx/conf/server_blocks
            - name: config
              mountPath: /app/config.json
              subPath: config.json
          ports:
            - name: http
              containerPort: 8080
          {{- if .Values.dashboard.resources }}
          resources: {{- toYaml .Values.dashboard.resources | nindent 12 }}
          {{- end }}
      volumes:
        - name: vhost
          configMap:
            name: {{ template "kubeapps.dashboard-config.fullname" . }}
            items:
              - key: vhost.conf
                path: vhost.conf
        - name: config
          configMap:
            name: {{ template "kubeapps.dashboard-config.fullname" . }}
            items:
              - key: config.json
                path: config.json
