Commit a658bed6 authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason
Browse files

Merge branch 'feature/enable_multiple_service_ports' into 'master'

Feature/enable multiple service ports

Closes #85

See merge request gitlab-org/cluster-integration/auto-deploy-image!194
parents 0933a5ca dd6ea6a3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
apiVersion: v1
description: GitLab's Auto-deploy Helm Chart
name: auto-deploy-app
version: 2.19.0
version: 2.20.0
icon: https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-square.png
+5 −0
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@
| service.commonName            | If present, this will define the ssl certificate common name to be used by CertManager. `service.url` and `service.additionalHosts` will be added as Subject Alternative Names (SANs) | `nil` |
| service.externalPort          |             | `5000`                             |
| service.internalPort          |             | `5000`                             |
| service.extraPorts        | List of additional service port definitions | `[]` |
| service.extraPorts.port   | Integer external port number | `nil` |
| service.extraPorts.targetPort | Integer container port number | `nil` |
| service.extraPorts.protocol | Protocol of the service port definition | `nil` |
| service.extraPorts.name | Name of the service port definition | `nil` |
| ingress.enabled               | If true, enables ingress | `true`                |
| ingress.path                  | Default path for the ingress | `/` |
| ingress.tls.enabled           | If true, enables SSL | `true`                    |
+9 −0
Original line number Diff line number Diff line
@@ -98,6 +98,15 @@ spec:
        ports:
        - name: "{{ .Values.service.name }}"
          containerPort: {{ .Values.service.internalPort }}
{{- if .Values.service.extraPorts }}
{{- range $servicePort := .Values.service.extraPorts }}
        - name: {{ $servicePort.name }}
          containerPort: {{ $servicePort.targetPort }}
          {{- if $servicePort.protocol }}
          protocol: {{ $servicePort.protocol }} 
          {{- end }}
{{- end }}
{{- end }}
        livenessProbe:
{{- if eq .Values.livenessProbe.probeType "httpGet" }}
          httpGet:
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ spec:
    name: {{ .Values.service.name }}
{{- if eq .Values.service.type "NodePort" }}
    nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- if .Values.service.extraPorts }}
{{ toYaml .Values.service.extraPorts | indent 2 }}
{{- end }}
  selector:
    app: {{ template "appname" . }}
+48 −0
Original line number Diff line number Diff line
@@ -618,3 +618,51 @@ func TestDeploymentTemplate(t *testing.T) {
		})
	}
}

func TestServiceExtraPortServicePortDefinition(t *testing.T) {
	releaseName := "deployment-extra-ports-service-port-definition-test"
	templates := []string{"templates/deployment.yaml"}

	tcs := []struct {
		name   string
		values map[string]string
		valueFiles []string
		expectedPorts []coreV1.ContainerPort
		expectedErrorRegexp *regexp.Regexp
	}{
		{
			name:                "with extra ports service port",
			valueFiles:  []string{"../testdata/service-definition.yaml"},
			expectedPorts: []coreV1.ContainerPort{
				coreV1.ContainerPort {
					Name: "web",
					ContainerPort: 5000,
				},
				coreV1.ContainerPort {
					Name: "port-443",
					ContainerPort: 443,
					Protocol: "TCP",
				},
			},
		},
	}

	for _, tc := range tcs {
		t.Run(tc.name, func(t *testing.T) {
			opts := &helm.Options{
				ValuesFiles: tc.valueFiles,
				SetValues:   tc.values,
			}
			output, err := helm.RenderTemplateE(t, opts, helmChartPath, releaseName, templates)

			if err != nil {
				t.Error(err)
				return
			}

			deployment := new(appsV1.Deployment)
			helm.UnmarshalK8SYaml(t, output, deployment)
			require.Equal(t, tc.expectedPorts, deployment.Spec.Template.Spec.Containers[0].Ports)
		})
	}
}
Loading