kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: iscsi-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["get", "list", "create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-iscsi-provisioner
subjects:
  - kind: ServiceAccount
    name: iscsi-provisioner
    namespace: default
roleRef:
  kind: ClusterRole
  name: iscsi-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: iscsi-provisioner
---
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: iscsi-provisioner
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: iscsi-provisioner
    spec:
      containers:
        - name: iscsi-provisioner
          imagePullPolicy: Always
          image: quay.io/external_storage/iscsi-controller:latest
          args:
            - "start"
          env:
            - name: PROVISIONER_NAME
              value: iscsi-targetd
            - name: LOG_LEVEL
              value: debug
            - name: TARGETD_USERNAME
              valueFrom:
                secretKeyRef:
                  name: targetd-account
                  key: username
            - name: TARGETD_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: targetd-account
                  key: password
            - name: TARGETD_ADDRESS
              value: 192.168.99.100
      serviceAccount: iscsi-provisioner
