Skip to content

Commit d37c289

Browse files
committed
feat(helm): add configurable PolicyServer port fields to defaults chart
Adds webhookPort, readinessProbePort, and metricsPort fields under policyServer in values.yaml (defaulting to 0, meaning use the PolicyServer CRD default). The policyserver-default.yaml template conditionally emits these fields when they are non-zero. values.schema.json is updated with integer constraints (0-65535) for the new fields. Helm unit tests verify that zero values are omitted and non-zero values are passed through to the PolicyServer spec. Signed-off-by: José Guilherme Vanz <jguilhermevanz@suse.com> Assisted-by: Github Copilot
1 parent 5300709 commit d37c289

4 files changed

Lines changed: 85 additions & 0 deletions

File tree

charts/kubewarden-defaults/templates/policyserver-default.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,13 @@ spec:
7777
{{- if .Values.policyServer.securityContexts }}
7878
securityContexts: {{ toYaml .Values.policyServer.securityContexts | nindent 4 }}
7979
{{- end }}
80+
{{- if .Values.policyServer.webhookPort }}
81+
webhookPort: {{ .Values.policyServer.webhookPort }}
82+
{{- end }}
83+
{{- if .Values.policyServer.readinessProbePort }}
84+
readinessProbePort: {{ .Values.policyServer.readinessProbePort }}
85+
{{- end }}
86+
{{- if .Values.policyServer.metricsPort }}
87+
metricsPort: {{ .Values.policyServer.metricsPort }}
88+
{{- end }}
8089
{{- end }}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
suite: host-network port configuration for default PolicyServer
2+
templates:
3+
- policyserver-default.yaml
4+
tests:
5+
- it: "should not set port fields by default (zero values are omitted)"
6+
asserts:
7+
- notExists:
8+
path: spec.webhookPort
9+
- notExists:
10+
path: spec.readinessProbePort
11+
- notExists:
12+
path: spec.metricsPort
13+
14+
- it: "should set webhookPort when overridden in values"
15+
set:
16+
policyServer.webhookPort: 9443
17+
asserts:
18+
- equal:
19+
path: spec.webhookPort
20+
value: 9443
21+
22+
- it: "should set readinessProbePort when overridden in values"
23+
set:
24+
policyServer.readinessProbePort: 9081
25+
asserts:
26+
- equal:
27+
path: spec.readinessProbePort
28+
value: 9081
29+
30+
- it: "should set metricsPort when overridden in values"
31+
set:
32+
policyServer.metricsPort: 9080
33+
asserts:
34+
- equal:
35+
path: spec.metricsPort
36+
value: 9080
37+
38+
- it: "should set all port fields when all are overridden"
39+
set:
40+
policyServer.webhookPort: 9443
41+
policyServer.readinessProbePort: 9081
42+
policyServer.metricsPort: 9080
43+
asserts:
44+
- equal:
45+
path: spec.webhookPort
46+
value: 9443
47+
- equal:
48+
path: spec.readinessProbePort
49+
value: 9081
50+
- equal:
51+
path: spec.metricsPort
52+
value: 9080

charts/kubewarden-defaults/values.schema.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@
1212
"minAvailable": {
1313
"type": "string",
1414
"minLength": 1
15+
},
16+
"webhookPort": {
17+
"type": "integer",
18+
"minimum": 0,
19+
"maximum": 65535,
20+
"description": "Port for the PolicyServer webhook listener. 0 means use default (8443)."
21+
},
22+
"readinessProbePort": {
23+
"type": "integer",
24+
"minimum": 0,
25+
"maximum": 65535,
26+
"description": "Port for the PolicyServer readiness probe. 0 means use default (8081)."
27+
},
28+
"metricsPort": {
29+
"type": "integer",
30+
"minimum": 0,
31+
"maximum": 65535,
32+
"description": "Port for the PolicyServer metrics endpoint. 0 means use default (8080)."
1533
}
1634
},
1735
"anyOf": [

charts/kubewarden-defaults/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ policyServer:
186186
# limits and requests, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
187187
limits: {}
188188
requests: {}
189+
# Ports used by the default PolicyServer.
190+
# Override these when hostNetwork is enabled on the controller chart to avoid conflicts with other workloads.
191+
# A value of 0 means "use the PolicyServer default" (8443 for webhook, 8081 for readiness, 8080 for metrics).
192+
webhookPort: 0
193+
readinessProbePort: 0
194+
metricsPort: 0
189195
crdVersion: "policies.kubewarden.io/v1"
190196
recommendedPolicies:
191197
enabled: False

0 commit comments

Comments
 (0)