Loading assets/auto-deploy-app/templates/deployment.yaml +4 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,10 @@ spec: {{- if .Values.initContainers }} initContainers: {{ toYaml .Values.initContainers | indent 8 }} {{- end }} {{- if and (ge .Capabilities.KubeVersion.Major 19) (.Values.topologySpreadConstraints) }} topologySpreadConstraints: {{ toYaml .Values.topologySpreadConstraints | indent 8 }} {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} containers: Loading assets/auto-deploy-app/test/templates/deployment_test.go +51 −7 Original line number Diff line number Diff line Loading @@ -435,6 +435,7 @@ func TestDeploymentTemplate(t *testing.T) { ExpectedTolerations []coreV1.Toleration ExpectedInitContainers []coreV1.Container ExpectedAffinity *coreV1.Affinity ExpectedTopologySpreadConstraints []coreV1.TopologySpreadConstraint }{ { CaseName: "selector", Loading Loading @@ -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()) Loading Loading @@ -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) }) } } Loading assets/auto-deploy-app/values.yaml +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
assets/auto-deploy-app/templates/deployment.yaml +4 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,10 @@ spec: {{- if .Values.initContainers }} initContainers: {{ toYaml .Values.initContainers | indent 8 }} {{- end }} {{- if and (ge .Capabilities.KubeVersion.Major 19) (.Values.topologySpreadConstraints) }} topologySpreadConstraints: {{ toYaml .Values.topologySpreadConstraints | indent 8 }} {{- end }} terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} containers: Loading
assets/auto-deploy-app/test/templates/deployment_test.go +51 −7 Original line number Diff line number Diff line Loading @@ -435,6 +435,7 @@ func TestDeploymentTemplate(t *testing.T) { ExpectedTolerations []coreV1.Toleration ExpectedInitContainers []coreV1.Container ExpectedAffinity *coreV1.Affinity ExpectedTopologySpreadConstraints []coreV1.TopologySpreadConstraint }{ { CaseName: "selector", Loading Loading @@ -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()) Loading Loading @@ -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) }) } } Loading
assets/auto-deploy-app/values.yaml +1 −0 Original line number Diff line number Diff line Loading @@ -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 Loading