NAME
gcluster job submit - submits a workload to a cluster.
SYNOPSIS
gcluster job submit [FLAGS]
DESCRIPTION
The gcluster job submit command submits a workload to a cluster. On
Google Kubernetes Engine (GKE) clusters, Cluster Toolkit deploys workloads
as Kubernetes JobSet resources integrated with Kueue. For single-slice,
non-Pathways workloads, the gcluster CLI falls back to a standalone batch/v1
Indexed Job and headless Service when the JobSet API isn't available or
the GCLUSTER_DISABLE_JOBSET=1 environment variable is set.
FLAGS
-i,--image IMAGE: The name of the prebuilt container image to run, including the registry path. Specify either the--imageor--base-imageflag, except in the following cases:- You submit a headless Pathways job (
--pathways-headlessflag). - You deploy a Shared Pathways Service (SPS) instance
(
--pathways-deploy-spsflag). - You run a local workload against an SPS instance
(
--pathways-run-sps-workloadflag).
- You submit a headless Pathways job (
-B,--base-image IMAGE: The name of the base image used to build a new container image and push it to Artifact Registry or another Open Container Initiative (OCI) registry by using Crane. This flag requires the--build-contextflag and can't be combined with the--imageflag.-b,--build-context DIR: The path to the build context directory for Crane. This flag is required when you use the--base-imageflag. Set theGCLUSTER_IMAGE_REPOenvironment variable to an Artifact Registry repository name or a fullREGISTRY_HOST/REPOSITORYOCI prefix. When the--base-imageimage is hosted in a custom OCI registry and theGCLUSTER_IMAGE_REPOenvironment variable is unset, thegclusterCLI defaults toHOST/library/gcluster.-e,--command COMMAND: The command to run in the workload container, such aspython3 train.py. This flag is required for job submissions, unless you submit a headless Pathways job with the--pathways-headlessflag or deploy an SPS instance with the--pathways-deploy-spsflag.--compute-type TYPE: The compute resource to request. This flag is required unless you set the--pathways-run-sps-workloadflag. Specify one of the following formats:- Compute Engine machine type, such as
n2-standard-32ora3-highgpu-8g - GPU or TPU shorthand, such as
h100-80gb-8,l4-1,v5e-8,v5litepod-32, orv6e-8 - GKE accelerator label, such as
nvidia-l4
- Compute Engine machine type, such as
-o,--dry-run-out PATH: The path to output the generated Kubernetes manifest instead of applying it.-f,--platform PLATFORM: The target platform for the image build, such aslinux/amd64orlinux/arm64. The default value islinux/amd64. Use this flag with the--base-imageflag.--mount VOLUME: Mounts Cloud Storage buckets, Filestore instances, Network File System (NFS) exports,PersistentVolumeClaim(PVC) resources, or host paths. You can specify this flag multiple times:--mount="SRC;DEST[;MODE][;profile=PROFILE][;options=OPTIONS][;attributes=KEY=VALUE[,...]]"- Sources (
SRC): Supportsgs://BUCKET[/SUBPATH],filestore://INSTANCE_OR_IP/SHARE,nfs://SERVER/EXPORT,PVC_NAME[/SUBPATH], or a host path starting with/. Fornfs://sources, thegclusterCLI provisions a shared NFSPersistentVolume(PV) and PVC on port2049and reclaims them when you run thegcluster job cancelcommand. - Access mode (
MODE):ro(default) orrw. For PVCs, thegclusterCLI rejects the;rwmode onReadOnlyManyclaims and requires theReadWriteManyorReadOnlyManyaccess mode for multi-node and Pathways jobs. - Cloud Storage FUSE options (
profile=,options=,attributes=): Valid only forgs://sources. Use hyphenated Container Storage Interface (CSI) mount options without leading dashes in theoptions=segment, such asoptions=implicit-dirsfor flat-namespace buckets on inline mounts. Inlinegs://mounts scopeSUBPATHwith theonly-diroption, while theprofile=segment (training,checkpointing, orserving) provisions a shared gateway PV and PVC by using the PodsubPathfield. For existing Cloud Storage FUSE PVCs, thegclusterCLI automatically adds thegke-gcsfuse/volumes: "true"Pod annotation.
- Sources (
--env KEY=VALUE: Custom environment variables inKEY=VALUEformat to pass to the workload container. Replaces matchinggclusterdefaults, such as theJAX_PLATFORMSvariable on Pathways or--verboselogging variables. For standard workloads, thegclusterCLI presets theWORKERS_0_HOSTNAMEandMASTER_ADDRenvironment variables toNAME-main-job-0-0.NAME(JobSet) orNAME-0.NAME(standalonebatch/v1Job) unless overridden. You can specify this flag multiple times.-n,--name NAME: The name of the workload to create. The name can't exceed 28 characters for standard jobs or 22 characters for Pathways jobs, which use the--pathwaysflag. This flag is required.-q,--queue QUEUE: The name of the KueueLocalQueueresource. If you omit this flag, then thegclusterCLI discovers the cluster'sLocalQueueresource automatically. Ignored with a warning when Kueue isn't available or theGCLUSTER_DISABLE_KUEUE=1environment variable is set.--num-nodes N: The number of nodes to use per group or slice. The default value is1. You can't use the--num-nodesflag with TPU jobs because the node count is calculated automatically from the--topologyvalue.--num-slices N: The number of independent groups or slices to use. The default value is1.--restarts N: The maximum number of restarts for theJobSetresource. Ignored with a warning on standalonebatch/v1Jobworkloads, which use thebackoffLimit: 0setting. Defaults to one of the following values:1for standard jobs0when the--pathways-run-sps-workloadflag is set30when the--pathways-deploy-spsflag is set
--gke-ttl-after-finished DURATION: The time to retain theJobSetor standaloneJobresource after it finishes. The default value is1h.--grace-period DURATION: The time to wait before forcefully terminating a Pod. The default value is30s. On Pathways jobs, this flag applies only to worker Pods (thepathways-headPod keeps30s); it is ignored when the--pathways-run-sps-workloadflag is set.--gke-disable-parallel-containers: Turns off parallel containers for TPU7x on GKE.--placement-policy POLICY: The name of an existing Compute Engine compact placement or workload policy to use. If you omit this flag for A4X or multi-host TPU7x workloads, then thegclusterCLI resolves the policy automatically.--node-constraint KEY=VALUE: Key-value pairs for node labels to target specific nodes. Supports a pipe separator (|) to specify multiple allowed values.--cpu-affinity AFFINITY: CPU affinity rules.--restart-on-exit-codes CODES: A comma-separated list of workload container exit codes from1to255that trigger a job restart up to the--restartslimit. Sidecar container exit codes aren't evaluated.--image-pull-secret SECRET: A comma-separated list of secrets for pulling images from private registries. If you omit this flag, then thegclusterCLI attaches matchingkubernetes.io/dockerconfigjsonsecrets from the target namespace for workload, Pathways, and ML Diagnostics images. To attach no pull secrets, pass the--image-pull-secret=""flag.--service-account ACCOUNT: The Kubernetes service account name for the Pods. On TPU and Pathways jobs, setting this flag turns off thehostNetworkfield so that Pods authenticate by using Workload Identity Federation for GKE. GPU jobs use thehostNetwork: truesetting, so their Pods authenticate as the GKE node pool's service account.--topology TOPOLOGY: The TPU slice topology, such as2x4or2x4x4. This flag is required for TPU7x workloads.--gke-scheduler SCHEDULER: The Kubernetes Scheduler name.--await-job-completion: Waits for the submitted job to complete.--timeout TIMEOUT: The time to wait for the job to complete, such as1hor10m. The default value is-1s, which waits indefinitely when the--await-job-completionflag is turned on. Setting a custom timeout automatically turns on the--await-job-completionflag.--priority PRIORITY: A priority class name.--verbose: Turns on verbose logging for the workload. Matching--envvalues on standard jobs or--pathways-worker-envvalues on Pathways jobs take precedence.--enable-ml-diagnostics: Turns on ML Diagnostics for the workload. By default, this flag uses the GKE managed webhook and requires the target cluster to have ML Diagnostics turned on. If you also set the--ml-diagnostics-imageflag or theGCLUSTER_TELEMETRY_IMAGEenvironment variable, then thegclusterCLI injects the built-inai-telemetry-collectorsidecar container on Kubernetes 1.29 and later TPU Pods.--ml-diagnostics-image IMAGE: The container image for the built-inai-telemetry-collectorsidecar on Kubernetes 1.29 and later TPU workloads. This flag requires the--enable-ml-diagnosticsflag and overrides theGCLUSTER_TELEMETRY_IMAGEenvironment variable. To ignore theGCLUSTER_TELEMETRY_IMAGEenvironment variable and use the GKE managed webhook, pass the--ml-diagnostics-image=""flag.--ml-diagnostics-telemetry-port PORT: The Prometheus metrics port exposed by the ML Diagnostics collector sidecar. The default value is8889. This flag requires the--enable-ml-diagnosticsflag together with either the--ml-diagnostics-imageflag or theGCLUSTER_TELEMETRY_IMAGEenvironment variable. Ports8431to8438,8471,8476to8479, and13133are reserved.--gke-nap-provisioning MODEL: The compute provisioning model for GKE node auto-provisioning, such ason-demand,spot, orreservation.--gke-nap-reservation RESERVATION: The name of the Google Cloud reservation for GKE node auto-provisioning. This flag is required when you set the--gke-nap-provisioning=reservationflag.--pathways: Generates a manifest for a Pathways job.--pathways-proxy-server-image PW_PROXY_IMAGE: The image for thepathways-proxycontainer. Defaults tous-docker.pkg.dev/cloud-tpu-v2-images/pathways/proxy_server:latest, the matchingcloud-pathways/proxy_serverrelease tag when using a public--pathways-colocated-python-sidecar-imageflag, or an image derived from the SPS instance. Required explicitly when the SPS server image is pinned by digest (@sha256:...).--pathways-server-image PW_SERVER_IMAGE: The image for thepathways-rmcontainer and the default for thepathways-workercontainer. Defaults tous-docker.pkg.dev/cloud-tpu-v2-images/pathways/server:latest, or the matchingcloud-pathways/serverrelease tag when using a public--pathways-colocated-python-sidecar-imageflag.--pathways-worker-image IMAGE: The image for thepathways-workercontainer. Defaults to the--pathways-server-imageflag value.--pathways-headless: Prevents deploying your workload container within thepathways-headjob.--pathways-deploy-sps: Deploys an SPS instance with a resource-manager-onlypathways-headPod and persistent TPU worker Pods. This flag requires the--pathwaysflag and can't be used with the--pathways-headless,--image,--base-image,--build-context, or--commandflags.--pathways-run-sps-workload INSTANCE_OR_ENDPOINT: Runs the--commandflag against an existing SPS instance. Specify either theJobSetname or the service endpoint, such asNAME-pathways-head-0-0.NAME:29001.- Local mode. If you omit the
--imageand--base-imageflags, then thegclusterCLI runs the command locally against a port-forwardedpathways-proxyPod. ThegclusterCLI sets theJAX_PLATFORMS=proxyenvironment variable unless overridden with the--envflag and sets theJAX_BACKEND_TARGETenvironment variable to the port-forward endpoint. The--mountflag isn't supported in local mode. - In-cluster mode. If you set the
--imageor--base-imageflag, then thegclusterCLI runs the workload in the cluster and supports the--mountflag.
This flag requires the
--pathwaysflag and can't be combined with the following flags:--compute-type--gke-mtc-enabled--ml-diagnostics-image--ml-diagnostics-telemetry-port--num-nodes--pathways-colocated-python-sidecar-image--pathways-deploy-sps--pathways-elastic-slices--pathways-headless--pathways-max-slice-restarts--pathways-server-*--pathways-worker-*--topology
- Local mode. If you omit the
--pathways-gcs-location PW_GCS_LOCATION: The Cloud Storage location to store Pathways artifacts. This flag is required when the--pathwaysflag is set, unless you also set the--pathways-run-sps-workloadflag.--pathways-elastic-slices N: Configures the number of elastic slices.--pathways-max-slice-restarts N: The maximum number of failed-Pod replacements per worker index, from0to2147483647. Sets thebackoffLimitPerIndexfield toNand caps thebackoffLimitfield at2147483647. Defaults to one of the following values:0for standard Pathways jobs4000when the--pathways-elastic-slicesflag is greater than0or the--pathways-headlessflag is set1000000when the--pathways-deploy-spsflag is set
--pathways-proxy-args ARGS: Additional arguments for thepathways-proxycontainer.--pathways-server-args ARGS: Additional arguments for thepathways-rmcontainer.--pathways-worker-args ARGS: Additional arguments for thepathways-workercontainer.--pathways-proxy-env KEY=VALUE: Environment variables for thepathways-proxycontainer inKEY=VALUEformat. Replaces matchinggclusterdefaults. You can specify this flag multiple times.--pathways-server-env KEY=VALUE: Environment variables for thepathways-rmcontainer inKEY=VALUEformat. Replaces matchinggclusterdefaults. You can specify this flag multiple times.--pathways-worker-env KEY=VALUE: Environment variables for thepathways-workercontainer inKEY=VALUEformat. Replaces matchinggclusterdefaults. You can specify this flag multiple times.--pathways-colocated-python-sidecar-image IMAGE: The image for the Python-based sidecar container that runs in each Pathways worker Pod and shares memory with the worker at the/tmp/sidecardirectory. Setting this flag mounts--mountvolumes into the sidecar and passes the--sidecar_name=externalargument to thepathways-proxycontainer unless the--pathways-proxy-argsflag already sets the--sidecar_nameargument. For publiccloud-pathwayssidecar tags, thegclusterCLI auto-matches the server and proxy release tags. For custom or digest-pinned sidecar images, pass matching--pathways-server-imageand--pathways-proxy-server-imageflags.--pathways-head-np NP: The node pool to use for the Pathways head job. If you omit this flag, then thegclusterCLI detects a node pool namedcpu-nporpathways-npautomatically.--gke-mtc-enabled: Turns on Multi-Tier Checkpointing (MTC).--gke-mtc-ramdisk-dir DIR: The ramdisk directory path for MTC. This flag is required when the--gke-mtc-enabledflag is set.--gke-custom-templates-path PATH: The path to the local directory containing custom GKE templates, such asbase.tmpl,job.tmpl,jobset.tmpl, orpathways_jobset.tmpl. Any template file or sharedbase.tmplblock that you omit from the custom directory falls back to its embedded default.
PERSISTENT FLAGS
These flags are available to all
gcluster job commands:
-c,--cluster CLUSTER_NAME: The name of the GKE cluster or Kuberneteskubeconfigcontext. Optional in Kubernetes mode when thecurrent-contextfield is set.-l,--location LOCATION: The location, either a region or a zone, of the GKE cluster (GKE only).-p,--project PROJECT_ID: The Google Cloud project ID (GKE only).--gke-namespace NAMESPACE: The target Kubernetes namespace for the operation. If you omit this flag, then thegclusterCLI detects the namespace automatically.--skip-prereqs: Skips local environment prerequisite checks, such askubectlandgcloudchecks, and container registry authentication for Crane builds.
EXAMPLES
To submit a workload named train-job to a cluster:
gcluster job submit \
--cluster=CLUSTER_NAME \
--project=PROJECT_ID \
--location=LOCATION \
--name=train-job \
--image=IMAGE \
--compute-type=TYPE \
--command="python3 train.py"
To submit a workload that mounts Cloud Storage buckets with storage profiles, mount options, and CSI volume attributes:
gcluster job submit \
--cluster=CLUSTER_NAME \
--project=PROJECT_ID \
--location=LOCATION \
--name=storage-train-job \
--image=IMAGE \
--compute-type=TYPE \
--service-account=SERVICE_ACCOUNT \
--mount="gs://my-dataset-bucket/imagenet;/data;ro;profile=training;options=implicit-dirs;attributes=anywhereCacheZones=us-central1-a" \
--mount="gs://my-ckpt-bucket/run-42;/checkpoints;rw;profile=checkpointing" \
--command="python3 train.py --data=/data --ckpt=/checkpoints"
To submit a multi-node workload:
gcluster job submit \
--cluster=CLUSTER_NAME \
--project=PROJECT_ID \
--location=LOCATION \
--name=multi-node-job \
--image=IMAGE \
--command="python3 train.py" \
--compute-type=TYPE \
--num-nodes=N
To submit a multi-slice workload:
gcluster job submit \
--cluster=CLUSTER_NAME \
--project=PROJECT_ID \
--location=LOCATION \
--name=multi-slice-job \
--image=IMAGE \
--command="python3 train.py" \
--compute-type=TYPE \
--num-slices=N
To submit a Pathways workload:
gcluster job submit \
--cluster=CLUSTER_NAME \
--project=PROJECT_ID \
--location=LOCATION \
--name=pw-train-job \
--compute-type=TYPE \
--image=IMAGE \
--pathways-server-image=PW_SERVER_IMAGE \
--pathways-proxy-server-image=PW_PROXY_IMAGE \
--command="python3 train.py" \
--pathways \
--pathways-gcs-location=PW_GCS_LOCATION