apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kiali
  namespace: {{ .Release.Namespace }}
  labels:
    app: kiali
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: kiali
  template:
    metadata:
      name: kiali
      labels:
        app: kiali
      annotations:
        sidecar.istio.io/inject: "false"
        scheduler.alpha.kubernetes.io/critical-pod: ""
    spec:
      serviceAccountName: kiali-service-account
{{- if .Values.global.priorityClassName }}
      priorityClassName: "{{ .Values.global.priorityClassName }}"
{{- end }}
      containers:
      - image: "{{ .Values.hub }}/kiali:{{ .Values.tag }}"
        name: kiali
        command:
        - "/opt/kiali/kiali"
        - "-config"
        - "/kiali-configuration/config.yaml"
        - "-v"
        - "4"
        env:
        - name: ACTIVE_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: SERVER_CREDENTIALS_USERNAME
          valueFrom:
            secretKeyRef:
              name: kiali
              key: username
        - name: SERVER_CREDENTIALS_PASSWORD
          valueFrom:
            secretKeyRef:
              name: kiali
              key: passphrase
        - name: PROMETHEUS_SERVICE_URL
          value: http://prometheus:9090
{{- if .Values.dashboard.grafanaURL }}
        - name: GRAFANA_URL
          value: {{ .Values.dashboard.grafanaURL }}
{{- end }}
        - name: GRAFANA_DASHBOARD
          value: istio-service-dashboard
        - name: GRAFANA_VAR_SERVICE_SOURCE
          value: var-service
        - name: GRAFANA_VAR_SERVICE_DEST
          value: var-service
{{- if .Values.dashboard.jaegerURL }}
        - name: JAEGER_URL
          value: {{ .Values.dashboard.jaegerURL }}
{{- end }}
        volumeMounts:
        - name: kiali-configuration
          mountPath: "/kiali-configuration"
        resources:
{{- if .Values.resources }}
{{ toYaml .Values.resources | indent 10 }}
{{- else }}
{{ toYaml .Values.global.defaultResources | indent 10 }}
{{- end }}
      volumes:
      - name: kiali-configuration
        configMap:
          name: kiali
