{{- if .Values.extensions.cache.enabled }} --- apiVersion: v1 kind: ServiceAccount metadata: name: {{ .Release.Name }}-extensions-cache namespace: {{ .Release.Namespace }} {{- if or .Values.serviceAccount.repoCredentials .Values.imagePullSecrets }} imagePullSecrets: {{- with .Values.serviceAccount.repoCredentials }} {{- range . }} - name: {{ . }} {{- end }} {{- end }} {{- with .Values.imagePullSecrets }} {{ . | toYaml }} {{- end }} {{- end }} {{- $allowedNamespaces := regexSplit " " (include "allowedNamespaces" .) -1 }} {{- range $index, $namespace := $allowedNamespaces }} {{- if eq $namespace "_all_namespaces_placeholder" }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: {{ $.Release.Name }}-extensions-cache {{- with $.Values.clusterOwnerRefereces }} ownerReferences: {{- toYaml . | nindent 4 }} {{- end }} {{- else }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: {{ $namespace }} name: {{ $.Release.Name }}-extensions-cache {{- end }} rules: - apiGroups: ["stackgres.io"] resources: - sgclusters - sgdistributedlogs verbs: - list - get {{- end }} {{- range $index, $namespace := $allowedNamespaces }} {{- if eq $namespace "_all_namespaces_placeholder" }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: {{ $.Release.Name }}-extensions-cache {{- with $.Values.clusterOwnerRefereces }} ownerReferences: {{- toYaml . | nindent 4 }} {{- end }} subjects: - kind: ServiceAccount name: {{ $.Release.Name }}-extensions-cache namespace: {{ $.Release.Namespace }} roleRef: kind: ClusterRole name: {{ $.Release.Name }}-extensions-cache apiGroup: rbac.authorization.k8s.io {{- else }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: namespace: {{ $namespace }} name: {{ $.Release.Name }}-extensions-cache subjects: - kind: ServiceAccount name: {{ $.Release.Name }}-extensions-cache namespace: {{ $.Release.Namespace }} roleRef: kind: Role name: {{ $.Release.Name }}-extensions-cache apiGroup: rbac.authorization.k8s.io {{- end }} {{- end }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: namespace: {{ .Release.Namespace }} name: {{ .Release.Name }}-extensions-cache-extra rules: - apiGroups: ["", "apps"] resources: - serviceaccounts - statefulsets verbs: - get - patch - update resourceNames: - {{ .Release.Name }}-extensions-cache - apiGroups: [""] resources: - pods verbs: - delete resourceNames: - {{ .Release.Name }}-extensions-cache-0 --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: namespace: {{ .Release.Namespace }} name: {{ .Release.Name }}-extensions-cache-extra subjects: - kind: ServiceAccount name: {{ .Release.Name }}-extensions-cache namespace: {{ .Release.Namespace }} roleRef: kind: Role name: {{ .Release.Name }}-extensions-cache-extra apiGroup: rbac.authorization.k8s.io {{- end }}