Commit 3aeb17e0 authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason
Browse files

Merge branch 'master' into 'master'

feat: affinity support

Closes #64

See merge request gitlab-org/cluster-integration/auto-deploy-image!185
parents 4c145b22 34d63039
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.6.0
version: 2.7.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
@@ -19,6 +19,7 @@
| podAnnotations                | Pod annotations | `{}`                           |
| nodeSelector                  | Node labels for pod assignment | `{}`           |
| tolerations                   | List of node taints to tolerate | `[]`          |
| affinity                      | Node affinity for pod assignment | `{}`          |
| application.track             |             | `stable`                           |
| application.tier              |             | `web`                              |
| application.migrateCommand    | If present, this variable will run as a shell command within an application Container as a Helm pre-upgrade Hook. Intended to run migration commands. | `nil` |
+5 −1
Original line number Diff line number Diff line
@@ -48,6 +48,10 @@ spec:
{{- if .Values.tolerations }}
      tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
      affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
      containers:
      - name: {{ .Chart.Name }}
+6 −0
Original line number Diff line number Diff line
@@ -54,6 +54,12 @@ items:
        tolerations:
{{ toYaml $tolerationsConfig | indent 10 }}
{{- end }}
{{- end }}
{{- with $affinityConfig := default $.Values.affinity $workerConfig.affinity -}}
{{- if $affinityConfig  }}
        affinity:
{{ toYaml $affinityConfig | indent 10 }}
{{- end }}
{{- end }}
        terminationGracePeriodSeconds: {{ $workerConfig.terminationGracePeriodSeconds }}
        containers:
+36 −0
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@ func TestDeploymentTemplate(t *testing.T) {
		ExpectedSelector     *metav1.LabelSelector
		ExpectedNodeSelector map[string]string
		ExpectedTolerations  []coreV1.Toleration
		ExpectedAffinity     *coreV1.Affinity
	}{
		{
			CaseName:        "selector",
@@ -338,6 +339,40 @@ func TestDeploymentTemplate(t *testing.T) {
				},
			},
		},
		{
			CaseName:     "affinity",
			Release:      "production",
			Values: map[string]string{
				"affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key":	  "key1",
				"affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator": "DoesNotExist",
			},
			ExpectedName:     "production",
			ExpectedRelease:  "production",
			ExpectedSelector: &metav1.LabelSelector{
				MatchLabels: map[string]string{
					"app":     "production",
					"release": "production",
					"tier":    "web",
					"track":   "stable",
				},
			},
			ExpectedAffinity: &coreV1.Affinity{
				NodeAffinity: &coreV1.NodeAffinity{
					RequiredDuringSchedulingIgnoredDuringExecution: &coreV1.NodeSelector{
						NodeSelectorTerms: []coreV1.NodeSelectorTerm{
							{
								MatchExpressions: []coreV1.NodeSelectorRequirement{
									{
										Key:      "key1",
										Operator: "DoesNotExist",
									},
								},
							},
						},
					},
				},
			},
		},
	} {
		t.Run(tc.CaseName, func(t *testing.T) {
			namespaceName := "minimal-ruby-app-" + strings.ToLower(random.UniqueId())
@@ -390,6 +425,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.ExpectedAffinity, deployment.Spec.Template.Spec.Affinity)
		})
	}
}
Loading