1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

feat: make aggregated reports optional ()

* feat: make aggregated reports optional

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* helm

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* changelog

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-06-16 17:19:22 +02:00 committed by GitHub
parent 7ba136767a
commit b2707c0cd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 12 deletions
CHANGELOG.md
charts/kyverno
cmd/reports-controller
config

View file

@ -5,6 +5,7 @@
### Note ### Note
- Deprecated flag `--imageSignatureRepository`. Will be removed in 1.12. Use per rule configuration `verifyImages.Repository` instead. - Deprecated flag `--imageSignatureRepository`. Will be removed in 1.12. Use per rule configuration `verifyImages.Repository` instead.
- Added `--aggregateReports` flag to reports controller to enable/disable aggregated reports (default value is `true`).
## v1.10.0 ## v1.10.0

View file

@ -291,6 +291,7 @@ The chart values are organised per component.
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----|------|---------|-------------| |-----|------|---------|-------------|
| features.admissionReports.enabled | bool | `true` | Enables the feature | | features.admissionReports.enabled | bool | `true` | Enables the feature |
| features.aggregateReports.enabled | bool | `true` | Enables the feature |
| features.autoUpdateWebhooks.enabled | bool | `true` | Enables the feature | | features.autoUpdateWebhooks.enabled | bool | `true` | Enables the feature |
| features.backgroundScan.enabled | bool | `true` | Enables the feature | | features.backgroundScan.enabled | bool | `true` | Enables the feature |
| features.backgroundScan.backgroundScanWorkers | int | `2` | Number of background scan workers | | features.backgroundScan.backgroundScanWorkers | int | `2` | Number of background scan workers |

View file

@ -13,6 +13,9 @@
{{- with .admissionReports -}} {{- with .admissionReports -}}
{{- $flags = append $flags (print "--admissionReports=" .enabled) -}} {{- $flags = append $flags (print "--admissionReports=" .enabled) -}}
{{- end -}} {{- end -}}
{{- with .aggregateReports -}}
{{- $flags = append $flags (print "--aggregateReports=" .enabled) -}}
{{- end -}}
{{- with .autoUpdateWebhooks -}} {{- with .autoUpdateWebhooks -}}
{{- $flags = append $flags (print "--autoUpdateWebhooks=" .enabled) -}} {{- $flags = append $flags (print "--autoUpdateWebhooks=" .enabled) -}}
{{- end -}} {{- end -}}

View file

