extensions-cache-service-account.yaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {{- if .Values.extensions.cache.enabled }}
  2. ---
  3. apiVersion: v1
  4. kind: ServiceAccount
  5. metadata:
  6. name: {{ .Release.Name }}-extensions-cache
  7. namespace: {{ .Release.Namespace }}
  8. {{- if or .Values.serviceAccount.repoCredentials .Values.imagePullSecrets }}
  9. imagePullSecrets:
  10. {{- with .Values.serviceAccount.repoCredentials }}
  11. {{- range . }}
  12. - name: {{ . }}
  13. {{- end }}
  14. {{- end }}
  15. {{- with .Values.imagePullSecrets }}
  16. {{ . | toYaml }}
  17. {{- end }}
  18. {{- end }}
  19. {{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }}
  20. {{- range $index, $namespace := $allowedNamespaces }}
  21. {{- if eq $namespace "_all_namespaces_placeholder" }}
  22. ---
  23. apiVersion: rbac.authorization.k8s.io/v1
  24. kind: ClusterRole
  25. metadata:
  26. name: {{ $.Release.Name }}-extensions-cache
  27. {{- with $.Values.clusterOwnerRefereces }}
  28. ownerReferences:
  29. {{- toYaml . | nindent 4 }}
  30. {{- end }}
  31. {{- else }}
  32. ---
  33. apiVersion: rbac.authorization.k8s.io/v1
  34. kind: Role
  35. metadata:
  36. namespace: {{ $namespace }}
  37. name: {{ $.Release.Name }}-extensions-cache
  38. {{- end }}
  39. rules:
  40. - apiGroups: ["stackgres.io"]
  41. resources:
  42. - sgclusters
  43. - sgdistributedlogs
  44. verbs:
  45. - list
  46. - get
  47. {{- end }}
  48. {{- range $index, $namespace := $allowedNamespaces }}
  49. {{- if eq $namespace "_all_namespaces_placeholder" }}
  50. ---
  51. apiVersion: rbac.authorization.k8s.io/v1
  52. kind: ClusterRoleBinding
  53. metadata:
  54. name: {{ $.Release.Name }}-extensions-cache
  55. {{- with $.Values.clusterOwnerRefereces }}
  56. ownerReferences:
  57. {{- toYaml . | nindent 4 }}
  58. {{- end }}
  59. subjects:
  60. - kind: ServiceAccount
  61. name: {{ $.Release.Name }}-extensions-cache
  62. namespace: {{ $.Release.Namespace }}
  63. roleRef:
  64. kind: ClusterRole
  65. name: {{ $.Release.Name }}-extensions-cache
  66. apiGroup: rbac.authorization.k8s.io
  67. {{- else }}
  68. ---
  69. apiVersion: rbac.authorization.k8s.io/v1
  70. kind: RoleBinding
  71. metadata:
  72. namespace: {{ $namespace }}
  73. name: {{ $.Release.Name }}-extensions-cache
  74. subjects:
  75. - kind: ServiceAccount
  76. name: {{ $.Release.Name }}-extensions-cache
  77. namespace: {{ $.Release.Namespace }}
  78. roleRef:
  79. kind: Role
  80. name: {{ $.Release.Name }}-extensions-cache
  81. apiGroup: rbac.authorization.k8s.io
  82. {{- end }}
  83. {{- end }}
  84. ---
  85. apiVersion: rbac.authorization.k8s.io/v1
  86. kind: Role
  87. metadata:
  88. namespace: {{ .Release.Namespace }}
  89. name: {{ .Release.Name }}-extensions-cache-extra
  90. rules:
  91. - apiGroups: ["", "apps"]
  92. resources:
  93. - serviceaccounts
  94. - statefulsets
  95. verbs:
  96. - get
  97. - patch
  98. - update
  99. resourceNames:
  100. - {{ .Release.Name }}-extensions-cache
  101. - apiGroups: [""]
  102. resources:
  103. - pods
  104. verbs:
  105. - delete
  106. resourceNames:
  107. - {{ .Release.Name }}-extensions-cache-0
  108. ---
  109. apiVersion: rbac.authorization.k8s.io/v1
  110. kind: RoleBinding
  111. metadata:
  112. namespace: {{ .Release.Namespace }}
  113. name: {{ .Release.Name }}-extensions-cache-extra
  114. subjects:
  115. - kind: ServiceAccount
  116. name: {{ .Release.Name }}-extensions-cache
  117. namespace: {{ .Release.Namespace }}
  118. roleRef:
  119. kind: Role
  120. name: {{ .Release.Name }}-extensions-cache-extra
  121. apiGroup: rbac.authorization.k8s.io
  122. {{- end }}