Skip to content

Commit

Permalink
fix volume in initContainer
Browse files Browse the repository at this point in the history
Signed-off-by: zwwhdls <[email protected]>
  • Loading branch information
zwwhdls committed Sep 18, 2023
1 parent 40b91da commit 280be17
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/juicefs/mount/builder/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ func (r *PodBuilder) NewMountPod(podName string) *corev1.Pod {

// generate initContainer
if r.jfsSetting.FormatCmd != "" {
initVolumeMounts := r.genInitVolumes()
initContainer := r.genInitContainer()
initContainer.VolumeMounts = append(initContainer.VolumeMounts, volumeMounts...)
initContainer.VolumeMounts = append(initContainer.VolumeMounts, initVolumeMounts...)
pod.Spec.InitContainers = []corev1.Container{initContainer}
}

Expand Down Expand Up @@ -243,6 +244,22 @@ func (r *PodBuilder) genPodVolumes() ([]corev1.Volume, []corev1.VolumeMount) {
return volumes, volumeMounts
}

// genInitVolumes: generate volumes for initContainer in mount pod
// jfs config dir: mount jfs config dir as emptyDir to deliver config file to initContainer
func (r *PodBuilder) genInitVolumes() []corev1.VolumeMount {
volumeMounts := []corev1.VolumeMount{}

if r.jfsSetting.FormatCmd != "" {
// initContainer will generate xx.conf to share with mount container
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: JfsRootDirName,
MountPath: "/root/.juicefs",
})
}

return volumeMounts
}

// genCleanCachePod: generate pod to clean cache in host
func (r *PodBuilder) genCleanCachePod() *corev1.Pod {
volumeMountPrefix := "/var/jfsCache"
Expand Down

0 comments on commit 280be17

Please sign in to comment.