Skip to content

Commit 8bef9d0

Browse files
authored
fix: set service account on orchestration migration jobs (#5973)
1 parent 77145ba commit 8bef9d0

6 files changed

Lines changed: 66 additions & 0 deletions

File tree

charts/camunda-platform-8.8/templates/orchestration/migration-data-job.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ spec:
1616
checksum/env-vars: {{ include (print $.Template.BasePath "/orchestration/migration-data-configmap-env-vars.yaml") . | sha256sum }}
1717
spec:
1818
restartPolicy: OnFailure
19+
serviceAccountName: {{ include "orchestration.serviceAccountName" . }}
1920
imagePullSecrets: {{- include "orchestration.imagePullSecrets" . | nindent 8 }}
2021
{{- if .Values.orchestration.podSecurityContext }}
2122
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.orchestration.podSecurityContext "context" $) | nindent 8 }}

charts/camunda-platform-8.8/templates/orchestration/migration-identity-job.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spec:
1515
checksum/config: {{ include (print $.Template.BasePath "/orchestration/migration-identity-configmap.yaml") . | sha256sum }}
1616
spec:
1717
restartPolicy: OnFailure
18+
serviceAccountName: {{ include "orchestration.serviceAccountName" . }}
1819
imagePullSecrets: {{- include "orchestration.imagePullSecrets" . | nindent 8 }}
1920
{{- if .Values.orchestration.podSecurityContext }}
2021
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.orchestration.podSecurityContext "context" $) | nindent 8 }}

charts/camunda-platform-8.8/test/unit/orchestration/golden/migration-data-job.golden.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ spec:
2929
annotations:
3030
spec:
3131
restartPolicy: OnFailure
32+
serviceAccountName: camunda-platform-test-zeebe
3233
imagePullSecrets:
3334
[]
3435
securityContext:

charts/camunda-platform-8.8/test/unit/orchestration/golden/migration-identity-job.golden.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ spec:
2929
annotations:
3030
spec:
3131
restartPolicy: OnFailure
32+
serviceAccountName: camunda-platform-test-zeebe
3233
imagePullSecrets:
3334
[]
3435
securityContext:

charts/camunda-platform-8.8/test/unit/orchestration/migration_data_job_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,33 @@ func (s *MigrationDataJobTest) TestCustomTrustStoreConfiguration() {
319319

320320
testhelpers.RunTestCasesE(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
321321
}
322+
323+
func (s *MigrationDataJobTest) TestServiceAccount() {
324+
testCases := []testhelpers.TestCase{
325+
{
326+
Name: "TestServiceAccountDefault",
327+
Values: map[string]string{
328+
"orchestration.migration.data.enabled": "true",
329+
},
330+
Verifier: func(t *testing.T, output string, err error) {
331+
var job batchv1.Job
332+
helm.UnmarshalK8SYaml(s.T(), output, &job)
333+
s.Require().Equal("camunda-platform-test-zeebe", job.Spec.Template.Spec.ServiceAccountName)
334+
},
335+
},
336+
{
337+
Name: "TestServiceAccountCustomName",
338+
Values: map[string]string{
339+
"orchestration.migration.data.enabled": "true",
340+
"orchestration.serviceAccount.name": "custom-sa",
341+
},
342+
Verifier: func(t *testing.T, output string, err error) {
343+
var job batchv1.Job
344+
helm.UnmarshalK8SYaml(s.T(), output, &job)
345+
s.Require().Equal("custom-sa", job.Spec.Template.Spec.ServiceAccountName)
346+
},
347+
},
348+
}
349+
350+
testhelpers.RunTestCasesE(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
351+
}

charts/camunda-platform-8.8/test/unit/orchestration/migration_identity_job_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,35 @@ func (s *MigrationIdentityJobTest) TestDifferentValuesInputs() {
158158

159159
testhelpers.RunTestCasesE(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
160160
}
161+
162+
func (s *MigrationIdentityJobTest) TestServiceAccount() {
163+
testCases := []testhelpers.TestCase{
164+
{
165+
Name: "TestServiceAccountDefault",
166+
Values: map[string]string{
167+
"orchestration.migration.identity.enabled": "true",
168+
"orchestration.migration.identity.secret.inlineSecret": "very-secret-thus-plaintext",
169+
},
170+
Verifier: func(t *testing.T, output string, err error) {
171+
var job batchv1.Job
172+
helm.UnmarshalK8SYaml(s.T(), output, &job)
173+
s.Require().Equal("camunda-platform-test-zeebe", job.Spec.Template.Spec.ServiceAccountName)
174+
},
175+
},
176+
{
177+
Name: "TestServiceAccountCustomName",
178+
Values: map[string]string{
179+
"orchestration.migration.identity.enabled": "true",
180+
"orchestration.migration.identity.secret.inlineSecret": "very-secret-thus-plaintext",
181+
"orchestration.serviceAccount.name": "custom-sa",
182+
},
183+
Verifier: func(t *testing.T, output string, err error) {
184+
var job batchv1.Job
185+
helm.UnmarshalK8SYaml(s.T(), output, &job)
186+
s.Require().Equal("custom-sa", job.Spec.Template.Spec.ServiceAccountName)
187+
},
188+
},
189+
}
190+
191+
testhelpers.RunTestCasesE(s.T(), s.chartPath, s.release, s.namespace, s.templates, testCases)
192+
}

0 commit comments

Comments
 (0)