This is an automated email from the ASF dual-hosted git repository.
adutra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 01a87998 (fix): add conditional for nodePort check (#984)
01a87998 is described below
commit 01a87998b5427edc402ad3bb37765ee36cd34434
Author: Kamesh Sampath <[email protected]>
AuthorDate: Tue Feb 18 15:51:27 2025 +0530
(fix): add conditional for nodePort check (#984)
---
helm/polaris/templates/service.yaml | 2 +-
helm/polaris/tests/service_test.yaml | 86 ++++++++++++++++++++++++++++++++++--
2 files changed, 83 insertions(+), 5 deletions(-)
diff --git a/helm/polaris/templates/service.yaml
b/helm/polaris/templates/service.yaml
index a44486a0..41166010 100644
--- a/helm/polaris/templates/service.yaml
+++ b/helm/polaris/templates/service.yaml
@@ -39,7 +39,7 @@ spec:
{{- if .targetPort }}
targetPort: {{ .targetPort }}
{{- end }}
- {{- if .nodePort }}
+ {{- if and (eq $.Values.service.type "NodePort") .nodePort }}
nodePort: {{ .nodePort }}
{{- end }}
protocol: {{ default "TCP" .protocol }}
diff --git a/helm/polaris/tests/service_test.yaml
b/helm/polaris/tests/service_test.yaml
index 41ff599f..d6d2e5be 100644
--- a/helm/polaris/tests/service_test.yaml
+++ b/helm/polaris/tests/service_test.yaml
@@ -29,7 +29,6 @@ templates:
- service.yaml
tests:
-
# metadata.name
- it: should set service name
asserts:
@@ -142,7 +141,6 @@ tests:
- port: 28181
targetPort: 28181
name: polaris-http2
- nodePort: 28181
protocol: UDP
asserts:
- equal:
@@ -155,8 +153,89 @@ tests:
- port: 28181
targetPort: 28181
name: polaris-http2
- nodePort: 28181
protocol: UDP
+ # node port
+ - it: should set nodeport only when service type is NodePort
+ set:
+ service:
+ type: NodePort
+ ports:
+ - port: 18181
+ targetPort: 18181
+ nodePort: 30081
+ name: polaris-http
+ asserts:
+ - equal:
+ path: spec.type
+ value: NodePort
+ - equal:
+ path: spec.ports
+ value:
+ - port: 18181
+ targetPort: 18181
+ protocol: TCP
+ name: polaris-http
+ nodePort: 30081
+ - it: should not set nodeport type is NodePort and nodePort value is empty
+ set:
+ service:
+ type: NodePort
+ ports:
+ - port: 18181
+ targetPort: 18181
+ name: polaris-http
+ asserts:
+ - equal:
+ path: spec.type
+ value: NodePort
+ - equal:
+ path: spec.ports
+ value:
+ - port: 18181
+ targetPort: 18181
+ protocol: TCP
+ name: polaris-http
+
+ - it: should set node port only if service type is NodePort
+ set:
+ service:
+ type: NodePort
+ ports:
+ - port: 18181
+ targetPort: 18181
+ nodePort: 30081
+ name: polaris-http
+ asserts:
+ - equal:
+ path: spec.type
+ value: NodePort
+ - equal:
+ path: spec.ports
+ value:
+ - port: 18181
+ targetPort: 18181
+ protocol: TCP
+ name: polaris-http
+ nodePort: 30081
+ - it: should not set node port if service type is NodePort and nodePort is
empty
+ set:
+ service:
+ type: NodePort
+ ports:
+ - port: 18181
+ targetPort: 18181
+ name: polaris-http
+ asserts:
+ - equal:
+ path: spec.type
+ value: NodePort
+ - equal:
+ path: spec.ports
+ value:
+ - port: 18181
+ targetPort: 18181
+ protocol: TCP
+ name: polaris-http
# spec.sessionAffinity
- it: should not set service session affinity by default
@@ -184,7 +263,6 @@ tests:
path: spec.clusterIP
value: 1.2.3.4
-
# spec.externalTrafficPolicy
- it: should not set service external traffic policy by default
asserts: