kind: StatefulSet
apiVersion: apps/v1beta1
metadata:
  name: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
  labels:
    app: {{ include "ceph-csi-rbd.name" . }}
    chart: {{ include "ceph-csi-rbd.chart" . }}
    component: {{ .Values.provisioner.name }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  serviceName: {{ include "ceph-csi-rbd.provisioner.fullname" . }}
  replicas: {{ .Values.provisioner.replicas }}
  template:
    metadata:
      labels:
        app: {{ include "ceph-csi-rbd.name" . }}
        chart: {{ include "ceph-csi-rbd.chart" . }}
        component: {{ .Values.provisioner.name }}
        release: {{ .Release.Name }}
        heritage: {{ .Release.Service }}
    spec:
      serviceAccountName: {{ include "ceph-csi-rbd.serviceAccountName.provisioner" . }}
      containers:
        - name: csi-provisioner
          image: "{{ .Values.provisioner.image.repository }}:{{ .Values.provisioner.image.tag }}"
          args:
            - "--provisioner=csi-rbdplugin"
            - "--csi-address=$(ADDRESS)"
            - "--v=5"
          env:
            - name: ADDRESS
              value: "{{ .Values.socketDir }}/{{ .Values.socketFile }}"
          imagePullPolicy: {{ .Values.provisioner.image.pullPolicy }}
          volumeMounts:
            - name: socket-dir
              mountPath: {{ .Values.socketDir }}
          resources:
{{ toYaml .Values.provisioner.resources | indent 12 }}
      volumes:
        - name: socket-dir
          hostPath:
            path: {{ .Values.socketDir }}
            type: DirectoryOrCreate
    {{- if .Values.provisioner.affinity -}}
      affinity:
{{ toYaml .Values.provisioner.affinity . | indent 8 }}
    {{- end -}}
    {{- if .Values.provisioner.nodeSelector -}}
      nodeSelector:
{{ toYaml .Values.provisioner.nodeSelector | indent 8 }}
    {{- end -}}
    {{- if .Values.provisioner.tolerations -}}
      tolerations:
{{ toYaml .Values.provisioner.tolerations | indent 8 }}
    {{- end -}}