Google Kubernetes Engine (GKE) submitter¶
gke_submit
¶
Submit a run (or family slice) to Google Kubernetes Engine (runtime="gke" / ray_mode="gke").
Why a Google Kubernetes Engine runtime beside Spark, Vertex AI, and Compute Engine:
1. Kubernetes Indexed Jobs (gke_mode="job", default):
- Dispatches a Kubernetes batch/v1 Indexed Job (completionMode: Indexed,
completions = W, parallelism = W) running SF_CONTAINER_IMAGE with dynamic GCS code
delivery (VERTEX_BOOTSTRAP_CODE -> scale_forecasting.vertex_entry).
- Kubernetes automatically injects JOB_COMPLETION_INDEX (0 .. W-1) into each pod, which
engines.vertex_engine.resolve_worker_topology parses into WorkerTopology(rank=r,
world_size=W, source="k8s_indexed_job").
- Supports single-pod execution (workers = 1), multi-pod local series-range pushdown
(workers = N via engines.vertex_engine.build_worker_series_range), $1$-pod-per-model
parallel global/deep-learning training (engines.vertex_engine.partition_models_for_worker),
and GCS completion barriers (SF_VERTEX_JOB_ID).
2. Ray on GKE (gke_mode="ray" or runtime="ray" with ray_mode="gke"):
- Runs engines.ray_engine.run on GKE using SF_CONTAINER_IMAGE (ray==2.59.0),
bypassing Vertex Managed Ray's custom-image and Ray-version constraints while preserving
fractional GPU packing and dynamic chunk scheduling.
- Emits both native Kubernetes Ray manifests (Headless Service + Worker Deployment + Driver Job)
and KubeRay ray.io/v1 RayCluster specifications.
3. Zero-Idle Standing Clusters (Autopilot / Node Autoprovisioning) & Ephemeral Lifecycle:
- Targets an existing GKE cluster when compute.gke_cluster_name or SF_GKE_CLUSTER is set
(allowing sub-15-second warm pod startup and scale-to-zero node pools), or provisions an
ephemeral GKE cluster per run and tears it down unconditionally in finally.
- Communicates with both the GKE Control Plane API (https://container.googleapis.com/v1) and
the Kubernetes API Server (https://<cluster.endpoint>) directly via
google.auth.transport.requests.AuthorizedSession + the cluster's CA certificate — requiring
zero kubectl, gke-gcloud-auth-plugin, or third-party kubernetes client binaries.
GkeJobPlan
dataclass
¶
GkeJobPlan(
job_name,
gke_mode,
cluster_name,
ephemeral_cluster,
namespace,
machine_type,
accelerator_type,
accelerator_count,
worker_count,
requested_workers,
hardware,
gpu_type,
image_uri="",
package_uri="",
config_uri="",
service_account="",
subnetwork_uri="",
boot_disk_gb=_DEFAULT_BOOT_DISK_GB,
resource_plan=None,
ray_cluster_plan=None,
)
Resolved execution plan for a Google Kubernetes Engine run (pure).
to_dict
¶
JSON-safe summary for run_jobs.job_telemetry.$.gke_job.
Source code in src/scale_forecasting/gke_submit.py
GkeK8sClient
¶
Direct REST client for a GKE cluster's Kubernetes API server using AuthorizedSession.
Source code in src/scale_forecasting/gke_submit.py
build_gke_cluster_spec
¶
Build the GKE projects.locations.clusters.create request body (pure).
Source code in src/scale_forecasting/gke_submit.py
build_k8s_indexed_job_manifest
¶
Build a Kubernetes batch/v1 Indexed Job manifest for gke_mode="job" (pure).
Kubernetes sets JOB_COMPLETION_INDEX in [0, plan.worker_count - 1] on each pod;
engines.vertex_engine.resolve_worker_topology reads JOB_COMPLETION_INDEX and
JOB_COMPLETION_TOTAL to shard series or models across pods without a coordinator node.
Source code in src/scale_forecasting/gke_submit.py
build_k8s_ray_manifests
¶
Build Kubernetes manifests for gke_mode="ray" (pure).
Returns a dictionary containing:
* job: The Kubernetes batch/v1 Job running RAY_GKE_BOOTSTRAP_CODE ->
scale_forecasting.ray_entry.
* head_service: Headless v1/Service exposing port 6379 when
plan.worker_count > 1, else None.
* worker_deployment: apps/v1/Deployment of plan.worker_count - 1 Ray worker pods
joining <job_name>-head:6379 when plan.worker_count > 1, else None.
* kuberay_cluster: The KubeRay ray.io/v1 RayCluster specification.
Source code in src/scale_forecasting/gke_submit.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 | |
build_kuberay_cluster_manifest
¶
Build a KubeRay ray.io/v1 RayCluster custom resource manifest (pure).
Source code in src/scale_forecasting/gke_submit.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | |
create_gke_cluster
¶
Create a GKE cluster and wait until its status is RUNNING.
Source code in src/scale_forecasting/gke_submit.py
delete_gke_cluster
¶
Delete a GKE cluster (idempotent on 404). Blocks until deleted when wait=True.
Source code in src/scale_forecasting/gke_submit.py
ephemeral_cluster_name
¶
Shared internal helper delegating to _ephemeral_cluster_name.
get_gke_cluster
¶
Fetch a GKE cluster resource by (project_id, location, cluster_name) (None on 404).
When location is a region (e.g. us-central1) and the direct regional lookup returns 404,
also searches clusters across locations/- in the project so a standing zonal cluster in that
region (e.g. us-central1-a) is resolved automatically.
Source code in src/scale_forecasting/gke_submit.py
k8s_job_state
¶
Classify a Kubernetes batch/v1 Job status into (state, detail) (pure).
Returns ("SUCCEEDED" | "FAILED" | "RUNNING" | "NOT_FOUND", detail).
Source code in src/scale_forecasting/gke_submit.py
plan_gke_job
¶
plan_gke_job(
cfg,
models=None,
*,
run_id=None,
job_id=None,
gke_mode=None,
cluster_name=None,
namespace=None,
hardware=None,
gpu_type=None,
machine_type=None,
worker_count=None,
accelerator_count=None,
image_uri="",
package_uri="",
config_uri="",
service_account="",
subnetwork_uri="",
profile=None,
infra=None,
)
Resolve a GkeJobPlan from cfg and per-family overrides (pure).
Source code in src/scale_forecasting/gke_submit.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
resolve_gke_candidates
¶
Explicit-zone candidates for ephemeral GKE cluster creation (pure).
Source code in src/scale_forecasting/gke_submit.py
submit_gke
¶
submit_gke(
cfg,
*,
settings=None,
infra=None,
wait=True,
models=None,
job_id=None,
gke_mode=None,
cluster_name=None,
cluster_location=None,
keep_cluster=False,
manage_header=True,
hardware=None,
gpu_type=None,
machine_type=None,
worker_count=None,
accelerator_count=None,
wait_timeout_seconds=None,
)
Stage artifacts, resolve/create GKE cluster, dispatch K8s Job, wait, and clean up.
Returns (run_id, job_name, ProbeHandle).
Source code in src/scale_forecasting/gke_submit.py
1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | |