Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions helm/kagent/templates/rbac/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.rbac.clusterRoleEnabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down Expand Up @@ -169,3 +170,4 @@ rules:
- update
- patch
- delete
{{- end }}
2 changes: 2 additions & 0 deletions helm/kagent/templates/rbac/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.rbac.clusterRoleEnabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand Down Expand Up @@ -27,3 +28,4 @@ subjects:
- kind: ServiceAccount
name: {{ include "kagent.fullname" . }}-controller
namespace: {{ .Release.Namespace }}
{{- end }}
43 changes: 42 additions & 1 deletion helm/kagent/tests/rbac_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,45 @@ tests:
value: RELEASE-NAME
- equal:
path: metadata.labels["app.kubernetes.io/managed-by"]
value: Helm
value: Helm

# Tests for rbac.clusterRoleEnabled switch
- it: should render clusterroles when rbac.clusterRoleEnabled is true (default)
template: rbac/clusterrole.yaml
set:
rbac:
clusterRoleEnabled: true
asserts:
- hasDocuments:
count: 2
- isKind:
of: ClusterRole

- it: should not render clusterroles when rbac.clusterRoleEnabled is false
template: rbac/clusterrole.yaml
set:
rbac:
clusterRoleEnabled: false
asserts:
- hasDocuments:
count: 0

- it: should render clusterrolebindings when rbac.clusterRoleEnabled is true (default)
template: rbac/clusterrolebinding.yaml
set:
rbac:
clusterRoleEnabled: true
asserts:
- hasDocuments:
count: 2
- isKind:
of: ClusterRoleBinding

- it: should not render clusterrolebindings when rbac.clusterRoleEnabled is false
template: rbac/clusterrolebinding.yaml
set:
rbac:
clusterRoleEnabled: false
asserts:
- hasDocuments:
count: 0
9 changes: 9 additions & 0 deletions helm/kagent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ securityContext: {}
# runAsNonRoot: true
# runAsUser: 1000

# ==============================================================================
# RBAC CONFIGURATION
# ==============================================================================

rbac:
# -- Whether to create ClusterRole and ClusterRoleBinding resources.
# Set to false if you want to manage RBAC externally or use pre-existing roles.
clusterRoleEnabled: true

# ==============================================================================
# CORE KAGENT COMPONENTS
# ==============================================================================
Expand Down