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
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 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | |
build_kuberay_cluster_manifest
¶
Build a KubeRay ray.io/v1 RayCluster custom resource manifest (pure).
Source code in src/scale_forecasting/gke_submit.py
537 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 | |
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
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
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 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
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
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 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 | |