diff --git a/docs/deployment/schedulers/k3s.md b/docs/deployment/schedulers/k3s.md index 815474024..fd80c27f3 100644 --- a/docs/deployment/schedulers/k3s.md +++ b/docs/deployment/schedulers/k3s.md @@ -195,10 +195,16 @@ The `docker-local` scheduler supports a minimal list of resource _limits_ and _r #### Resource Limits +> [!NOTE] +> Cron tasks retrieve resource limits based on the computed cron task ID. If unspecified, the default will be 1 CPU and 512m RAM. + - cpu: is specified in number of CPUs a process can access. - memory: should be specified with a suffix of `b` (bytes), `k` (kilobytes), `m` (megabytes), `g` (gigabytes). Default unit is `m` (megabytes). #### Resource Reservations +> [!NOTE] +> Cron tasks retrieve resource reservations based on the computed cron task ID. If unspecified, the default will be 1 CPU and 512m RAM. + - cpu: is specified in number of CPUs a process can access. - memory: should be specified with a suffix of `b` (bytes), `k` (kilobytes), `m` (megabytes), `g` (gigabytes). Default unit is `m` (megabytes). diff --git a/plugins/scheduler-k3s/template.go b/plugins/scheduler-k3s/template.go index 2c425692d..eb1a13778 100644 --- a/plugins/scheduler-k3s/template.go +++ b/plugins/scheduler-k3s/template.go @@ -274,6 +274,8 @@ func templateKubernetesCronJob(input Job) (batchv1.CronJob, error) { return job, fmt.Errorf("Error parsing cpu limit: %w", err) } job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Limits["cpu"] = cpuQuantity + } else { + job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Limits["cpu"] = resource.MustParse("500m") } nvidiaGpuLimit, err := common.PlugnTriggerOutputAsString("resource-get-property", []string{input.AppName, input.ProcessType, "limit", "nvidia-gpu"}...) if err != nil && nvidiaGpuLimit != "" && nvidiaGpuLimit != "0" { @@ -290,6 +292,8 @@ func templateKubernetesCronJob(input Job) (batchv1.CronJob, error) { return job, fmt.Errorf("Error parsing memory limit: %w", err) } job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Limits["memory"] = memoryQuantity + } else { + job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Limits["memory"] = resource.MustParse("512Mi") } cpuRequest, err := common.PlugnTriggerOutputAsString("resource-get-property", []string{input.AppName, input.ProcessType, "reserve", "cpu"}...) @@ -299,6 +303,8 @@ func templateKubernetesCronJob(input Job) (batchv1.CronJob, error) { return job, fmt.Errorf("Error parsing cpu request: %w", err) } job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Requests["cpu"] = cpuQuantity + } else { + job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Requests["cpu"] = resource.MustParse("500m") } memoryRequest, err := common.PlugnTriggerOutputAsString("resource-get-property", []string{input.AppName, input.ProcessType, "reserve", "memory"}...) if err != nil && memoryRequest != "" && memoryRequest != "0" { @@ -307,6 +313,8 @@ func templateKubernetesCronJob(input Job) (batchv1.CronJob, error) { return job, fmt.Errorf("Error parsing memory request: %w", err) } job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Requests["memory"] = memoryQuantity + } else { + job.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources.Requests["memory"] = resource.MustParse("512Mi") } return job, nil