xpk-to-clustertoolkit
Skill370 starsChanged 13 days agoApache-2.0View on GitHub
Migrate xpk CLI commands, scripts, and documentation to Cluster Toolkit blueprints and gcluster CLI submission commands. Use when migrating AI/ML TPU/GPU workloads from xpk to Cluster Toolkit.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- cluster-blueprint-assistantSkill
- gke-kueue-debuggingSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 2 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 45
Migration Guide: Read docs/migration/xpk_to_clustertoolkit.md (or online at XPK to Cluster Toolkit Migration Guide).
- Very specific: line 46
Flag Mapping Matrix: Read flag_mappings.md for 1:1 flag translation and --filter-by-status to --status mappings.
- Distinctive: line 47
Architectural Differences: Read architectural_differences.md for IaC lifecycle, KubeRay, and storage comparisons.
- Distinctive: line 48
End-to-End Examples: Read examples.md for full worked migration recipes (MaxText RL, multi-slice TPU, NVIDIA GPU, Lustre).
- Very specific: line 54
When processing target files, stitch together line continuations (\) and evaluate unexpanded shell parameters.
- Very specific: line 75
Avoid pure
kubectlcommands: Do NOT generate raw Kubernetes manifests (e.g. - Very specific: line 78
Always run the parser with single quotes so shell variables ($CLUSTER, $ZONE) reach the parser unexpanded:
- Very specific: line 127
Never modify files under examples/ in place — they are shared, CI-tested assets.
- Very specific: line 138
Reservation Affinity: If --reservation is omitted in the XPK command, delete the pre-existing reservation_affinity block from the …
- Very specific: line 139
GPU Blueprints: Do NOT merge compute_machine_type into examples/gke-a3-megagpu/ or examples/gke-a4/ — those blueprints default it to the …
- Very specific: line 147
Do NOT add global variables that the example does not declare.
- Very specific: line 199
Verify that zero residual XPK execution commands remain in migrated workload and deployment scripts.
- Very specific: line 201
Verify that all referenced blueprints (e.g.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
[!WARNING] This skill is experimental. Always review generated blueprints and command translations before execution, and explicitly request confirmation for any mutating deployments.
<!-- pymarkdown:disable heading-style,single-title -->Overview
You are an expert in migrating xpk CLI configurations and commands to Cluster
Toolkit (gcluster). Your goal is to automate the translation of xpk commands
found in Markdown files and Bash scripts into their equivalent Cluster Toolkit
representations.
Canonical Documentation & Reference Tier
For deep technical details and comprehensive translation matrices, consult the authoritative documentation:
- Migration Guide: Read
docs/migration/xpk_to_clustertoolkit.md(or online at XPK to Cluster Toolkit Migration Guide). - Flag Mapping Matrix: Read flag_mappings.md for 1:1 flag translation and
--filter-by-statusto--statusmappings. - Architectural Differences: Read architectural_differences.md for IaC lifecycle, KubeRay, and storage comparisons.
- End-to-End Examples: Read examples.md for full worked migration recipes (MaxText RL, multi-slice TPU, NVIDIA GPU, Lustre).
Core Workflows
When processing target files, stitch together line continuations (\) and evaluate
unexpanded shell parameters.
1. 1:1 Mapping Rule (Simple Commands)
For simple xpk commands, perform inline replacements:
xpk workload list->gcluster job list(filters workloads via--name-contains).xpk workload delete <name>->gcluster job cancel <name>(positional workload name; batch deletion via--filter-by-jobis not supported).xpk cluster delete->gcluster destroy <deployment_directory>(takes the path to the deployment directory, e.g../<deployment_name>).xpk config set->gcluster job config set(Cluster Toolkit accepts onlyproject,cluster,location). Setting this preamble in workflow scripts allows subsequentjob submit,job list, andjob logscommands to omit connection flags.xpk inspector->gcluster job logs <workload_name>(orgcluster job inspect <workload_name>).xpk info->gcluster cluster infoxpk cluster list->gcluster cluster listxpk cluster describe->gcluster cluster describexpk cluster adapt-> Remove command (# Prerequisite tools checked via gcluster; cluster CRDs deployed via blueprint).xpk storage list->gcluster cluster volume
2. Complex Commands (workload create & cluster create)
MANDATORY RULE ON WORKLOAD TRANSLATION:
- Always use
gcluster job submit: Translate allxpk workload createorxpk workload create-pathwayscommands togcluster job submit. - Avoid pure
kubectlcommands: Do NOT generate raw Kubernetes manifests (e.g. rawJob,JobSet, orPodYAMLs applied viakubectl apply) as replacements forxpk workload create, unless specifically migrating custom operators like KubeRay (RayJob).
Deterministic Parser Invocation:
Always run the parser with single quotes so shell variables ($CLUSTER, $ZONE) reach the parser unexpanded:
python3 skills/xpk-to-clustertoolkit/scripts/parse_xpk_to_gcluster.py 'xpk ...'(Adjust the script path if vendored outside the repository root).
[!IMPORTANT]
parse_xpk_to_gcluster.pyis the authoritative source of truth for flag mappings. Give precedence to user experience and correctness: never silently parse or drop unrecognized flags. When the parser encounters an unmapped or unrecognized flag, it emits an explicit# Warning: Unmapped xpk flags were ignored:note clarifying that the tool is unsure how to translate it automatically. When handling these flags: (a) clearly warn the user about any unrecognized flags and explain that the tool is unsure of their translation, (b) record them in the Migration Report's Unmapped Flags table with behavioral impacts, and (c) do NOT leave inline comments naming the legacy XPK flag in executable scripts. If the flag is load-bearing (--force,--dry-run), ask the user before proceeding.
2a. Workload Submission (gcluster job submit)
- Standard TPU Workloads: Converted to
gcluster job submit --compute-type <type> --topology <AxBxC> --command <cmd>.- TPU
--num-nodesConstraint:gcluster job submitrejects--num-nodesfor TPU jobs (cmd/job/submit.go:226 (validateTPUFlags)). The parser automatically omits--num-nodesfor TPUs.
- TPU
- GPU Workloads: GPU jobs take
--num-nodesand never--topology. The parser preserves--num-nodesfor GPU compute types (e.g.,a3-megagpu-8g,h100-mega-80gb-8). - Pathways Workloads (
xpk workload create-pathways):- Adds
--pathwaysand maps--headless->--pathways-headless. --pathways-gcs-location <gs-uri>is mandatory in Cluster Toolkit.- Workload Name Length: Standard names must be <= 28 characters; Pathways names must be <= 22 characters due to Kubernetes 63-byte coordinator label limits (
<name>-pathways-head-0-0.<name>).
- Adds
- Multi-Tier Checkpointing (MTC): Maps
--mtc-enabled->--gke-mtc-enabled,--ramdisk-directory->--gke-mtc-ramdisk-dir, and--colocated-python-sidecar-image->--pathways-colocated-python-sidecar-image. (Cluster requiresHighScaleCheckpointingandGcsFuseCsiDriveraddons). - Elastic Slices: Maps
--elastic-slices->--pathways-elastic-slicesand--max-slice-restarts->--pathways-max-slice-restarts. - Container Images & Crane Builds:
--docker-imagedesignates the direct workload container image (--image).--base-docker-imagepaired with--script-dirmaps to--base-image+--build-contextfor Crane builds. Note that xpk rejects combining--docker-imagewith--base-docker-imageor--script-dir; following xpk precedence,--docker-imagetakes precedence and emits--imagealone without build context. - Storage Mounts: In xpk,
--storage <name>references a separate Storage object whose mount point, PVC name, and read-only mode live on the CRD rather than the CLI command. The parser emits a failsafe placeholder--mount "<src>;/mnt/<src>;ro"(defaulting to read-onlyro, matching gcluster's default) with a warning to verify the real parameters viaxpk storage listorgcluster cluster volume. Destination paths are automatically deduplicated (/mnt/data,/mnt/data_2).
Standard Workload Example:
# Input:
xpk workload create --workload my-workload --tpu-type tpu7x-4x4x4 --command "python3 train.py"
# Output:
gcluster job submit --name my-workload --command 'python3 train.py' --compute-type tpu7x-standard-4t --topology 4x4x4Pathways Workload Example:
# Input:
xpk workload create-pathways --workload my-pw-job --tpu-type tpu7x-4x4x4 --headless --pathways-gcs-location gs://my-bucket/tmp --command "python3 train.py"
# Output:
gcluster job submit --pathways --name my-pw-job --command 'python3 train.py' --pathways-gcs-location gs://my-bucket/tmp --pathways-headless --compute-type tpu7x-standard-4t --topology 4x4x42b. Blueprint Generation (cluster create)
For xpk cluster create and create-pathways, generate a declarative Cluster Toolkit blueprint:
- Asset Selection & Blueprint Copying:
Never modify files under
examples/in place — they are shared, CI-tested assets. Copy the canonical example next to the source script and name it<deployment_name>.yaml; all edits go to the copy:- TPU v4 / v5e / v5p / v6e:
examples/gke-tpu-v6e/gke-tpu-v6e.yaml,examples/gke-tpu-v4/gke-tpu-v4.yaml - TPU 7x:
examples/gke-tpu-7x/gke-tpu-7x.yaml - NVIDIA GPU (A4 / A3):
examples/gke-a4/gke-a4.yaml,examples/gke-a3-megagpu/gke-a3-megagpu.yaml - Managed Lustre:
examples/gke-managed-lustre.yaml - Storage (GCS FUSE, Filestore, Persistent Volumes):
examples/storage-gke.yaml(In standalone environments where the repository is not cloned, runskills/xpk-to-clustertoolkit/scripts/fetch_toolkit_examples.shto sync canonical examples to~/.cache/cluster-toolkit-examples/, or download directly viacurl https://raw.githubusercontent.com/GoogleCloudPlatform/cluster-toolkit/main/examples/<path>).
- TPU v4 / v5e / v5p / v6e:
- Additive Merge Semantics:
Merging is additive: overwrite only the keys the parser emitted and preserve every other key already present in the example's
vars:block.- Pre-existing Unset Variables: Canonical examples (like
examples/gke-tpu-v6e/gke-tpu-v6e.yaml) declareauthorized_cidrandreservationwith no default value. Supply them via--varsor prompt the user. - Reservation Affinity: If
--reservationis omitted in the XPK command, delete the pre-existingreservation_affinityblock from the accelerator node pool module and the now-unusedreservationvariable fromvars:(it is the block's only consumer in canonical blueprints; leaving it tripstest_deployment_variable_not_used). - GPU Blueprints: Do NOT merge
compute_machine_typeintoexamples/gke-a3-megagpu/orexamples/gke-a4/— those blueprints default it to the only machine type the node pool supports. Merge onlystatic_node_count,project_id,deployment_name,zone, andregion.
- Pre-existing Unset Variables: Canonical examples (like
- Decision Rule for
vars:vssettings:: The parser emits three distinct configuration buckets:vars:: Global blueprint variables (e.g.project_id,deployment_name,reservation,enable_pathways_for_tpus). In modern unified GPU blueprints (gke-a3-megagpu, and as of PRs #6276/#6279gke-a3-highgpu,gke-a3-ultragpu,gke-a4), consumption models are configured directly invars:(e.g.vars.spot,vars.enable_flex_start, andvars.reservation_affinity).cluster_module_settings:: Module settings applied directly undermodules/scheduler/gke-clustersettings:(e.g.authorized_cidr).nodepool_module_settings:: Node pool settings applied directly undermodules/compute/gke-node-poolsettings:(e.g.spot,enable_flex_start,auto_repair, and for TPU/other blueprints,reservation_affinity).- Reference Pattern: When an example declares a key in
vars:and references it in settings as$(vars.X)(e.g.enable_pathways_for_tpus: $(vars.enable_pathways_for_tpus)orreservation_affinity.specific_reservations[0].name: $(vars.reservation)), update the value invars:and leave the reference intact. This keeps values--vars-settable at deploy time and preventstest_deployment_variable_not_usederrors. - Do NOT add global variables that the example does not declare; explicit module settings block global propagation and trigger
test_deployment_variable_not_used.
- Pathways Configuration:
- When migrating with Pathways (
--enable-pathways): Setenable_pathways_for_tpus: trueinvars:. This automatically provisions the dedicatedcpu-npnode pool (n4-standard-64). - When migrating WITHOUT Pathways: You MUST explicitly set
enable_pathways_for_tpus: false(emitted automatically by the parser for TPU clusters). Canonical blueprints (e.g.gke-tpu-v6e.yaml:53 (enable_pathways_for_tpus)) default it totrueand will otherwise provision an unrequested CPU node pool. Do not set this variable on GPU blueprints.
- When migrating with Pathways (
- Reservation Affinity Targeting:
For modern unified GPU blueprints (
gke-a3-megagpu, and as of PRs #6276/#6279gke-a3-highgpu,gke-a3-ultragpu,gke-a4), configure thereservation_affinityobject directly invars:. For TPU and specialized blueprints (gke-tpu-v6e-pool,gke-tpu-7x-pool,a4x_pool), configurereservation: <name>invars:and ensure the accelerator node pool module references- name: $(vars.reservation)undersettings:. If the example already definesreservation_affinity, edit the existing block rather than adding a second one. - Storage & Persistent Volume Architecture:
- A
modules/file-system/*module provisions storage instances but creates no PVC. Always pair it withmodules/file-system/gke-persistent-volume(use: [<cluster>, <fs-module>]). - In
examples/gke-managed-lustre.yaml, the generated PersistentVolumeClaim claim name isgke-lustre-instance-pvc(notlustre-pvc). Workloads mount this claim directly. <src>resolution: Cloud Storage ->gs://bucket/path; PVC provisioned bygke-persistent-volume-> bare claim name; Filestore ->filestore://<instance>/<share>.<dest>was set byxpk storage create --mount-pointand cannot be derived from the submission command; ask the user rather than guessing.
- A
- GHPC Template Expressions & HCL Arithmetic:
Template expansions inside
$(...)evaluate as native HCL expressions. Compound arithmetic is fully supported (e.g.$(vars.num_slices * pool.node_count_static * pool.tpu_chips_per_node)). - Deployment Command:
Blueprint YAML cannot interpolate any shell variable — neithergcluster deploy <blueprint_file.yaml> --vars project_id=<project>,deployment_name=<name>,zone=<zone>,region=<region>$ZONEnor${ZONE%-*}. Every value the parser emits containing$must either be passed at deploy time via--vars, or replaced with a literal. Note thatblueprint_nameis a top-level field, not a variable:--varscannot override it, so it must always be a literal lowercase RFC-1035 string (e.g.my-cluster).reservationmust also be passed at deploy time (via--vars reservation=$RES) when the source command supplied one.
Safety Guidelines & Confirmation Protocol
- Safe Actions (Zero Turn Delay): Generating blueprints, inspecting configurations (
gcluster expand), translating CLI commands, parsing recipes, and reading documentation execute freely. - Mutating & Billable Actions (Confirmation Strictly Required):
- Infrastructure Provisioning:
gcluster deploy(including re-deployments over existing directories) creates billable Cloud resources and modifies infrastructure. - Workload Execution:
gcluster job submitlaunches billable computing workloads on clusters. - Destructive Teardown:
gcluster job cancelandgcluster destroyterminate running jobs and delete infrastructure. These actions must NEVER execute autonomously without presenting a structured remediation plan and obtaining user confirmation.
- Infrastructure Provisioning:
- Tool Grant Precedence: The
allowed-toolsgrant in frontmatter is permissive for execution convenience; the confirmation protocol above takes absolute precedence over it in all cases. Mutating actions (gcluster deploy,gcluster job submit,gcluster job cancel,gcluster destroy) must never execute without prior plan confirmation.
Required Remediation Plan Format:
[PROPOSED REMEDIATION PLAN]
- Target Resource: <Cluster|Workload|Deployment>/<RESOURCE_NAME>
- Root Cause Identified: <Precise migration or operational intent>
- Proposed Action: <Exact command to execute, e.g. gcluster deploy <blueprint.yaml> or gcluster job submit ...>
- Accelerator & Node Count: <e.g. TPU v6e-256 (64 nodes) / Billable Resource>
- Blast Radius: <Affected clusters, node pools, running jobs, storage volumes, and billing impact>
- Confirmation Required: Reply 'yes' to proceed.Mandatory Post-Migration Verification & Residual Audit
- Audit for Residual XPK Execution Invocations:
Verify that zero residual XPK execution commands remain in migrated workload and deployment scripts. All active runtime entrypoints and submission loops must use
gcluster. (Comparative documentation and migration guides may retain contextual XPK references for contrast, but operational scripts must be 100% clean). - Verify Asset & Blueprint Existence:
Verify that all referenced blueprints (e.g.
examples/gke-tpu-v6e/gke-tpu-v6e.yaml,examples/gke-managed-lustre.yaml) exist at the specified relative paths in the workspace. - Generate Migration Report Deliverable:
Provide a markdown artifact (
migration_report.md) containing:- Migration Inventory & Mapping Summary table.
- Unmapped Flags table with behavioral impacts.
- Decommissioning checklist for legacy scripts and tabs.
- Verification commands and cleanup instructions (
gcluster destroy <deployment_dir>).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

