From ec98a9d3edc2a08701231e3d11fc528bd7a0405b Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Wed, 7 Apr 2021 14:27:17 +0200 Subject: [PATCH] containerPortYaml to allow exotic port setups --- charts/onechart/Chart.yaml | 2 +- charts/onechart/templates/deployment.yaml | 4 ++ .../deployment_contianer_port_yaml_test.yaml | 44 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 charts/onechart/tests/deployment_contianer_port_yaml_test.yaml diff --git a/charts/onechart/Chart.yaml b/charts/onechart/Chart.yaml index d18ea9f..b1afe81 100644 --- a/charts/onechart/Chart.yaml +++ b/charts/onechart/Chart.yaml @@ -15,4 +15,4 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.17.0 +version: 0.18.0 diff --git a/charts/onechart/templates/deployment.yaml b/charts/onechart/templates/deployment.yaml index 790c8a8..506f55d 100644 --- a/charts/onechart/templates/deployment.yaml +++ b/charts/onechart/templates/deployment.yaml @@ -54,9 +54,13 @@ spec: {{- end }} {{- end }} ports: + {{- if not .Values.containerPortYaml }} - name: http containerPort: {{ .Values.containerPort }} protocol: TCP + {{ else }} + {{- toYaml .Values.containerPortYaml | nindent 12 }} + {{- end }} {{- if .Values.probe.enabled }} readinessProbe: httpGet: diff --git a/charts/onechart/tests/deployment_contianer_port_yaml_test.yaml b/charts/onechart/tests/deployment_contianer_port_yaml_test.yaml new file mode 100644 index 0000000..eee4f22 --- /dev/null +++ b/charts/onechart/tests/deployment_contianer_port_yaml_test.yaml @@ -0,0 +1,44 @@ +suite: test deployment +templates: + - deployment.yaml + - configmap.yaml +tests: + - it: Should set custom ports + set: + containerPortYaml: + - port: 21 + targetPort: ftp + protocol: TCP + name: ftp + - port: 3001 + targetPort: passive-1 + protocol: TCP + name: passive-1 + - port: 3002 + targetPort: passive-2 + protocol: TCP + name: passive-2 + asserts: + - equal: + path: spec.template.spec.containers[0].ports + value: + - port: 21 + targetPort: ftp + protocol: TCP + name: ftp + - port: 3001 + targetPort: passive-1 + protocol: TCP + name: passive-1 + - port: 3002 + targetPort: passive-2 + protocol: TCP + name: passive-2 + - it: Should set default port + asserts: + - equal: + path: spec.template.spec.containers[0].ports + value: + - name: http + containerPort: 80 + protocol: TCP