webapi-cluster-role.yaml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {{- if and .Values.deploy.restapi .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: {{ $.Values.restapi.name }}
  10. {{- with $.Values.clusterOwnerRefereces }}
  11. ownerReferences:
  12. {{- toYaml . | nindent 4 }}
  13. {{- end }}
  14. rules:
  15. - apiGroups:
  16. - authorization.k8s.io
  17. resources:
  18. - subjectaccessreviews
  19. verbs:
  20. - create
  21. - apiGroups:
  22. - ""
  23. resources:
  24. - users
  25. - groups
  26. verbs:
  27. - impersonate
  28. {{- else if and (eq $index 0) $.Values.allowImpersonationForRestApi }}
  29. ---
  30. apiVersion: rbac.authorization.k8s.io/v1
  31. kind: ClusterRole
  32. metadata:
  33. name: {{ $.Values.restapi.name }}
  34. {{- with $.Values.clusterOwnerRefereces }}
  35. ownerReferences:
  36. {{- toYaml . | nindent 4 }}
  37. {{- end }}
  38. rules:
  39. - apiGroups:
  40. - ""
  41. resources:
  42. - users
  43. - groups
  44. verbs:
  45. - impersonate
  46. {{- end }}
  47. {{- if not (eq $namespace "_all_namespaces_placeholder") }}
  48. ---
  49. apiVersion: rbac.authorization.k8s.io/v1
  50. kind: Role
  51. metadata:
  52. namespace: {{ $namespace }}
  53. name: {{ $.Values.restapi.name }}
  54. rules:
  55. {{- end }}
  56. - apiGroups:
  57. - ""
  58. resources:
  59. - secrets # Secret Verification authentication
  60. verbs:
  61. - get
  62. - list
  63. {{- end }}
  64. {{- end }}