{{- if eq .Values.global.influxdb_location "on-cluster" }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: drycc-monitor-influxdb
  labels:
    heritage: drycc
  annotations:
    component.drycc.cc/version: {{ .Values.monitor.influxdb.docker_tag }}
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: drycc-monitor-influxdb
  template:
    metadata:
      labels:
        app: drycc-monitor-influxdb
    spec:
      containers:
      - name: drycc-monitor-influxdb
        image: {{.Values.monitor.influxdb.docker_registry}}{{.Values.monitor.influxdb.org}}/influxdb:{{.Values.monitor.influxdb.docker_tag}}
        imagePullPolicy: {{.Values.monitor.influxdb.pull_policy}}
{{- if or (.Values.monitor.influxdb.limits_cpu) (.Values.monitor.influxdb.limits_memory)}}
        resources:
          limits:
{{- if (.Values.monitor.influxdb.limits_cpu) }}
            cpu: {{.Values.monitor.influxdb.limits_cpu}}
{{- end}}
{{- if (.Values.monitor.influxdb.limits_memory) }}
            memory: {{.Values.monitor.influxdb.limits_memory}}
{{- end}}
{{- end}}
        ports:
        - containerPort: 8083
          name: admin
        - containerPort: 8086
          name: transport
          protocol: TCP
        - containerPort: 8084
          name: ssltransport
          protocol: TCP
        livenessProbe:
          httpGet:
            path: /ping
            port: 8086
          initialDelaySeconds: 1
          timeoutSeconds: 1
        readinessProbe:
          httpGet:
            path: /ping
            port: 8086
          initialDelaySeconds: 1
          timeoutSeconds: 1
{{- if .Values.monitor.influxdb.persistence.enabled }}
        volumeMounts:
        - name: influxdb-data
          mountPath: /data
      # Allow user influxdb to write to /data
      securityContext:
        fsGroup: 1001
      volumes:
      - name: influxdb-data
        persistentVolumeClaim:
          claimName: drycc-monitor-influxdb
{{- end }}
{{- end }}
