operator-cluster-role.yaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. {{- if and .Values.deploy.operator .Values.serviceAccount.create }}
  2. {{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }}
  3. {{- range $index, $namespace := $allowedNamespaces }}
  4. {{- if and (eq $index 0) (not $.Values.disableClusterRole) }}
  5. ---
  6. apiVersion: rbac.authorization.k8s.io/v1
  7. kind: ClusterRole
  8. metadata:
  9. name: {{ $.Release.Name }}
  10. {{- with $.Values.clusterOwnerRefereces }}
  11. ownerReferences:
  12. {{- toYaml . | nindent 4 }}
  13. {{- end }}
  14. rules:
  15. - apiGroups: [""]
  16. resources: ["namespaces"]
  17. verbs:
  18. - get
  19. - list
  20. - apiGroups: ["storage.k8s.io"]
  21. resources: ["storageclasses"]
  22. verbs:
  23. - get
  24. - list
  25. - apiGroups: ["apiextensions.k8s.io"]
  26. resources:
  27. - customresourcedefinitions
  28. resourceNames:
  29. - sgconfigs.stackgres.io
  30. - sgclusters.stackgres.io
  31. - sginstanceprofiles.stackgres.io
  32. - sgpgconfigs.stackgres.io
  33. - sgpoolconfigs.stackgres.io
  34. - sgbackups.stackgres.io
  35. - sgbackupconfigs.stackgres.io
  36. - sgobjectstorages.stackgres.io
  37. - sgdbops.stackgres.io
  38. - sgdistributedlogs.stackgres.io
  39. - sgshardedclusters.stackgres.io
  40. - sgshardedbackups.stackgres.io
  41. - sgshardeddbops.stackgres.io
  42. - sgscripts.stackgres.io
  43. - sgstreams.stackgres.io
  44. verbs:
  45. - get
  46. - apiGroups: ["apiextensions.k8s.io"]
  47. resources:
  48. - customresourcedefinitions
  49. verbs:
  50. - list
  51. {{- if not $.Values.disableCrdsAndWebhooksUpdate }}
  52. - apiGroups:
  53. - admissionregistration.k8s.io
  54. resources:
  55. - mutatingwebhookconfigurations
  56. - validatingwebhookconfigurations
  57. resourceNames:
  58. - {{ $.Release.Name }}
  59. verbs:
  60. - get
  61. - patch
  62. - apiGroups: ["apiextensions.k8s.io"]
  63. resources:
  64. - customresourcedefinitions
  65. verbs:
  66. - create
  67. - apiGroups: ["apiextensions.k8s.io"]
  68. resources:
  69. - customresourcedefinitions
  70. resourceNames:
  71. - sgconfigs.stackgres.io
  72. - sgclusters.stackgres.io
  73. - sginstanceprofiles.stackgres.io
  74. - sgpgconfigs.stackgres.io
  75. - sgpoolconfigs.stackgres.io
  76. - sgbackups.stackgres.io
  77. - sgbackupconfigs.stackgres.io
  78. - sgobjectstorages.stackgres.io
  79. - sgdbops.stackgres.io
  80. - sgdistributedlogs.stackgres.io
  81. - sgshardedclusters.stackgres.io
  82. - sgshardedbackups.stackgres.io
  83. - sgshardeddbops.stackgres.io
  84. - sgscripts.stackgres.io
  85. - sgstreams.stackgres.io
  86. verbs:
  87. - patch
  88. - update
  89. {{- end }}
  90. {{- if (or $.Values.collector.prometheusOperator.allowDiscovery (gt (len $.Values.collector.prometheusOperator.monitors) 0)) }}
  91. - apiGroups: ["apiextensions.k8s.io"]
  92. resources:
  93. - customresourcedefinitions
  94. resourceNames:
  95. - prometheuses.monitoring.coreos.com
  96. verbs:
  97. - get
  98. {{- end }}
  99. {{- if and $.Values.sgConfigNamespace (not (eq $.Values.sgConfigNamespace $.Release.Namespace)) }}
  100. - apiGroups: ["rbac.authorization.k8s.io"]
  101. resources:
  102. - clusterrolebindings
  103. verbs:
  104. - create
  105. - watch
  106. - list
  107. - get
  108. - update
  109. - patch
  110. - delete
  111. - apiGroups:
  112. - ""
  113. resources:
  114. - users
  115. - groups
  116. verbs:
  117. - impersonate
  118. {{- end }}
  119. {{- end }}
  120. {{- if not (eq $namespace "_all_namespaces_placeholder") }}
  121. ---
  122. apiVersion: rbac.authorization.k8s.io/v1
  123. kind: Role
  124. metadata:
  125. namespace: {{ $namespace }}
  126. name: {{ $.Release.Name }}
  127. rules:
  128. {{- end }}
  129. - apiGroups: ["", "apps", "extensions", "rbac.authorization.k8s.io", "batch"]
  130. resources:
  131. - pods
  132. - pods/exec
  133. - pods/log
  134. - services
  135. - endpoints
  136. - endpoints/restricted
  137. - persistentvolumeclaims
  138. - configmaps
  139. - secrets
  140. - deployments
  141. - statefulsets
  142. - serviceaccounts
  143. - namespaces
  144. - roles
  145. - rolebindings
  146. - events
  147. - cronjobs
  148. - jobs
  149. verbs:
  150. - get
  151. - list
  152. - watch
  153. - update
  154. - create
  155. - delete
  156. - deletecollection
  157. - patch
  158. - apiGroups: ["stackgres.io"]
  159. resources:
  160. - sgclusters
  161. - sgpgconfigs
  162. - sginstanceprofiles
  163. - sgpoolconfigs
  164. - sgbackupconfigs
  165. - sgbackups
  166. - sgdistributedlogs
  167. - sgdbops
  168. - sgobjectstorages
  169. - sgscripts
  170. - sgshardedclusters
  171. - sgshardedbackups
  172. - sgshardeddbops
  173. - sgstreams
  174. - sgconfigs
  175. verbs:
  176. - create
  177. - watch
  178. - list
  179. - get
  180. - update
  181. - patch
  182. - delete
  183. - apiGroups: ["stackgres.io"]
  184. resources:
  185. - sgconfigs/status
  186. - sgclusters/status
  187. - sgdistributedlogs/status
  188. - sgclusters/finalizers
  189. - sgpgconfigs/finalizers
  190. - sginstanceprofiles/finalizers
  191. - sgpoolconfigs/finalizers
  192. - sgbackupconfigs/finalizers
  193. - sgbackups/finalizers
  194. - sgdistributedlogs/finalizers
  195. - sgdbops/finalizers
  196. - sgobjectstorages/finalizers
  197. - sgscripts/finalizers
  198. - sgshardedclusters/finalizers
  199. - sgshardedbackups/finalizers
  200. - sgshardeddbops/finalizers
  201. - sgstreams/finalizers
  202. - sgconfigs/finalizers
  203. verbs:
  204. - update
  205. - apiGroups: ["", "apps", "batch"]
  206. resources:
  207. - statefulsets/finalizers
  208. - persistentvolumeclaims/finalizers
  209. - deployments/finalizers
  210. - services/finalizers
  211. - endpoints/finalizers
  212. - cronjobs/finalizers
  213. - jobs/finalizers
  214. - pods/finalizers
  215. verbs:
  216. - update
  217. - apiGroups: ["snapshot.storage.k8s.io"]
  218. resources:
  219. - volumesnapshots
  220. verbs:
  221. - list
  222. - get
  223. - watch
  224. - create
  225. {{- if (or $.Values.collector.prometheusOperator.allowDiscovery (gt (len $.Values.collector.prometheusOperator.monitors) 0)) }}
  226. - apiGroups: ["monitoring.coreos.com"]
  227. resources:
  228. - servicemonitors
  229. - podmonitors
  230. verbs:
  231. - list
  232. - get
  233. - create
  234. - delete
  235. - update
  236. - patch
  237. - apiGroups: ["monitoring.coreos.com"]
  238. resources:
  239. - prometheus
  240. - prometheuses
  241. - podmonitors
  242. verbs:
  243. - list
  244. - get
  245. {{- end }}
  246. - apiGroups: ["shardingsphere.apache.org"]
  247. resources:
  248. - computenodes
  249. verbs:
  250. - get
  251. - list
  252. - watch
  253. - update
  254. - create
  255. - delete
  256. - patch
  257. - apiGroups: ["keda.sh"]
  258. resources:
  259. - scaledobjects
  260. - triggerauthentications
  261. verbs:
  262. - get
  263. - list
  264. - watch
  265. - update
  266. - create
  267. - delete
  268. - patch
  269. - apiGroups: ["autoscaling.k8s.io"]
  270. resources:
  271. - verticalpodautoscalers
  272. verbs:
  273. - get
  274. - list
  275. - watch
  276. - update
  277. - create
  278. - delete
  279. - patch
  280. - apiGroups: ["serving.knative.dev"]
  281. resources:
  282. - services
  283. verbs:
  284. - get
  285. - list
  286. - watch
  287. - update
  288. - create
  289. - delete
  290. - patch
  291. {{- end }}
  292. {{- end }}