/castai-pack:castai-reference-architecturefrom castai-pack
Provides a Terraform module structure and policies for deploying CAST AI across multiple Kubernetes clusters (dev, staging, prod) for cost optimization.
Ships in castai-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Production-grade architecture for managing CAST AI across multiple Kubernetes clusters. Covers Terraform module layout, per-environment policies, API key management, and observability integration.
infrastructure/
├── modules/
│ └── castai-cluster/
│ ├── main.tf # CAST AI provider resources
│ ├── variables.tf # Cluster-specific inputs
│ ├── outputs.tf # Cluster ID, savings metrics
│ ├── policies.tf # Autoscaler policy configuration
│ ├── node-templates.tf # Node template definitions
│ └── security.tf # Kvisor, RBAC
├── environments/
│ ├── dev/
│ │ ├── main.tf # Dev cluster onboarding
│ │ ├── terraform.tfvars # Dev-specific values
│ │ └── backend.tf # State storage
│ ├── staging/
│ │ ├── main.tf
│ │ ├── terraform.tfvars
│ │ └── backend.tf
│ └── prod/
│ ├── main.tf
│ ├── terraform.tfvars
│ └── backend.tf
└── shared/
├── api-keys.tf # Key management
└── monitoring.tf # Alerting rules
# modules/castai-cluster/main.tf
variable "cluster_name" { type = string }
variable "cluster_id" { type = string }
variable "environment" { type = string }
variable "api_token" { type = string; sensitive = true }
variable "provider_type" { type = string } # eks, gke, aks
variable "max_cpu_cores" { type = number; default = 100 }
variable "spot_enabled" { type = bool; default = true }
variable "hibernation_enabled" { type = bool; default = false }
variable "evictor_aggressive" { type = bool; default = false }
resource "castai_autoscaler" "this" {
cluster_id = var.cluster_id
autoscaler_policies_json = jsonencode({
enabled = true
unschedulablePods = {
enabled = true
headroom = {
enabled = true
cpuPercentage = var.environment == "prod" ? 15 : 5
memoryPercentage = var.environment == "prod" ? 15 : 5
}
}
nodeDownscaler = {
enabled = true
emptyNodes = {
enabled = true
delaySeconds = var.environment == "prod" ? 300 : 60
}
}
spotInstances = {
enabled = var.spot_enabled
spotDiversityEnabled = true
}
clusterLimits = {
enabled = true
cpu = { minCores = 2, maxCores = var.max_cpu_cores }
}
})
}
resource "castai_node_template" "default_spot" {
cluster_id = var.cluster_id
name = "${var.environment}-spot-workers"
is_enabled = var.spot_enabled
constraints {
spot = true
use_spot_fallbacks = true
architectures = ["amd64"]
}
}
# environments/dev/terraform.tfvars
environment = "dev"
max_cpu_cores = 16
spot_enabled = true
hibernation_enabled = true # Hibernate off-hours
evictor_aggressive = true # Fast consolidation OK
# environments/prod/terraform.tfvars
environment = "prod"
max_cpu_cores = 200
spot_enabled = true
hibernation_enabled = false # Never hibernate production
evictor_aggressive = false # Conservative eviction
┌─────────────────────┐
│ CAST AI Console │
│ console.cast.ai │
└──────────┬──────────┘
│ API
┌────────────────┼────────────────┐
│ │ │
┌────────▼──────┐ ┌──────▼────────┐ ┌─────▼───────┐
│ Dev (EKS) │ │ Staging (GKE) │ │ Prod (EKS) │
│ Spot: 100% │ │ Spot: 80% │ │ Spot: 60% │
│ Hibernate: Y │ │ Hibernate: N │ │ Hibernate:N│
│ Max: 16 CPU │ │ Max: 50 CPU │ │ Max:200CPU │
└───────────────┘ └───────────────┘ └─────────────┘
│ │ │
┌────────▼──────┐ ┌──────▼────────┐ ┌─────▼───────┐
│ Terraform │ │ Terraform │ │ Terraform │
│ dev/ │ │ staging/ │ │ prod/ │
└───────────────┘ └───────────────┘ └─────────────┘
# Prometheus alert rules for CAST AI
groups:
- name: castai
rules:
- alert: CastAIAgentDown
expr: kube_pod_status_ready{namespace="castai-agent", pod=~"castai-agent.*"} == 0
for: 5m
labels:
severity: critical
annotations:
summary: "CAST AI agent is down on {{ $labels.cluster }}"
- alert: CastAIHighSpotInterruptions
expr: increase(castai_spot_interruptions_total[1h]) > 5
labels:
severity: warning
annotations:
summary: "High spot interruption rate on {{ $labels.cluster }}"
| Issue | Cause | Solution |
|---|---|---|
| State drift between envs | Manual console changes | Enforce Terraform-only policy |
| Module version mismatch | Independent env upgrades | Pin module versions |
| Cross-env key leak | Shared tfvars | Separate state and secrets per env |
| Monitoring gaps | Missing scrape config | Add castai-agent namespace to Prometheus |
This completes the CAST AI skill pack. Start with castai-install-auth for new clusters.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
18 skills in this plugin
/castai-ci-integrationIntegrate CAST AI policy validation and cost checks into CI/CD pipelines.
Use when adding CAST AI savings verification to GitHub Actions,
validating Terraform plans, or gating deployments on cost thresholds.
Trigger with phrases like "cast ai CI", "cast ai github actions",
"cast ai terraform CI", "cast ai pipeline".
/castai-common-errorsDiagnose and fix CAST AI agent, API, and autoscaler errors.
Use when the CAST AI agent is offline, nodes are not scaling,
or API calls return errors.
Trigger with phrases like "cast ai error", "cast ai not working",
"cast ai agent offline", "cast ai debug", "fix cast ai".
/castai-npx claudepluginhub flight505/skill-forge --plugin castai-packOther plugins' skills for the same job