Commit 9d3fd1d6 authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason
Browse files

Merge branch 'continue-feature-add-topologyspreadconstraints' into 'master'

Continue feature add topologyspreadconstraints

See merge request gitlab-org/cluster-integration/auto-deploy-image!247
parents a658bed6 a6babdcd
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.20.0
version: 2.21.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
@@ -25,6 +25,7 @@
| tolerations                   | List of node taints to tolerate | `[]`          |
| terminationGracePeriodSeconds | The amount of time in seconds a pod is given to terminate | [See the Kubernetes API for reference](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#lifecycle)          |
| initContainers                | Containers that are run before the app containers are started. | `[]`          |
| topologySpreadConstraints     | [Pod Topology Spread Constraints](https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/) | `[]`          |
| affinity                      | Node affinity for pod assignment | `{}`          |
| application.track             |             | `stable`                           |
| application.tier              |             | `web`                              |
+4 −0
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@ spec:
{{- if .Values.initContainers }}
      initContainers:
{{ toYaml .Values.initContainers | indent 8 }}
{{- end }}
{{- if and (semverCompare ">= 1.19.x" .Capabilities.KubeVersion.Version) (.Values.topologySpreadConstraints) }}
      topologySpreadConstraints:
{{ toYaml .Values.topologySpreadConstraints | indent 8 }}
{{- end }}
      terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}
      containers:
+51 −7
Original line number Diff line number Diff line
@@ -435,6 +435,7 @@ func TestDeploymentTemplate(t *testing.T) {
		ExpectedTolerations               []coreV1.Toleration
		ExpectedInitContainers            []coreV1.Container
		ExpectedAffinity                  *coreV1.Affinity
		ExpectedTopologySpreadConstraints []coreV1.TopologySpreadConstraint
	}{
		{
			CaseName:        "selector",
@@ -561,6 +562,48 @@ func TestDeploymentTemplate(t *testing.T) {
				},
			},
		},
		{
			CaseName: "topologySpreadConstraints",
			Release:  "production",
			Values: map[string]string{
				"topologySpreadConstraints[0].maxSkew":                                     "1",
				"topologySpreadConstraints[0].topologyKey":                                 "zone",
				"topologySpreadConstraints[0].whenUnsatisfiable":                           "DoNotSchedule",
				"topologySpreadConstraints[0].labelSelector.matchLabels.foo":               "bar",
				"topologySpreadConstraints[0].labelSelector.matchExpressions[0].key":       "key1",
				"topologySpreadConstraints[0].labelSelector.matchExpressions[0].operator":  "DoesNotExist",
				"topologySpreadConstraints[0].labelSelector.matchExpressions[0].values[0]": "value1",
			},
			ExpectedName:    "production",
			ExpectedRelease: "production",
			ExpectedSelector: &metav1.LabelSelector{
				MatchLabels: map[string]string{
					"app":     "production",
					"release": "production",
					"tier":    "web",
					"track":   "stable",
				},
			},
			ExpectedTopologySpreadConstraints: []coreV1.TopologySpreadConstraint{
				{
					MaxSkew:           1,
					TopologyKey:       "zone",
					WhenUnsatisfiable: "DoNotSchedule",
					LabelSelector: &metav1.LabelSelector{
						MatchLabels: map[string]string{
							"foo": "bar",
						},
						MatchExpressions: []metav1.LabelSelectorRequirement{
							{
								Key:      "key1",
								Operator: "DoesNotExist",
								Values:   []string{"value1"},
							},
						},
					},
				},
			},
		},
	} {
		t.Run(tc.CaseName, func(t *testing.T) {
			namespaceName := "minimal-ruby-app-" + strings.ToLower(random.UniqueId())
@@ -615,6 +658,7 @@ func TestDeploymentTemplate(t *testing.T) {
			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)
			require.Equal(t, tc.ExpectedTopologySpreadConstraints, deployment.Spec.Template.Spec.TopologySpreadConstraints)
		})
	}
}
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ initContainers: []
# - name: init-myservice
#   image: busybox
#   command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice to start; sleep 1; done;']
topologySpreadConstraints: []
application:
  track: stable
  tier: web