Google cloud solution guided gke ai migration

From vaila-multimodaltoolbox/vaila · View interactive version

Google cloud solution guided gke ai migration is an AI agent skill from the GitHub repository vaila-multimodaltoolbox/vaila. Guides the migration of existing AI workloads (Cloud Run, Gemini API, Gemini Enterprise Agent Platform) to self-hosted GKE inference using gcloud and kubectl. Use when the user has an existing AI inference workload (on Cloud Run, the Gemini API, Gemini Enterprise Agent Platform, or a custom VM) and

How to use this skill

Skill file

Migrate AI Workloads to GKE Inference

This skill guides agents through the end-to-end process of migrating existing AI inference workloads (e.g., from Cloud Run, Gemini API, Gemini Enterprise Agent Platform) to self-hosted inference on Google Kubernetes Engine (GKE). The agent will act as an interactive architect, using a structured 4-phase workflow to discover requirements, design a Google Cloud-native solution, execute the implementation using gcloud and kubectl, and validate the deployment.

Gemini Cloud Assist MCP off-ramp

This skill covers manual, architect-guided migration only. Automated migration is the job of the Gemini Cloud Assist MCP server. Route between them as follows:

When stopping for an MCP request, your response MUST include these 4 points:

  1. STOP the manual workflow & clarify scope: State that google-cloud-solution-guided-gke-ai-migration is strictly intended for manual, architect-guided migration using native CLIs (gcloud and kubectl), and that this manual skill workflow is being stopped.
  2. Explain MCP capabilities: Explain that the Gemini Cloud Assist MCP server assists in automated infrastructure analysis (gemini_cloud_assist:ask_cloud_assist) or direct Google Cloud resource mutation (gemini_cloud_assist:invoke_operation).
  3. Link to MCP Documentation: Provide a valid hyperlink to the Gemini Cloud Assist MCP Documentation.
  4. Link to Intent to Infrastructure Codelab: Provide a valid hyperlink to the Intent to Infrastructure Codelab for guidance on setting up the MCP server.

Scope Check: New Deployments vs. Migrations

This skill is specifically intended for migrating existing AI workloads (from Cloud Run, Gemini API, Agent Platform, or other platforms) to GKE.

If the user wants to deploy a new AI model server from scratch on GKE (and does NOT have an existing deployment to migrate), STOP and recommend using the gke-inference skill instead. Explain that google-cloud-solution-guided-gke-ai-migration focuses on migration workflows (discovering existing Cloud Run/Agent Platform configurations, traffic cutover, etc.), while gke-inference is optimized for fresh GKE AI model server deployments using AI Profiles and golden path manifests.

Core Architectural Principles (The "Golden Path")

When designing the solution, always default to the latest GKE AI best practices:

Workflow

The solution design and implementation workflow consists of the following 4 phases:

At the start of every architectural response, print a simple visual progress indicator line to keep both the user and model aligned on the current phase:

**Migration Progress:** [● Discovery] ➔ [○ Solution Design] ➔ [○ Implementation] ➔ [○ Validation]

(Update ● to mark the current active phase, e.g., [● Solution Design] during Phase 2).

Phase Routing Rules

Determine the active phase based on the user's prompt context:

If migration-state.md exists in the current directory, read it before anything else and resume from the recorded phase with the recorded values; only re-ask a discovery question if its value is missing from the file or contradicted by the user's prompt.

Phase 1: Discovery

The goal of Phase 1 is to discover all workload specifications necessary to design and build the target GKE inference infrastructure.

Phase 1 Response Requirements: Every response during Phase 1 MUST begin with the visual progress indicator: **Migration Progress:** [● Discovery] ➔ [○ Solution Design] ➔ [○ Implementation] ➔ [○ Validation].

Discovery Checklist (Attributes to Identify)

The agent must discover or confirm the following 6 core attribute categories:

Discovery Execution (Automated & Interactive)

Phase 2: Solution Design

Based on the discovery phase, design the architecture and manifests needed to accomplish the migration.

Phase 2 Response Requirements: Every response during Phase 2 MUST begin with the visual progress indicator: **Migration Progress:** [○ Discovery] ➔ [● Solution Design] ➔ [○ Implementation] ➔ [○ Validation].

Just-in-Time Context Loading: When evaluating specific architectural choices below (e.g., storage options, load balancing, or autoscaling), fetch and read the relevant reference documentation link from the Supporting links section as needed.

  1. Map components and alternatives: For each major component (e.g., Load Balancing, Autoscaling, Single vs Multi-node), present your recommended "Golden Path" option along with alternatives. If the user requested HPA, ensure the design addresses the LLM Autoscaling Trap and recommends custom metrics (defaulting to Queue Size).
  2. Accelerator Selection: Refer to

