{{- $bl := empty .Values.influxURL }}
{{- if not $bl }}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "kapacitor.fullname" . }}
  labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
    app: {{ template "kapacitor.fullname" . }}
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: {{ template "kapacitor.fullname" . }}
    spec:
      containers:
      - name: {{ .Chart.Name }}
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        env:
        - name: KAPACITOR_HOSTNAME
          value: {{ template "kapacitor.fullname" . }}.{{ .Release.Namespace }}
        - name: KAPACITOR_INFLUXDB_0_URLS_0
          value: {{ .Values.influxURL }}
        {{- range $key, $val := .Values.envVars }}
        - name: {{ $key }}
          value: {{ $val | quote }}
        {{- end }}
        ports:
        - containerPort: 9092
        volumeMounts:
        - name: data
          mountPath: /var/lib/kapacitor
        resources:
{{ toYaml .Values.resources | indent 12 }}
      volumes:
        - name: data
        {{- if .Values.persistence.enabled }}
          persistentVolumeClaim:
            claimName: {{ template "kapacitor.fullname" . }}
        {{- else }}
          emptyDir: {}
        {{- end }}
{{- end }}