@ -109,6 +109,7 @@ spec:
{{- end }} {{- end }}
{{- include "kyverno.features.flags" (pick (mergeOverwrite .Values.features .Values.reportsController.featuresOverride) {{- include "kyverno.features.flags" (pick (mergeOverwrite .Values.features .Values.reportsController.featuresOverride)
"admissionReports" "admissionReports"
"aggregateReports"
"backgroundScan" "backgroundScan"
"configMapCaching" "configMapCaching"
"logging" "logging"

View file

@ -327,6 +327,9 @@ features:
admissionReports: admissionReports:
# -- Enables the feature # -- Enables the feature
enabled: true enabled: true
aggregateReports:
# -- Enables the feature
enabled: true
autoUpdateWebhooks: autoUpdateWebhooks:
# -- Enables the feature # -- Enables the feature
enabled: true enabled: true

View file

@ -36,6 +36,7 @@ func createReportControllers(
eng engineapi.Engine, eng engineapi.Engine,
backgroundScan bool, backgroundScan bool,
admissionReports bool, admissionReports bool,
aggregateReports bool,
reportsChunkSize int, reportsChunkSize int,
backgroundScanWorkers int, backgroundScanWorkers int,
client dclient.Interface, client dclient.Interface,
@ -65,18 +66,20 @@ func createReportControllers(
resourceReportController, resourceReportController,
resourcereportcontroller.Workers, resourcereportcontroller.Workers,
)) ))
ctrls = append(ctrls, internal.NewController( if aggregateReports {
aggregatereportcontroller.ControllerName, ctrls = append(ctrls, internal.NewController(
aggregatereportcontroller.NewController( aggregatereportcontroller.ControllerName,
kyvernoClient, aggregatereportcontroller.NewController(
metadataFactory, kyvernoClient,
kyvernoV1.Policies(), metadataFactory,
kyvernoV1.ClusterPolicies(), kyvernoV1.Policies(),
resourceReportController, kyvernoV1.ClusterPolicies(),
reportsChunkSize, resourceReportController,
), reportsChunkSize,
aggregatereportcontroller.Workers, ),
)) aggregatereportcontroller.Workers,
))
}
if admissionReports { if admissionReports {
ctrls = append(ctrls, internal.NewController( ctrls = append(ctrls, internal.NewController(
admissionreportcontroller.ControllerName, admissionreportcontroller.ControllerName,
@ -123,6 +126,7 @@ func createrLeaderControllers(
eng engineapi.Engine, eng engineapi.Engine,
backgroundScan bool, backgroundScan bool,
admissionReports bool, admissionReports bool,
aggregateReports bool,
reportsChunkSize int, reportsChunkSize int,
backgroundScanWorkers int, backgroundScanWorkers int,
kubeInformer kubeinformers.SharedInformerFactory, kubeInformer kubeinformers.SharedInformerFactory,
@ -139,6 +143,7 @@ func createrLeaderControllers(
eng, eng,
backgroundScan, backgroundScan,
admissionReports, admissionReports,
aggregateReports,
reportsChunkSize, reportsChunkSize,
backgroundScanWorkers, backgroundScanWorkers,
dynamicClient, dynamicClient,
@ -158,6 +163,7 @@ func main() {
var ( var (
backgroundScan bool backgroundScan bool
admissionReports bool admissionReports bool
aggregateReports bool
reportsChunkSize int reportsChunkSize int
backgroundScanWorkers int backgroundScanWorkers int
backgroundScanInterval time.Duration backgroundScanInterval time.Duration
@ -168,6 +174,7 @@ func main() {
flagset := flag.NewFlagSet("reports-controller", flag.ExitOnError) flagset := flag.NewFlagSet("reports-controller", flag.ExitOnError)
flagset.BoolVar(&backgroundScan, "backgroundScan", true, "Enable or disable backgound scan.") flagset.BoolVar(&backgroundScan, "backgroundScan", true, "Enable or disable backgound scan.")
flagset.BoolVar(&admissionReports, "admissionReports", true, "Enable or disable admission reports.") flagset.BoolVar(&admissionReports, "admissionReports", true, "Enable or disable admission reports.")
flagset.BoolVar(&aggregateReports, "aggregateReports", true, "Enable or disable aggregated policy reports.")
flagset.IntVar(&reportsChunkSize, "reportsChunkSize", 1000, "Max number of results in generated reports, reports will be split accordingly if there are more results to be stored.") flagset.IntVar(&reportsChunkSize, "reportsChunkSize", 1000, "Max number of results in generated reports, reports will be split accordingly if there are more results to be stored.")
flagset.IntVar(&backgroundScanWorkers, "backgroundScanWorkers", backgroundscancontroller.Workers, "Configure the number of background scan workers.") flagset.IntVar(&backgroundScanWorkers, "backgroundScanWorkers", backgroundscancontroller.Workers, "Configure the number of background scan workers.")
flagset.DurationVar(&backgroundScanInterval, "backgroundScanInterval", time.Hour, "Configure background scan interval.") flagset.DurationVar(&backgroundScanInterval, "backgroundScanInterval", time.Hour, "Configure background scan interval.")
@ -259,6 +266,7 @@ func main() {
engine, engine,
backgroundScan, backgroundScan,
admissionReports, admissionReports,
aggregateReports,
reportsChunkSize, reportsChunkSize,
backgroundScanWorkers, backgroundScanWorkers,
kubeInformer, kubeInformer,

View file

@ -39109,6 +39109,7 @@ spec:
- --otelConfig=prometheus - --otelConfig=prometheus
- --metricsPort=8000 - --metricsPort=8000
- --admissionReports=true - --admissionReports=true
- --aggregateReports=true
- --backgroundScan=true - --backgroundScan=true
- --backgroundScanWorkers=2 - --backgroundScanWorkers=2
- --backgroundScanInterval=1h - --backgroundScanInterval=1h