XMC Upgrade Environment
Upgrades an existing XManager on Cloud (XMC) environment on GKE to the latest current branch state using the deployment configuration YAML.
Warnings for the author
- "name" should use lowercase letters, digits and single hyphens only
- "name" should match the name of the directory that holds SKILL.md
- Not listed through the skills extension: the directory must be named after the skill.
Upgrade XMC Environment Workflow
This skill guides the agent through upgrading an existing deployed XManager on Cloud (XMC) environment on Google Kubernetes Engine (GKE) so that it runs the latest code from the current local repository branch (HEAD), leveraging the deployment configuration YAML file.
[!IMPORTANT] All execution steps in this skill MUST strictly adhere to the policy rules defined in Skills & Automation Guidelines and Core Engineering Standards.
[!CAUTION] Exclusive Execution Tool Policy: Environment upgrades MUST be performed EXCLUSIVELY using the unified development environment CLI
python3 tools/dev_env/dev_env.py gke-upgrade(or legacypython3 ./tools/dev_env/upgrade_dev_env.py). Agents MUST NOT run manualhelm upgrade,kubectl apply,kubectl set image, orgcluster deploycommands for upgrades. If the user does not specify a specific upgrade step, run the entire upgrade script (or run step-by-step using--only <step>or--start-from <step>depending on the prompt). If a step fails or is interrupted, troubleshoot script inputs or resume usingpython3 tools/dev_env/dev_env.py gke-upgrade --start-from <step>or--only <step>.
[!CAUTION] Authentication Integrity Policy: Under no circumstances should
gke-upgradebe invoked withauth.mockAuth="true"orauth.disableAuthentication="true"unless the user explicitly requests and confirms mock authentication. Published images are built without themockauthGo build tag, so every XMC service refuses to start when either flag is true. Always maintain the production OAuth/IAP authentication pipeline configured indeploy/ctk_v2/xmanager-cloud-deployment.yaml.
graph TD
Start[Start Upgrade] --> CheckEnv["Check configuration YAML"]
CheckEnv --> CheckRun["Run python3 tools/dev_env/dev_env.py gke-upgrade --only check"]
CheckRun --> MigrateCheck["Run python3 tools/dev_env/dev_env.py gke-upgrade --only migrate"]
MigrateCheck -->|No pending migrations| AutoRun["Run python3 tools/dev_env/dev_env.py gke-upgrade --start-from images"]
MigrateCheck -->|"Pending migrations (Exit 10)"| PromptUser["Prompt User to run migrations"]
PromptUser -->|User declines| Abort["Abort Upgrade"]
PromptUser -->|User approves| AutoRunMigrate["Run python3 tools/dev_env/dev_env.py gke-upgrade --start-from migrate --run-migrations"]
AutoRunMigrate --> Verify["Verification & Validation"]
AutoRun --> Verify
Verify -->|All checks pass| L["Report completed upgrade & healthy rollout"]
1. Pre-flight CLI & Config Checks
CLI Tool Checks
Before running any upgrade step, verify that the required CLI tools are installed and operational:
| CLI Tool | Verification Command | Expected Successful Outcome |
|---|---|---|
gcloud | gcloud --version | Prints Google Cloud SDK version info |
kubectl | kubectl version --client | Prints Kubernetes client version |
helm | helm version | Prints Helm client version (minimum 3.14.0) |
bazel | bazel --version | Prints Bazel version |
[!CAUTION] Check Action: If any CLI check fails (command not found or returns error):
- Rule out PATH first: Apply PATH-First Diagnosis for Missing CLIs; if the binary is found, add its directory to
PATHand re-run the check.- If still failing, stop execution immediately.
- Alert the user about the missing/broken CLI dependency.
- Provide installation instructions and do not proceed.
Configuration File Verification (YAML)
Verify that the deployment configuration YAML file exists. By default, the script looks for deploy/ctk_v2/xmanager-cloud-deployment.yaml.
If you need to use a custom configuration file, you must pass it using the --config (or -c) flag.
You can optionally define environment variable overrides (e.g., PROJECT_ID, K8S_NAMESPACE, XMANAGER_ENV) in your active shell before running the script to bypass values defined in the YAML configuration. You can copy .env.example to .env and export them: set -o allexport; source .env; set +o allexport.
If no configuration file is found at the default path:
- Search for alternatives: Check if there are any other
*-deployment.yamlfiles indeploy/ctk_v2/. - Handle missing config:
- If other configuration files are found, ask the user which one they want to use and run the script with
--config <path>. - If no configuration files are found, stop execution and instruct the user to create a deployment configuration (referring to
INSTALL.mdor thexmc_deployskill) before upgrading.
- If other configuration files are found, ask the user which one they want to use and run the script with
2. Automated Dev Upgrade (tools/dev_env/dev_env.py gke-upgrade)
Use the unified environment tool (python3 tools/dev_env/dev_env.py gke-upgrade or legacy upgrade_dev_env.py / upgrade command) to execute the environment upgrade.
Step 1: Run Configuration & Authentication Checks
Validate configuration in YAML, authenticate with Google Cloud and GKE, and verify that the target Kubernetes namespace exists:
python3 tools/dev_env/dev_env.py gke-upgrade --only check
Step 2: Check for Pending Database Migrations
Verify if there are any pending Spanner database migrations:
python3 tools/dev_env/dev_env.py gke-upgrade --only migrate
[!IMPORTANT] Migration Decision:
- If the command succeeds (Exit 0): No pending migrations are found. Proceed to Step 3.
- If the command exits with code 10: Pending migrations were detected.
- Stop execution and communicate the pending migrations status to the user.
- Ask the user if they want to run the pending migrations.
- If user says YES: Proceed to Step 3 and append
--run-migrationsflag to the command.- If user says NO: Abort the upgrade workflow and report to the user that upgrade was cancelled due to declined migrations.
Step 3: Execute Upgrade
If no migrations were pending, or if the user approved running migrations:
- Case A: No pending migrations:
Run the upgrade starting from the
imagesstep (skipping migration step):python3 tools/dev_env/dev_env.py gke-upgrade --start-from images - Case B: User approved migrations:
Run the upgrade starting from
migratestep and authorize migration execution:python3 tools/dev_env/dev_env.py gke-upgrade --start-from migrate --run-migrations
[!NOTE] During the
appstep,gke-upgradeautomatically re-compiles the Cluster Toolkit blueprint (gcluster create deploy/ctk_v2/xmanager-cloud.yaml -d ... --force) and exports outputs across prerequisite groups (primary,compute) so that all updated feature flags, environment variables, and Helm values are propagated toctk-out/before applying Kubernetes workload updates.
Resuming or Running Specific Steps (Advanced / Troubleshooting)
If the upgrade fails at a specific phase, or if you need to rerun a specific part of the workflow:
- Resume from a specific step: To resume from a failed phase (
check,migrate,images,app,restart,verify):python3 tools/dev_env/dev_env.py gke-upgrade --start-from <failed_step> - Execute a single step: To execute only one specific step:
Valid steps:python3 tools/dev_env/dev_env.py gke-upgrade --only <step>check,migrate,images,app,restart,verify
4. Verification and Validation
Ensure the Python virtual environment is activated, then run the verification script from the repository root to verify that all upgraded pods are running and endpoints respond correctly:
python3 ./deploy/ctk_v2/verify_xmc.py
[!TIP] Once the verification script reports that all pods are healthy and services are ready, confirm to the user that the XMC environment upgrade is complete and running the current branch state.
Files of this skill
This skill has no supporting files.