Skip to content

Commit

Permalink
fix(kspm-collector): Add missing clusterrole for KSPM PSP (#1109)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele De Lorenzi <[email protected]>
  • Loading branch information
dark-vex authored May 18, 2023
1 parent 959627c commit ac63313
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/kspm-collector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: kspm-collector
description: Sysdig KSPM collector

version: 0.1.44
version: 0.1.45
appVersion: 1.22.0
keywords:
- monitoring
Expand Down
10 changes: 10 additions & 0 deletions charts/kspm-collector/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ rules:
- 'get'
- 'list'
- 'watch'
{{- if and .Values.psp.create (include "kspmCollector.kubeVersionLessThan" (dict "root" . "major" 1 "minor" 25)) }}
- apiGroups:
- "policy"
resources:
- "podsecuritypolicies"
resourceNames:
- "{{ template "kspmCollector.fullname" .}}"
verbs:
- "use"
{{- end }}
{{- end }}
71 changes: 71 additions & 0 deletions charts/kspm-collector/tests/clusterrole_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
suite: KSPM Collector Cluster Role Tests
templates:
- templates/clusterrole.yaml
tests:
- it: Test PSP information included in k8s <1.25
capabilities:
majorVersion: 1
minorVersion: 24
asserts:
- contains:
path: rules
content:
apiGroups:
- "policy"
resources:
- "podsecuritypolicies"
resourceNames:
- release-name-kspm-collector
verbs:
- "use"

- it: Test PSP information not included in k8s >=1.25
capabilities:
majorVersion: 1
minorVersion: 25
asserts:
- notContains:
path: rules
content:
apiGroups:
- "policy"
resources:
- "podsecuritypolicies"
resourceNames:
- release-name-kspm-collector
verbs:
- "use"

- it: Test PSP information included in k8s <1.25 with '+' character in minor version
capabilities:
majorVersion: 1
minorVersion: "24+"
asserts:
- contains:
path: rules
content:
apiGroups:
- "policy"
resources:
- "podsecuritypolicies"
resourceNames:
- release-name-kspm-collector
verbs:
- "use"

- it: Test PSP information not included in k8s >=1.25 with '+' character in minor version
capabilities:
majorVersion: 1
minorVersion: "25+"
asserts:
- notContains:
path: rules
content:
apiGroups:
- "policy"
resources:
- "podsecuritypolicies"
resourceNames:
- release-name-kspm-collector
verbs:
- "use"

0 comments on commit ac63313

Please sign in to comment.