Skip to content

Commit 8859a7f

Browse files
author
Duc Thang Tran
committed
feat: adding auth secret for terraform controller and terraform job to pull priate images
1 parent 0845592 commit 8859a7f

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

chart/templates/terraform_controller.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ spec:
2020
- name: terraform-controller
2121
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
2222
imagePullPolicy: {{ .Values.image.pullPolicy }}
23+
{{- if .Values.authSecretName }}
24+
imagePullSecrets:
25+
- name: {{ .Values.authSecretName }}
26+
{{- end }}
2327
args:
2428
{{- if .Values.controllerNamespace }}
2529
- --controller-namespace={{ .Values.controllerNamespace }}
@@ -38,6 +42,10 @@ spec:
3842
value: {{ .Values.busyboxImage}}
3943
- name: GIT_IMAGE
4044
value: {{ .Values.gitImage}}
45+
{{- if .Values.jobAuthSecret }}
46+
- name: JOB_AUTH_SECRET
47+
value: {{ .Values.jobAuthSecret }}
48+
{{- end }}
4149
- name: GITHUB_BLOCKED
4250
value: {{ .Values.githubBlocked }}
4351
{{ if .Values.jobBackoffLimit }}

chart/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ busyboxImage: busybox:latest
1010
terraformImage: oamdev/docker-terraform:1.1.5
1111
controllerNamespace: ""
1212

13+
authSecretName: ""
14+
jobAuthSecret: ""
15+
1316
# "{\"nat\": \"true\"}"
1417
jobNodeSelector: ""
1518
jobBackoffLimit: ""

controllers/configuration_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ func (r *ConfigurationReconciler) preCheck(ctx context.Context, configuration *v
373373
}
374374
}
375375

376+
meta.JobAuthSecret = os.Getenv("JOB_AUTH_SECRET")
377+
376378
if err := r.preCheckResourcesSetting(meta); err != nil {
377379
return err
378380
}

controllers/process/meta.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ type TFConfigurationMeta struct {
5757
BusyboxImage string
5858
GitImage string
5959

60+
// JobAuthSecret is the secret name for pulling image in the Terraform job
61+
JobAuthSecret string
62+
6063
// BackoffLimit specifies the number of retries to mark the Job as failed
6164
BackoffLimit int32
6265

controllers/process/process.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ func (meta *TFConfigurationMeta) assembleTerraformJob(executionType types.Terraf
328328
Volumes: executorVolumes,
329329
RestartPolicy: v1.RestartPolicyOnFailure,
330330
NodeSelector: meta.JobNodeSelector,
331+
ImagePullSecrets: []v1.LocalObjectReference{{Name: meta.JobAuthSecret}},
331332
},
332333
},
333334
},

0 commit comments

Comments
 (0)