apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template "openebs.fullname" . }}-provisioner
  labels:
    app: {{ template "openebs.name" . }}
    chart: {{ template "openebs.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
    component: provisioner
    openebs.io/component-name: openebs-provisioner
spec:
  replicas: {{ .Values.provisioner.replicas }}
  selector:
    matchLabels:
      app: {{ template "openebs.name" . }}
      release: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ template "openebs.name" . }}
        release: {{ .Release.Name }}
        component: provisioner
    spec:
      serviceAccountName: {{ template "openebs.serviceAccountName" . }}
      containers:
      - name: {{ template "openebs.name" . }}-provisioner
        image: "{{ .Values.provisioner.image }}:{{ .Values.provisioner.imageTag }}"
        imagePullPolicy: {{ .Values.image.pullPolicy }}
        env:
        # OPENEBS_IO_K8S_MASTER enables openebs provisioner to connect to K8s
        # based on this address. This is ignored if empty.
        # This is supported for openebs provisioner version 0.5.2 onwards
        #- name: OPENEBS_IO_K8S_MASTER
        #  value: "http://10.128.0.12:8080"
        # OPENEBS_IO_KUBE_CONFIG enables openebs provisioner to connect to K8s
        # based on this config. This is ignored if empty.
        # This is supported for openebs provisioner version 0.5.2 onwards
        #- name: OPENEBS_IO_KUBE_CONFIG
        #  value: "/home/ubuntu/.kube/config"
        # OPENEBS_NAMESPACE is the namespace that this provisioner will
        # lookup to find maya api service
        - name: OPENEBS_NAMESPACE
          value: "{{ .Release.Namespace }}"
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        # OPENEBS_MAYA_SERVICE_NAME provides the maya-apiserver K8s service name,
        # that provisioner should forward the volume creaet/delete requests.
        # If not present, "maya-apiserver-service" will be used for lookup.
        # This is supported for openebs provisioner version 0.5.3-RC1 onwards
        - name: OPENEBS_MAYA_SERVICE_NAME
          value: "{{ template "openebs.fullname" . }}-apiservice"
        # The following values will be set as annotations to the PV object.
        # Refer : https://github.com/openebs/external-storage/pull/15
        #- name: OPENEBS_MONITOR_URL
        #  value: "{{ .Values.provisioner.monitorUrl }}"
        #- name: OPENEBS_MONITOR_VOLKEY
        #  value: "{{ .Values.provisioner.monitorVolumeKey }}"
        #- name: MAYA_PORTAL_URL
        #  value: "{{ .Values.provisioner.mayaPortalUrl }}"
        livenessProbe:
          exec:
            command:
            - pgrep
            - ".*openebs"
          initialDelaySeconds: {{ .Values.provisioner.healthCheck.initialDelaySeconds }}
          periodSeconds: {{ .Values.provisioner.healthCheck.periodSeconds }}
{{- if .Values.provisioner.nodeSelector }}
      nodeSelector:
{{ toYaml .Values.provisioner.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.provisioner.tolerations }}
      tolerations:
{{ toYaml .Values.provisioner.tolerations | indent 8 }}
{{- end }}
{{- if .Values.provisioner.affinity }}
      affinity:
{{ toYaml .Values.provisioner.affinity | indent 8 }}
{{- end }}
