Skip to content
Skillv1.0.0

castai-local-dev-loop

Set up a local Kubernetes development loop with CAST AI cost monitoring. Use when building cost-aware deployments, testing autoscaler policies, or iterating on Terraform CAST AI configurations locally

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/castai-local-dev-loop/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill castai-local-dev-loop. Copyright stays with the author (MIT).

CAST AI Local Dev Loop

Overview

Fast iteration workflow for CAST AI integrations: test autoscaler policies in a dev cluster, validate Terraform modules before applying to production, and use the CAST AI API to measure savings impact during development.

Prerequisites

  • Completed castai-install-auth setup
  • A development Kubernetes cluster (kind, minikube, or cloud dev cluster)
  • kubectl, helm, and optionally terraform installed

Instructions

Step 1: Project Structure

my-castai-infra/
├── terraform/
│   ├── environments/
│   │   ├── dev.tfvars
│   │   ├── staging.tfvars
│   │   └── prod.tfvars
│   ├── modules/
│   │   └── castai-cluster/
│   │       ├── main.tf
│   │       ├── variables.tf
│   │       └── outputs.tf
│   └── main.tf
├── policies/
│   ├── dev-policy.json
│   └── prod-policy.json
├── scripts/
│   ├── check-savings.sh
│   └── validate-policies.sh
├── .env.dev            # Dev API key (git-ignored)
└── .env.example

Step 2: Dev Cluster with Relaxed Policies

# Connect your dev cluster (read-only first)
helm upgrade --install castai-agent castai-helm/castai-agent \
  -n castai-agent --create-namespace \
  --set apiKey="${CASTAI_API_KEY_DEV}" \
  --set provider="eks"

# Apply development-safe autoscaler policy
curl -X PUT -H "X-API-Key: ${CASTAI_API_KEY_DEV}" \
  -H "Content-Type: application/json" \
  "https://api.cast.ai/v1/kubernetes/clusters/${CASTAI_CLUSTER_ID}/policies" \
  -d '{
    "enabled": true,
    "unschedulablePods": { "enabled": true },
    "nodeDownscaler": {
      "enabled": true,
      "emptyNodes": { "enabled": true, "delaySeconds": 300 }
    },
    "clusterLimits": {
      "enabled": true,
      "cpu": { "minCores": 2, "maxCores": 16 }
    }
  }'

Step 3: Quick Savings Check Script

#!/bin/bash
# scripts/check-savings.sh
set -euo pipefail

API_KEY="${CASTAI_API_KEY_DEV}"
CLUSTER_ID="${CASTAI_CLUSTER_ID}"

echo "=== CAST AI Dev Cluster Savings ==="
curl -s -H "X-API-Key: ${API_KEY}" \
  "https://api.cast.ai/v1/kubernetes/clusters/${CLUSTER_ID}/savings" \
  | jq '{
    monthlySavings: .monthlySavings,
    percentage: .savingsPercentage,
    spotNodes: [.nodes[] | select(.lifecycle == "spot")] | length,
    totalNodes: [.nodes[]] | length
  }'

Step 4: Terraform Plan-Apply Loop

# Plan with dev variables
cd terraform/
terraform plan -var-file=environments/dev.tfvars -out=plan.tfplan

# Apply and check CAST AI result
terraform apply plan.tfplan

# Verify policies took effect
curl -s -H "X-API-Key: ${CASTAI_API_KEY_DEV}" \
  "https://api.cast.ai/v1/kubernetes/clusters/${CASTAI_CLUSTER_ID}/policies" \
  | jq .

Step 5: Watch Node Changes in Real Time

# Terminal 1: Watch CAST AI node operations
watch -n 15 'curl -s -H "X-API-Key: ${CASTAI_API_KEY_DEV}" \
  "https://api.cast.ai/v1/kubernetes/external-clusters/${CASTAI_CLUSTER_ID}/nodes" \
  | jq "[.items[] | {name, instanceType, lifecycle, age: .createdAt}] | length"'

# Terminal 2: Watch kubectl node status
kubectl get nodes -w

Error Handling

Error Cause Solution
Dev cluster not found Wrong cluster ID List clusters with API first
Policy rejected Invalid JSON Validate with jq . < policy.json
Terraform drift Manual console changes Run terraform refresh
Agent offline after restart Helm release stale helm upgrade --install again

Output

The local loop produces a versioned plan, non-production policy result, agent health check, and observed node/policy evidence. Keep development credentials and cluster identifiers isolated from production; a plan or console result is not permission to apply a change to another environment.

Examples

Run terraform plan against a disposable development cluster, inspect the saved plan for destructive changes, then apply only after a reviewer accepts the diff. Confirm policy state and node behavior, and destroy or reset the test resources after observation so temporary optimization settings cannot quietly persist into a later test.

Resources

Next Steps

See castai-sdk-patterns for reusable API wrapper patterns.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-castai-local-b44309/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-castai-local-b44309.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-castai-local-b44309",
  "kind": "skill",
  "name": "castai-local-dev-loop",
  "description": "Set up a local Kubernetes development loop with CAST AI cost monitoring. Use when building cost-aware deployments, testing autoscaler policies, or iterating on Terraform CAST AI configurations locally. Trigger with phrases like \"cast ai dev setup\", \"cast ai local testing\", \"develop with cast ai\", \"cast ai terraform dev\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "saas",
      "kubernetes",
      "cost-optimization",
      "castai",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Set up a local Kubernetes development loop with CAST AI cost monitoring. Use when building cost-aware deployments, testing autoscaler policies, or iterating on Terraform CAST AI configurations locally. Trigger with phrases like \"cast ai dev setup\", \"cast ai local testing\", \"develop with cast ai\", \"cast ai terraform dev\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/castai-local-dev-loop/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/castai-local-dev-loop/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/castai-local-dev-loop/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Bash(kubectl:*),",
      "Bash(helm:*),",
      "Bash(terraform:*),",
      "Grep"
    ],
    "license": "MIT"
  },
  "instructions": "# CAST AI Local Dev Loop\n\n## Overview\n\nFast iteration workflow for CAST AI integrations: test autoscaler policies in a dev cluster, validate Terraform modules before applying to production, and use the CAST AI API to measure savings impact during development.\n\n## Prerequisites\n\n- Completed `castai-install-auth` setup\n- A development Kubernetes cluster (kind, minikube, or cloud dev cluster)\n- `kubectl`, `helm`, and optionally `terraform` installed\n\n## Instructions\n\n### Step 1: Project Structure\n\n```\nmy-castai-infra/\n├── terraform/\n│   ├── environments/\n│   │   ├── dev.tfvars\n│   │   ├── staging",
  "cost": {
    "context_tokens": 1105
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-castai-local-b44309/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.