Skip to content

Commit a47b439

Browse files
authored
Prevent cluster autoscaler from reallocating job pods (#1919)
1 parent 3926728 commit a47b439

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

pkg/lib/k8s/job.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ func Job(spec *JobSpec) *kbatch.Job {
5858
Parallelism: &spec.Parallelism,
5959
Template: kcore.PodTemplateSpec{
6060
ObjectMeta: kmeta.ObjectMeta{
61-
Name: spec.PodSpec.Name,
62-
Labels: spec.PodSpec.Labels,
61+
Name: spec.PodSpec.Name,
62+
Labels: spec.PodSpec.Labels,
63+
Annotations: spec.PodSpec.Annotations,
6364
},
6465
Spec: spec.PodSpec.K8sPodSpec,
6566
},

pkg/operator/resources/job/batchapi/k8s_specs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func pythonPredictorJobSpec(api *spec.API, job *spec.BatchJob) (*kbatch.Job, err
8181
},
8282
Annotations: map[string]string{
8383
"traffic.sidecar.istio.io/excludeOutboundIPRanges": "0.0.0.0/0",
84+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
8485
},
8586
K8sPodSpec: kcore.PodSpec{
8687
RestartPolicy: "Never",
@@ -130,6 +131,7 @@ func tensorFlowPredictorJobSpec(api *spec.API, job *spec.BatchJob) (*kbatch.Job,
130131
},
131132
Annotations: map[string]string{
132133
"traffic.sidecar.istio.io/excludeOutboundIPRanges": "0.0.0.0/0",
134+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
133135
},
134136
K8sPodSpec: kcore.PodSpec{
135137
RestartPolicy: "Never",
@@ -180,6 +182,7 @@ func onnxPredictorJobSpec(api *spec.API, job *spec.BatchJob) (*kbatch.Job, error
180182
},
181183
Annotations: map[string]string{
182184
"traffic.sidecar.istio.io/excludeOutboundIPRanges": "0.0.0.0/0",
185+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
183186
},
184187
K8sPodSpec: kcore.PodSpec{
185188
RestartPolicy: "Never",

pkg/operator/resources/job/taskapi/k8s_specs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func k8sJobSpec(api *spec.API, job *spec.TaskJob) (*kbatch.Job, error) {
109109
},
110110
Annotations: map[string]string{
111111
"traffic.sidecar.istio.io/excludeOutboundIPRanges": "0.0.0.0/0",
112+
"cluster-autoscaler.kubernetes.io/safe-to-evict": "false",
112113
},
113114
K8sPodSpec: kcore.PodSpec{
114115
RestartPolicy: "Never",

0 commit comments

Comments
 (0)