Skip to content

Commit a647bc1

Browse files
authored
Chart: Implement controller.admissionWebhooks.service.servicePort. (#11931)
1 parent e9259af commit a647bc1

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

charts/ingress-nginx/templates/admission-webhooks/validating-webhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ webhooks:
4040
service:
4141
name: {{ include "ingress-nginx.controller.fullname" . }}-admission
4242
namespace: {{ include "ingress-nginx.namespace" . }}
43+
port: {{ .Values.controller.admissionWebhooks.service.servicePort }}
4344
path: /networking/v1/ingresses
4445
{{- if .Values.controller.admissionWebhooks.timeoutSeconds }}
4546
timeoutSeconds: {{ .Values.controller.admissionWebhooks.timeoutSeconds }}

charts/ingress-nginx/templates/controller-service-webhook.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ spec:
2929
{{- end }}
3030
ports:
3131
- name: https-webhook
32-
port: 443
32+
port: {{ .Values.controller.admissionWebhooks.service.servicePort }}
3333
targetPort: webhook
3434
{{- if semverCompare ">=1.20.0-0" .Capabilities.KubeVersion.Version }}
3535
appProtocol: https
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
suite: Admission Webhooks > ValidatingWebhookConfiguration
2+
templates:
3+
- admission-webhooks/validating-webhook.yaml
4+
5+
tests:
6+
- it: should not create a ValidatingWebhookConfiguration if `controller.admissionWebhooks.enabled` is false
7+
set:
8+
controller.admissionWebhooks.enabled: false
9+
asserts:
10+
- hasDocuments:
11+
count: 0
12+
13+
- it: should create a ValidatingWebhookConfiguration if `controller.admissionWebhooks.enabled` is true
14+
set:
15+
controller.admissionWebhooks.enabled: true
16+
asserts:
17+
- hasDocuments:
18+
count: 1
19+
- isKind:
20+
of: ValidatingWebhookConfiguration
21+
- equal:
22+
path: metadata.name
23+
value: RELEASE-NAME-admission
24+
25+
- it: should create a ValidatingWebhookConfiguration with a custom port if `controller.admissionWebhooks.service.servicePort` is set
26+
set:
27+
controller.admissionWebhooks.enabled: true
28+
controller.admissionWebhooks.service.servicePort: 9443
29+
asserts:
30+
- equal:
31+
path: webhooks[0].clientConfig.service.port
32+
value: 9443
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
suite: Controller > Service > Webhook
2+
templates:
3+
- controller-service-webhook.yaml
4+
5+
tests:
6+
- it: should not create a webhook Service if `controller.admissionWebhooks.enabled` is false
7+
set:
8+
controller.admissionWebhooks.enabled: false
9+
asserts:
10+
- hasDocuments:
11+
count: 0
12+
13+
- it: should create a webhook Service if `controller.admissionWebhooks.enabled` is true
14+
set:
15+
controller.admissionWebhooks.enabled: true
16+
asserts:
17+
- hasDocuments:
18+
count: 1
19+
- isKind:
20+
of: Service
21+
- equal:
22+
path: metadata.name
23+
value: RELEASE-NAME-ingress-nginx-controller-admission
24+
25+
- it: should create a webhook Service with a custom port if `controller.admissionWebhooks.service.servicePort` is set
26+
set:
27+
controller.admissionWebhooks.enabled: true
28+
controller.admissionWebhooks.service.servicePort: 9443
29+
asserts:
30+
- equal:
31+
path: spec.ports[0].port
32+
value: 9443

0 commit comments

Comments
 (0)