Skip to content

Commit f1b0f26

Browse files
committed
feat: set default values for kyverno if activated via env var
On-behalf-of: Radek Schekalla (SAP) <[email protected]> Signed-off-by: Radek Schekalla (SAP) <[email protected]>
1 parent 07e9a3e commit f1b0f26

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

internal/controller/core/cloudorchestrator/controller.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
"os"
89
"strings"
910
"time"
1011

@@ -42,6 +43,43 @@ import (
4243
const (
4344
defaultNamespace string = "openmcp-system" // TODO make this configurable
4445
ControllerName string = "CloudOrchestrator"
46+
47+
envEnableKyvernoDefaultValues string = "ENABLE_KYVERNO_DEFAULT_VALUES"
48+
kyvernoDefaultValues string = `{
49+
"config": {
50+
"excludeGroups": [
51+
"system:nodes"
52+
],
53+
"preserve": false,
54+
"resourceFilters": [
55+
"[*/*,kyverno,*]",
56+
"[*/*,istio-system,*]",
57+
"[*/*,kyma-system,*]",
58+
"[*/*,kube-system,*]",
59+
"[*/*,kube-public,*]",
60+
"[*/*,neo-core,*]"
61+
],
62+
"updateRequestThreshold": 5000,
63+
"webhooks": {
64+
"namespaceSelector": {
65+
"matchExpressions": [
66+
{
67+
"key": "kubernetes.io/metadata.name",
68+
"operator": "NotIn",
69+
"values": [
70+
"kube-system",
71+
"kyverno",
72+
"istio-system",
73+
"kube-public",
74+
"kyma-system",
75+
"neo-core"
76+
]
77+
}
78+
]
79+
}
80+
}
81+
}
82+
}`
4583
)
4684

4785
var (
@@ -367,8 +405,14 @@ func convertToControlPlaneSpec(coSpec *openmcpv1alpha1.CloudOrchestratorSpec, ap
367405
}
368406

369407
if coSpec.Kyverno != nil {
408+
var values *apiextensionsv1.JSON
409+
if os.Getenv(envEnableKyvernoDefaultValues) == "true" {
410+
values = &apiextensionsv1.JSON{Raw: []byte(kyvernoDefaultValues)}
411+
}
412+
370413
controlPlaneSpec.Kyverno = &corev1beta1.KyvernoConfig{
371414
Version: coSpec.Kyverno.Version,
415+
Values: values,
372416
}
373417
}
374418

0 commit comments

Comments
 (0)