rbac.yaml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # This YAML file contains all RBAC objects that are necessary to run external
  2. # CSI attacher.
  3. #
  4. # In production, each CSI driver deployment has to be customized:
  5. # - to avoid conflicts, use non-default namespace and different names
  6. # for non-namespaced entities like the ClusterRole
  7. # - decide whether the deployment replicates the external CSI
  8. # attacher, in which case leadership election must be enabled;
  9. # this influences the RBAC setup, see below
  10. apiVersion: v1
  11. kind: ServiceAccount
  12. metadata:
  13. name: csi-attacher
  14. # replace with non-default namespace name
  15. namespace: default
  16. ---
  17. # Attacher must be able to work with PVs, nodes and VolumeAttachments
  18. kind: ClusterRole
  19. apiVersion: rbac.authorization.k8s.io/v1
  20. metadata:
  21. name: external-attacher-runner
  22. rules:
  23. - apiGroups: [""]
  24. resources: ["persistentvolumes"]
  25. verbs: ["get", "list", "watch", "update", "patch"]
  26. - apiGroups: [""]
  27. resources: ["nodes"]
  28. verbs: ["get", "list", "watch"]
  29. - apiGroups: ["storage.k8s.io"]
  30. resources: ["csinodes"]
  31. verbs: ["get", "list", "watch"]
  32. - apiGroups: ["storage.k8s.io"]
  33. resources: ["volumeattachments"]
  34. verbs: ["get", "list", "watch", "update", "patch"]
  35. #Secret permission is optional.
  36. #Enable it if you need value from secret.
  37. #For example, you have key `csi.storage.k8s.io/controller-publish-secret-name` in StorageClass.parameters
  38. #see https://kubernetes-csi.github.io/docs/secrets-and-credentials.html
  39. # - apiGroups: [""]
  40. # resources: ["secrets"]
  41. # verbs: ["get", "list"]
  42. ---
  43. kind: ClusterRoleBinding
  44. apiVersion: rbac.authorization.k8s.io/v1
  45. metadata:
  46. name: csi-attacher-role
  47. subjects:
  48. - kind: ServiceAccount
  49. name: csi-attacher
  50. # replace with non-default namespace name
  51. namespace: default
  52. roleRef:
  53. kind: ClusterRole
  54. name: external-attacher-runner
  55. apiGroup: rbac.authorization.k8s.io
  56. ---
  57. # Attacher must be able to work with configmaps or leases in the current namespace
  58. # if (and only if) leadership election is enabled
  59. kind: Role
  60. apiVersion: rbac.authorization.k8s.io/v1
  61. metadata:
  62. # replace with non-default namespace name
  63. namespace: default
  64. name: external-attacher-cfg
  65. rules:
  66. - apiGroups: ["coordination.k8s.io"]
  67. resources: ["leases"]
  68. verbs: ["get", "watch", "list", "delete", "update", "create"]
  69. ---
  70. kind: RoleBinding
  71. apiVersion: rbac.authorization.k8s.io/v1
  72. metadata:
  73. name: csi-attacher-role-cfg
  74. # replace with non-default namespace name
  75. namespace: default
  76. subjects:
  77. - kind: ServiceAccount
  78. name: csi-attacher
  79. # replace with non-default namespace name
  80. namespace: default
  81. roleRef:
  82. kind: Role
  83. name: external-attacher-cfg
  84. apiGroup: rbac.authorization.k8s.io