mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
fix: add work-dir volume for job pod.
Signed-off-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
parent
2eed0820d7
commit
0491f22e6f
File diff suppressed because it is too large
Load Diff
|
|
@ -56,6 +56,9 @@ type PipelineSpec struct {
|
|||
// Debug mode, after a successful execution of Pipeline, will retain runtime data, which includes task execution status and parameters.
|
||||
// +optional
|
||||
Debug bool `json:"debug,omitempty"`
|
||||
// WorkVolume for work dir. valid in job pod.
|
||||
// +optional
|
||||
WorkVolume *corev1.Volume `json:"workVolume,omitempty"`
|
||||
}
|
||||
|
||||
type PipelineProject struct {
|
||||
|
|
|
|||
|
|
@ -351,6 +351,11 @@ func (in *PipelineSpec) DeepCopyInto(out *PipelineSpec) {
|
|||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.WorkVolume != nil {
|
||||
in, out := &in.WorkVolume, &out.WorkVolume
|
||||
*out = new(corev1.Volume)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PipelineSpec.
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import (
|
|||
ctrlfinalizer "sigs.k8s.io/controller-runtime/pkg/finalizer"
|
||||
|
||||
kubekeyv1 "github.com/kubesphere/kubekey/v4/pkg/apis/kubekey/v1"
|
||||
_const "github.com/kubesphere/kubekey/v4/pkg/const"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -188,7 +189,6 @@ func (r *PipelineReconciler) dealRunningPipeline(ctx context.Context, pipeline *
|
|||
Completions: ptr.To[int32](1),
|
||||
BackoffLimit: ptr.To[int32](0),
|
||||
Template: corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{},
|
||||
Spec: corev1.PodSpec{
|
||||
ServiceAccountName: saName,
|
||||
RestartPolicy: "Never",
|
||||
|
|
@ -207,9 +207,18 @@ func (r *PipelineReconciler) dealRunningPipeline(ctx context.Context, pipeline *
|
|||
},
|
||||
},
|
||||
}
|
||||
// add ownerReference
|
||||
if err := controllerutil.SetOwnerReference(pipeline, job, r.Scheme); err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
// add work-dir volume
|
||||
if pipeline.Spec.WorkVolume != nil {
|
||||
job.Spec.Template.Spec.Volumes = append(job.Spec.Template.Spec.Volumes, *pipeline.Spec.WorkVolume)
|
||||
job.Spec.Template.Spec.Containers[0].VolumeMounts = append(job.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{
|
||||
Name: pipeline.Spec.WorkVolume.Name,
|
||||
MountPath: _const.GetWorkDir(),
|
||||
})
|
||||
}
|
||||
err := r.Create(ctx, job)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue