webapi-cluster-role-binding.yaml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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: ClusterRoleBinding
  8. metadata:
  9. name: {{ $.Values.restapi.name }}
  10. {{- with $.Values.clusterOwnerRefereces }}
  11. ownerReferences:
  12. {{- toYaml . | nindent 4 }}
  13. {{- end }}
  14. subjects:
  15. - kind: ServiceAccount
  16. name: {{ $.Values.restapi.name }}
  17. namespace: {{ $.Release.Namespace }}
  18. roleRef:
  19. kind: ClusterRole
  20. name: {{ $.Values.restapi.name }}
  21. apiGroup: rbac.authorization.k8s.io
  22. {{- else if and (eq $index 0) $.Values.allowImpersonationForRestApi }}
  23. ---
  24. apiVersion: rbac.authorization.k8s.io/v1
  25. kind: ClusterRoleBinding
  26. metadata:
  27. name: {{ $.Values.restapi.name }}
  28. {{- with $.Values.clusterOwnerRefereces }}
  29. ownerReferences:
  30. {{- toYaml . | nindent 4 }}
  31. {{- end }}
  32. subjects:
  33. - kind: ServiceAccount
  34. name: {{ $.Values.restapi.name }}
  35. namespace: {{ $.Release.Namespace }}
  36. roleRef:
  37. kind: ClusterRole
  38. name: {{ $.Values.restapi.name }}
  39. apiGroup: rbac.authorization.k8s.io
  40. {{- end }}
  41. {{- if not (eq $namespace "_all_namespaces_placeholder") }}
  42. ---
  43. apiVersion: rbac.authorization.k8s.io/v1
  44. kind: RoleBinding
  45. metadata:
  46. namespace: {{ $namespace }}
  47. name: {{ $.Values.restapi.name }}
  48. subjects:
  49. - kind: ServiceAccount
  50. name: {{ $.Values.restapi.name }}
  51. namespace: {{ $.Release.Namespace }}
  52. roleRef:
  53. kind: Role
  54. name: {{ $.Values.restapi.name }}
  55. apiGroup: rbac.authorization.k8s.io
  56. {{- end }}
  57. {{- end }}
  58. {{- end }}