From 2fa949bd11cd8441ebabf7f55a75f4893af7f312 Mon Sep 17 00:00:00 2001 From: zhesihuang Date: Sat, 16 Nov 2019 17:19:50 +0800 Subject: [PATCH] Add svc hosts volumeMount for InitContainers --- pkg/controllers/job/plugins/svc/svc.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/controllers/job/plugins/svc/svc.go b/pkg/controllers/job/plugins/svc/svc.go index 561a1166ee..7297b92cd6 100644 --- a/pkg/controllers/job/plugins/svc/svc.go +++ b/pkg/controllers/job/plugins/svc/svc.go @@ -112,14 +112,17 @@ func (sp *servicePlugin) mountConfigmap(pod *v1.Pod, job *batch.Job) { } pod.Spec.Volumes = append(pod.Spec.Volumes, cmVolume) - for i, c := range pod.Spec.Containers { - vm := v1.VolumeMount{ - MountPath: ConfigMapMountPath, - Name: cmName, - } + vm := v1.VolumeMount{ + MountPath: ConfigMapMountPath, + Name: cmName, + } + for i, c := range pod.Spec.Containers { pod.Spec.Containers[i].VolumeMounts = append(c.VolumeMounts, vm) } + for i, c := range pod.Spec.InitContainers { + pod.Spec.InitContainers[i].VolumeMounts = append(c.VolumeMounts, vm) + } } func (sp *servicePlugin) createServiceIfNotExist(job *batch.Job) error {