{{- if not .Values.benji.rook.enabled }}
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template "benji.fullname" . }}
  labels:
    app: {{ template "benji.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  replicas: 1
  template:
    metadata:
      name: {{ template "benji.fullname" . }}
      labels:
        app: {{ template "benji.name" . }}
        release: {{ .Release.Name }}
      annotations:
        prometheus.io/port: "{{ .Values.pushgateway.port }}"
        prometheus.io/scrape: "true"
    spec:
      serviceAccount: {{ template "benji.fullname" . }}
      dnsPolicy: ClusterFirstWithHostNet
      containers:
        - name: benji
          image: "{{ .Values.benji.image.registry }}/{{ .Values.benji.image.repository }}:{{ .Values.benji.image.tag }}"
          imagePullPolicy: {{ .Values.benji.image.pullPolicy }}
          securityContext:
            privileged: true
          volumeMounts:
            - mountPath: /dev
              name: dev
            - mountPath: /sys/bus
              name: sysbus
            - mountPath: /lib/modules
              name: libmodules
            - name: mon-endpoint-volume
              mountPath: /etc/rook
            - name: benji-config
              mountPath: /benji/etc
            - name: tz-config
              mountPath: /etc/localtime
          resources:
{{ toYaml .Values.benji.resources | indent 12 }}
        - name: pushgateway
          image: "{{ .Values.pushgateway.image.registry }}/{{ .Values.pushgateway.image.repository }}:{{ .Values.pushgateway.image.tag }}"
          imagePullPolicy: {{ .Values.pushgateway.image.pullPolicy }}
          args:
            - "--web.listen-address=:{{ .Values.pushgateway.port }}"
            - "--persistence.file=/var/lib/pushgateway/database.dat"
          ports:
            - containerPort: {{ .Values.pushgateway.port }}
          volumeMounts:
            - mountPath: /var/lib/pushgateway
              name: pushgateway
            - name: tz-config
              mountPath: /etc/localtime
      hostNetwork: false
      volumes:
        - name: dev
          hostPath:
            path: /dev
        - name: sysbus
          hostPath:
            path: /sys/bus
        - name: libmodules
          hostPath:
            path: /lib/modules
        - name: mon-endpoint-volume
          configMap:
            name: rook-ceph-mon-endpoints
            items:
              - key: data
                path: mon-endpoints
        - name: benji-config
          configMap:
            name: {{ template "benji.fullname" . }}
        - name: pushgateway
          emptyDir: {}
        - name: tz-config
          hostPath:
            path: /usr/share/zoneinfo/{{ .Values.timeZone }}
    {{- if .Values.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
    {{- end }}
{{- end }}
