diff --git a/charts/onechart/templates/ingress.yaml b/charts/onechart/templates/ingress.yaml index 7ba8953..2a53ef7 100644 --- a/charts/onechart/templates/ingress.yaml +++ b/charts/onechart/templates/ingress.yaml @@ -38,7 +38,7 @@ spec: paths: - backend: serviceName: {{ $robustName }} - servicePort: {{ .root.Values.containerPort }} + servicePort: {{ if .root.Values.svcPort }}{{ .root.Values.svcPort }}{{ else }}{{ .root.Values.containerPort }}{{ end }} {{- end }} {{- with .Values.ingress }} diff --git a/charts/onechart/tests/ingress_port_test.yaml b/charts/onechart/tests/ingress_port_test.yaml new file mode 100644 index 0000000..8ed4d0c --- /dev/null +++ b/charts/onechart/tests/ingress_port_test.yaml @@ -0,0 +1,23 @@ +suite: test deployment +templates: + - ingress.yaml +tests: + - it: Should use container port + set: + ingress: + host: chart-example.local + containerPort: 1234 + asserts: + - equal: + path: spec.rules[0].http.paths[0].backend.servicePort + value: 1234 + - it: Should use service port + set: + ingress: + host: chart-example.local + svcPort: 1234 + containerPort: 5678 + asserts: + - equal: + path: spec.rules[0].http.paths[0].backend.servicePort + value: 1234