{{- if .Values.rbac.create -}}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: csi-{{ .Values.rbac.name }}-node-role
rules:
  - apiGroups: [""]
    resources: ["secrets"]
    verbs: ["get"]
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get"]

---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: csi-{{ .Values.rbac.name }}-node-secret-binding
subjects:
  - kind: ServiceAccount
    name: {{ .Values.serviceAccount.node }}
    namespace: {{ .Release.Namespace }}
roleRef:
  kind: ClusterRole
  name: csi-{{ .Values.rbac.name }}-node-role
  apiGroup: rbac.authorization.k8s.io
{{ end }}