GPU platforms or

Plan your TPU configuration in GKE to

recommend the best accelerator for the target model.

(Note: the manifest templates in assets/ are GPU-only. If the user selects Cloud TPU, state this explicitly, and base the serving manifests on the GKE TPU serving documentation instead of the templates in this skill.)

  1. Storage Selection: Refer to GCP AI Storage Options to recommend the best storage solution for model staging and serving.
  2. Hardware & VRAM Sizing: Accurately calculate VRAM using the Deterministic VRAM Sizing Formula below, based on parameters, context window, and quantization. Map to appropriate GPUs (L4, A100, H100).
  3. Cluster & Node Setup: Design the appropriate cluster for the job. Add appropriate sized nodes for the task using Custom Compute Classes (CCC). Design Workload Identity if required. The vLLM Deployment MUST select nodes with nodeSelector: cloud.google.com/compute-class: {compute_class_name} so the workload actually schedules through the ComputeClass. If the user declines CCC and wants on-demand nodes only, replace this selector with cloud.google.com/gke-accelerator: {accelerator_type} and skip ccc-profile.yaml entirely; do not apply a ComputeClass that no workload references.
  4. Model Staging Design: Determine if a staging Job is required based on the source location of the model weights and the target storage solution. If the source is Hugging Face, or if the target is Lustre and source is GCS, plan for a Job to download/copy weights. If the source is GCS and target is GCS FUSE, skip staging. Plan for using Cloud Storage FUSE or Lustre CSI to mount this storage to the workload.
  5. Draft solution architecture and manifests: Read the manifest templates in assets/ (assets/vllm-deployment.yaml.tmpl, assets/ccc-profile.yaml.tmpl, assets/gke-inference-gateway.yaml.tmpl, assets/storage-config.yaml.tmpl, and assets/model-staging-job.yaml.tmpl), substitute the parameters discovered in Phase 1, and save the resulting YAML manifests (vllm-deployment.yaml, ccc-profile.yaml, gke-inference-gateway.yaml, storage-config.yaml, model-staging-job.yaml) to disk in the current directory. When creating vllm-deployment.yaml, explicitly inject any required model-specific architecture flags discovered in Phase 1 (e.g., --trust-remote-code) into the container args array. When creating gke-inference-gateway.yaml, base it on assets/gke-inference-gateway.yaml.tmpl: use gatewayClassName: gke-l7-rilb for the Gateway resource unless the user has explicitly chosen external exposure or the InferencePool-based GKE Inference Gateway, and route /v1 traffic to the vLLM ClusterIP service ({workload_name}-vllm-svc on port 8000) in the HTTPRoute resource. If using a storage class other than gcsfuse-csi (e.g., lustre-csi), remove the gcsfuse.cloud.google.com annotations from storage-config.yaml.
  6. Request review and iterate: Present the generated solution architecture and diagram to the user and request their feedback. Iterate on the design until the user approves it before moving to Phase 3.
Deterministic VRAM Sizing Formula

To accurately calculate VRAM requirements for model serving/inference, use the following deterministic formula:

Hardware & Sizing Recommendation Requirements: When calculating VRAM sizing or recommending hardware:

$$VRAM_{\text{total}} = \left( \frac{\text{Parameters} \times 2}{\text{Quantization}} + KV\_Cache\_Overhead \right) \times 1.2$$

Where:

$$KV\_Cache\_Overhead \,(GB) = \frac{2 \times n_{\text{layers}} \times n_{\text{kv\_heads}} \times d_{\text{head}} \times \text{Context Length} \times \text{Batch Size} \times \text{Precision Bytes}}{10^9}$$

(Rule of thumb: If model layer architecture details are unknown, estimate $KV\_Cache\_Overhead \approx 0.2 \times \text{Model Weight Memory}$).

When mapping the result to an accelerator, compare $VRAM_{\text{total}}$ against the card's full memory (e.g., 24 GB for an L4), not against memory discounted by --gpu-memory-utilization. The 1.2 multiplier and vLLM's utilization cap reserve headroom for the same overheads; applying both double-counts the margin and pushes sizing one accelerator tier too high.

Phase 3: Implementation

