service-account.yaml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {{- $saName := print (include "neo4j.fullname" .) "-sa" -}}
  2. {{- if .Values.serviceAccount.create -}}
  3. ---
  4. apiVersion: v1
  5. kind: ServiceAccount
  6. metadata:
  7. {{- if .Values.serviceAccount.annotations }}
  8. annotations:
  9. {{- range $key, $value := .Values.serviceAccount.annotations }}
  10. {{ $key }}: "{{ $value }}"
  11. {{- end }}
  12. {{- end }}
  13. name: {{ default $saName .Values.serviceAccount.name }}
  14. {{ printf "\n" }}
  15. {{- end }}
  16. {{- if .Values.rbac.create -}}
  17. ---
  18. apiVersion: rbac.authorization.k8s.io/v1
  19. kind: Role
  20. metadata:
  21. name: {{ template "neo4j.fullname" . }}-service-reader
  22. rules:
  23. - apiGroups: [""] # "" indicates the core API group
  24. resources: ["services"]
  25. verbs: ["get", "watch", "list"]
  26. ---
  27. apiVersion: rbac.authorization.k8s.io/v1
  28. kind: RoleBinding
  29. metadata:
  30. name: {{ template "neo4j.fullname" . }}-sa-to-service-reader-binding
  31. subjects:
  32. - kind: ServiceAccount
  33. name: {{ default $saName .Values.serviceAccount.name }}
  34. roleRef:
  35. # "roleRef" specifies the binding to a Role / ClusterRole
  36. kind: Role # this must be Role or ClusterRole
  37. name: {{ template "neo4j.fullname" . }}-service-reader # this must match the name of the Role or ClusterRole you wish to bind to
  38. apiGroup: rbac.authorization.k8s.io
  39. {{- end}}