apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: grafana
  labels:
    app: {{ template "grafana.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: {{ .Values.replicaCount }}
  template:
    metadata:
      labels:
        app: grafana
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.global.hub }}/grafana:{{ .Values.global.tag }}"
          imagePullPolicy: {{ .Values.imagePullPolicy }}
          ports:
            - containerPort: {{ .Values.service.internalPort }}
          readinessProbe:
            httpGet:
              path: /login
              port: {{ .Values.service.internalPort }}
          env:
          - name: GRAFANA_PORT
            value: {{ .Values.service.internalPort | quote }}
          - name: GF_AUTH_BASIC_ENABLED
            value: "false"
          - name: GF_AUTH_ANONYMOUS_ENABLED
            value: "true"
          - name: GF_AUTH_ANONYMOUS_ORG_ROLE
            value: Admin
          - name: GF_PATHS_DATA
            value: /data/grafana
          resources:
{{ toYaml .Values.resources | indent 12 }}
          volumeMounts:
          - name: data
            mountPath: /data/grafana
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
      volumes:
      - name: data
        emptyDir: {}