Carry out the approved design per the Execution policy: generate the commands below and either hand them to the user or, if the user has asked you to run them, execute them and report the output.

  1. Identify deployment prerequisites: Ensure billing, APIs, and IAM permissions are in place.
  2. Infrastructure Provisioning: Provide explicit gcloud commands to provision storage and cluster prerequisites (such as enabling the Cloud Storage FUSE CSI driver) and configure Workload Identity IAM bindings. Gateway API Pre-flight Check: Explicitly instruct the user to verify the Gateway API is enabled on their cluster. Recommend running gcloud container clusters update <CLUSTER_NAME> --gateway-api=standard before they attempt to apply the routing manifests to prevent CRD-not-found errors.
  3. Storage Provisioning: Create the necessary storage resources (Cloud Storage bucket or Managed Lustre file system).
  4. Model Staging: Apply conditional logic based on the design from Phase 2.
  1. Workload Deployment: Provide explicit kubectl apply commands to deploy the storage config (kubectl apply -f storage-config.yaml), ComputeClass (kubectl apply -f ccc-profile.yaml), vLLM deployment (kubectl apply -f vllm-deployment.yaml), and Inference Gateway (kubectl apply -f gke-inference-gateway.yaml). Ensure the vLLM deployment spec mounts the staged model weights from the PVC into /models. Ensure that if a Secret was created for a gated model, it is referenced correctly in the Deployment manifest. Set vLLM's --model flag to the staged local path (/models/{model_name}), never to the Hugging Face repo ID; a repo ID makes vLLM re-download the full weights on every pod start and silently defeats the staging step. Preserve the model's public name for API clients with --served-model-name={model_id}.
  2. Verify the rollout: Confirm success with kubectl rollout status deployment/{workload_name}-vllm --timeout=30m and kubectl get pods -l app={workload_name}-vllm -o wide. If the rollout fails or times out, go directly to Troubleshooting Guidance with the observed error; do not ask the user whether the deployment succeeded when the command output already answers it. Ask the user only about outcomes the cluster cannot verify (for example, whether response quality matches the source system).

Phase 4: Validation and Cutover

Verify that the deployed infrastructure meets the workload's requirements and provide instructions for traffic migration.

Phase 4 Response Requirements: Every response during Phase 4 MUST begin with the visual progress indicator: **Migration Progress:** [○ Discovery] ➔ [○ Solution Design] ➔ [○ Implementation] ➔ [● Validation].

  1. Health Checks: Recommend explicit health check commands to verify pod, node, and gateway status (kubectl get pods, kubectl get nodes, and kubectl get gateway).
  2. Testing Inference: Verify the service is serving the model. Provide a kubectl port-forward command (kubectl port-forward svc/{workload_name}-vllm-svc 8000:8000) and a sample curl request to /v1/chat/completions to test endpoint inference. Compare responses with the previous infrastructure if applicable.
  3. Traffic Cutover Guidance: Do NOT attempt to implement traffic migration automatically. Instead:
  1. Rollback readiness: Before any traffic moves, confirm the source service stays deployed (scaled down is fine, deleted is not) until the GKE endpoint has served production traffic for a period the user chooses. Provide the single command or config change that restores traffic to the source. Only after the user declares the migration stable, provide the commands to decommission the source service.
  2. Compile Validation Report & Request Final Approval: Compile a validation report summarizing all health check outcomes and inference test results. You MUST explicitly request final user approval to finalize and complete the migration workflow.

Troubleshooting Guidance

When users report issues where pods are created but the inference endpoint is not responding (or request troubleshooting help):

  1. Recommend specific diagnostic commands: kubectl logs {pod_name} (to check container startup logs) and kubectl describe pod {pod_name} (to inspect pod initialization state).
  2. Suggest verifying Google Cloud accelerator quotas (GPU/TPU) in the target region to ensure required resources can be provisioned.
  3. Check for JIT Compilation / Startup Delays: If curl returns Connection refused but the Pod is Running, the serving engine (e.g., vLLM) may still be executing JIT compilation (such as Triton PTX or Torch Inductor) or capturing CUDA graphs. This can take several minutes after model weights are loaded. Advise the user to check kubectl logs {pod_name} and explicitly wait for the Uvicorn running on http://0.0.0.0:8000 (or equivalent) log message before assuming there is a networking issue.
  4. Recommend checking GKE Workload Identity bindings, PVC mount health (Cloud Storage FUSE), and GKE Inference Gateway listener configurations.

Supporting links

Use these references as needed to ground your design choices, answer user questions, and generate implementation manifests:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.