Commit 9aa25a50 authored by Gavin Astur's avatar Gavin Astur Committed by Shinya Maeda
Browse files

feat: initContainers support

parent 3c9c8070
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.13.0
version: 2.14.0
icon: https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-square.png
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
| podAnnotations                | Pod annotations | `{}`                           |
| nodeSelector                  | Node labels for pod assignment | `{}`           |
| tolerations                   | List of node taints to tolerate | `[]`          |
| initContainers                | Containers that are run before the app containers are started. | `[]`          |
| affinity                      | Node affinity for pod assignment | `{}`          |
| application.track             |             | `stable`                           |
| application.tier              |             | `web`                              |
+4 −0
Original line number Diff line number Diff line
@@ -52,6 +52,10 @@ spec:
{{- if .Values.affinity }}
      affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.initContainers }}
      initContainers:
{{ toYaml .Values.initContainers | indent 8 }}
{{- end }}
      containers:
      - name: {{ .Chart.Name }}
+6 −0
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ items:
        affinity:
{{ toYaml $affinityConfig | indent 10 }}
{{- end }}
{{- end }}
{{- with $initContainersConfig := default $.Values.initContainers $workerConfig.initContainers -}}
{{- if $initContainersConfig  }}
        initContainers:
{{ toYaml $initContainersConfig | indent 10 }}
{{- end }}
{{- end }}
        terminationGracePeriodSeconds: {{ $workerConfig.terminationGracePeriodSeconds }}
        containers:
+37 −6
Original line number Diff line number Diff line
@@ -433,6 +433,7 @@ func TestDeploymentTemplate(t *testing.T) {
		ExpectedSelector       *metav1.LabelSelector
		ExpectedNodeSelector   map[string]string
		ExpectedTolerations    []coreV1.Toleration
		ExpectedInitContainers []coreV1.Container
		ExpectedAffinity       *coreV1.Affinity
	}{
		{
@@ -497,6 +498,35 @@ func TestDeploymentTemplate(t *testing.T) {
				},
			},
		},
		{
			CaseName: "initContainers",
			Release:  "production",
			Values: map[string]string{
				"initContainers[0].name":       "myservice",
				"initContainers[0].image":      "myimage:1",
				"initContainers[0].command[0]": "sh",
				"initContainers[0].command[1]": "-c",
				"initContainers[0].command[2]": "until nslookup myservice; do echo waiting for myservice to start; sleep 1; done;",
			},

			ExpectedName:    "production",
			ExpectedRelease: "production",
			ExpectedSelector: &metav1.LabelSelector{
				MatchLabels: map[string]string{
					"app":     "production",
					"release": "production",
					"tier":    "web",
					"track":   "stable",
				},
			},
			ExpectedInitContainers: []coreV1.Container{
				{
					Name:    "myservice",
					Image:   "myimage:1",
					Command: []string{"sh", "-c", "until nslookup myservice; do echo waiting for myservice to start; sleep 1; done;"},
				},
			},
		},
		{
			CaseName: "affinity",
			Release:  "production",
@@ -583,6 +613,7 @@ func TestDeploymentTemplate(t *testing.T) {

			require.Equal(t, tc.ExpectedNodeSelector, deployment.Spec.Template.Spec.NodeSelector)
			require.Equal(t, tc.ExpectedTolerations, deployment.Spec.Template.Spec.Tolerations)
			require.Equal(t, tc.ExpectedInitContainers, deployment.Spec.Template.Spec.InitContainers)
			require.Equal(t, tc.ExpectedAffinity, deployment.Spec.Template.Spec.Affinity)
		})
	}
Loading