Skip to content

Commit

Permalink
feat: configurable update strategy (#2036)
Browse files Browse the repository at this point in the history
* feat: configurable update strategy

* feat: backport strategy feature to alpha

* chore: update readme

* test: fixes test issue where it references the wrong struct

* chore: update readme
  • Loading branch information
jessesimpson36 authored Jun 25, 2024
1 parent fd64f25 commit 70f5232
Show file tree
Hide file tree
Showing 49 changed files with 1,023 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ metadata:
annotations: {{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: {{ .Values.connectors.replicas }}
{{- if .Values.connectors.strategy }}
strategy:
{{- .Values.connectors.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels: {{- include "connectors.matchLabels" . | nindent 6 }}
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ metadata:
{{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: {{ .Values.console.replicas }}
{{- if .Values.console.strategy }}
strategy:
{{- .Values.console.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "console.matchLabels" . | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ metadata:
annotations: {{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: 1
{{- if .Values.identity.strategy }}
strategy:
{{- .Values.identity.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels: {{- include "identity.matchLabels" . | nindent 6 }}
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ metadata:
{{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: 1
{{- if .Values.operate.strategy }}
strategy:
{{- .Values.operate.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "operate.matchLabels" . | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ metadata:
{{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: 1
strategy:
{{- .Values.optimize.strategy | toYaml | nindent 4 }}
selector:
matchLabels:
{{- include "optimize.matchLabels" . | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ metadata:
{{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: 1
{{- if .Values.tasklist.strategy }}
strategy:
{{- .Values.tasklist.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "tasklist.matchLabels" . | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ metadata:
annotations: {{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: 1
{{- if .Values.webModeler.restapi.strategy }}
strategy:
{{- .Values.webModeler.restapi.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels: {{- include "webModeler.restapi.matchLabels" . | nindent 6 }}
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ metadata:
annotations: {{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: 1
{{- if .Values.webModeler.webapp.strategy }}
strategy:
{{- .Values.webModeler.webapp.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels: {{- include "webModeler.webapp.matchLabels" . | nindent 6 }}
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ metadata:
annotations: {{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: 1
{{- if .Values.webModeler.websockets.strategy }}
strategy:
{{- .Values.webModeler.websockets.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels: {{- include "webModeler.websockets.matchLabels" . | nindent 6 }}
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ metadata:
{{- toYaml .Values.global.annotations | nindent 4 }}
spec:
replicas: {{ .Values.zeebeGateway.replicas }}
{{- if .Values.zeebeGateway.strategy }}
strategy:
{{- .Values.zeebeGateway.strategy | toYaml | nindent 4 }}
{{- end }}
selector:
matchLabels:
{{- include "zeebe.matchLabels.gateway" . | nindent 6 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
{{- include "zeebe.matchLabels.broker" . | nindent 6 }}
serviceName: {{ include "zeebe.names.broker" . }}
updateStrategy:
type: RollingUpdate
{{- .Values.zeebe.strategy | toYaml | nindent 4 }}
podManagementPolicy: Parallel
template:
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,42 @@ func (s *deploymentTemplateTest) TestContainerSetInitContainer() {

s.Require().Contains(podContainers, expectedContainer)
}

func (s *deploymentTemplateTest) TestDefaultStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal("", string(strategy.Type))

}

func (s *deploymentTemplateTest) TestDefinedStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{
"connectors.strategy.type": "Recreate",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal("Recreate", string(strategy.Type))
}
42 changes: 42 additions & 0 deletions charts/camunda-platform-alpha/test/unit/console/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,3 +775,45 @@ func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}

func (s *deploymentTemplateTest) TestDefaultStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{
"console.enabled": "true",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal("", string(strategy.Type))

}

func (s *deploymentTemplateTest) TestDefinedStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{
"console.enabled": "true",
"console.strategy.type": "Recreate",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal("Recreate", string(strategy.Type))
}
Original file line number Diff line number Diff line change
Expand Up @@ -1111,3 +1111,42 @@ func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}

func (s *deploymentTemplateTest) TestDefaultStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal("", string(strategy.Type))

}

func (s *deploymentTemplateTest) TestDefinedStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{
"identity.strategy.type": "Recreate",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal("Recreate", string(strategy.Type))
}
38 changes: 38 additions & 0 deletions charts/camunda-platform-alpha/test/unit/operate/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,41 @@ func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}

func (s *deploymentTemplateTest) TestDefaultStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal(string(strategy.Type), "")
}

func (s *deploymentTemplateTest) TestDefinedStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{
"operate.strategy.type": "Recreate",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal(string(strategy.Type), "Recreate")
}
Original file line number Diff line number Diff line change
Expand Up @@ -928,3 +928,41 @@ func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {

require.Equal(s.T(), expectedDNSConfig, deployment.Spec.Template.Spec.DNSConfig, "dnsConfig should match the expected configuration")
}

func (s *deploymentTemplateTest) TestDefaultStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal(string(strategy.Type), "Recreate")
}

func (s *deploymentTemplateTest) TestDefinedStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{
"optimize.strategy.type": "RollingUpdate",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal(string(strategy.Type), "RollingUpdate")
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ metadata:
{}
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: camunda-platform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,43 @@ func (s *deploymentTemplateTest) TestTasklistWithLog4j2Configuration() {
s.Require().Equal("config", volume.Name)
s.Require().Equal("camunda-platform-test-tasklist-configuration", volume.ConfigMap.Name)
}
func (s *deploymentTemplateTest) TestDefaultStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal(string(strategy.Type), "")
}

func (s *deploymentTemplateTest) TestDefinedStrategy() {
// given
options := &helm.Options{
SetValues: map[string]string{
"tasklist.strategy.type": "Recreate",
},
KubectlOptions: k8s.NewKubectlOptions("", "", s.namespace),
}

// when
output := helm.RenderTemplate(s.T(), options, s.chartPath, s.release, s.templates)
var deployment appsv1.Deployment
helm.UnmarshalK8SYaml(s.T(), output, &deployment)

// then
strategy := deployment.Spec.Strategy

s.Require().Equal(string(strategy.Type), "Recreate")
}
func (s *deploymentTemplateTest) TestSetDnsPolicyAndDnsConfig() {
// given
options := &helm.Options{
Expand Down
Loading

0 comments on commit 70f5232

Please sign in to comment.