{{ if .Values.smbFlexVolInstaller.enabled }}

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: {{ include "smb-flexvol.fullname" . }}-installer
  labels:
    k8s-app: smb
{{ include "smb-flexvol.labels" . | indent 4 }}
  namespace: kube-system
spec:
  selector:
    matchLabels:
      name: smb
      app.kubernetes.io/name: {{ include "smb-flexvol.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    metadata:
      labels:
        name: smb
        app.kubernetes.io/name: {{ include "smb-flexvol.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      containers:
      - name: smb-flexvol-installer
        image: "{{ .Values.smbFlexVolInstaller.image.repository }}:{{ .Values.smbFlexVolInstaller.image.tag }}"
        env:
          - name: INSTALL_DEPS
            value: "{{ .Values.smbFlexVolInstaller.installDependencies }}"
        imagePullPolicy: Always
        volumeMounts:
        - name: volplugins
          mountPath: /etc/kubernetes/volumeplugins/
        - name: varlog
          mountPath: /var/log/
      nodeSelector:
{{ toYaml .Values.smbFlexVolInstaller.nodeSelector | indent 8 }}
      tolerations:
{{ toYaml .Values.smbFlexVolInstaller.tolerations | indent 8 }}
      volumes:
      - name: varlog
        hostPath:
          path: /var/log/              
      - name: volplugins
        hostPath:
          path: {{ .Values.smbFlexVolInstaller.flexVolumePluginPath }}
          type: DirectoryOrCreate

{{ end }}
