Skip to content

Commit

Permalink
chore(rbac): rbac should only be generated when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
tthvo committed Apr 21, 2024
1 parent 62d8ff3 commit a6cd757
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions charts/cryostat/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{- if .Values.rbac.create -}}
{{- if and .Values.rbac.create .Values.core.discovery.kubernetes.enabled -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "cryostat.fullname" . }}
name: {{ include "cryostat.fullname" . }}-namespaced
labels:
{{- include "cryostat.labels" . | nindent 4 }}
rules:
Expand Down
8 changes: 3 additions & 5 deletions charts/cryostat/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ metadata:
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "cryostat.fullname" . }}
name: {{ include "cryostat.fullname" . }}-namespaced
subjects:
- kind: ServiceAccount
name: {{ include "cryostat.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
{{- end -}}

{{- if .Values.rbac.create -}}
{{- $ := . -}}
{{- if and .Values.rbac.create .Values.core.discovery.kubernetes.enabled -}}
{{- $watchNs := list -}}
{{- $ownNs := .Release.Namespace -}}
{{- range .Values.core.discovery.kubernetes.namespaces -}}
{{- if eq . "." -}}
{{- $watchNs = append $watchNs $ownNs -}}
{{- $watchNs = append $watchNs $.Release.Namespace -}}
{{- else -}}
{{- $watchNs = append $watchNs . -}}
{{- end -}}
Expand Down

0 comments on commit a6cd757

Please sign in to comment.