Get up and running with Cluster Code in minutes. This guide will walk you through installation, initial configuration, and your first cluster operations.
Before installing Cluster Code, ensure you have:
az) 2.50+ for Azure operations (Install)aws) 2.13+ for AWS operations (Install)oc) 4.15+ for OpenShift features (Install)# Install globally (scoped package)
npm install -g @cluster-code/cluster-code
# Or install the unscoped alias
npm install -g cluster-code
# Verify installation
cluster-code --version
# Clone repository
git clone https://github.com/kcns008/cluster-code.git
cd cluster-code
# Install dependencies
npm install
# Link for global use
npm link
# Verify installation
cluster-code --version
# Run without installing (scoped package)
npx @cluster-code/cluster-code <command>
# Example
npx @cluster-code/cluster-code diagnose
# Or use the unscoped alias
npx cluster-code diagnose
Cluster Code uses a hierarchical configuration system:
# Initialize configuration (creates ~/.cluster-code/config.json)
cluster-code config init
# Or use project-specific configuration
cluster-code config init --project
Based on which clouds you’ll use, configure credentials:
# Login to Azure
az login
# Set default subscription
az account set --subscription <subscription-id>
# Configure Cluster Code
cluster-code config set cloud_providers.azure.enabled true
cluster-code config set cloud_providers.azure.subscription_id "<subscription-id>"
# Configure AWS credentials
aws configure
# Configure Cluster Code
cluster-code config set cloud_providers.aws.enabled true
cluster-code config set cloud_providers.aws.region "us-east-1"
# Login to GCP
gcloud auth login
# Set project
gcloud config set project <project-id>
# Configure Cluster Code
cluster-code config set cloud_providers.gcp.enabled true
cluster-code config set cloud_providers.gcp.project_id "<project-id>"
Enable the plugins you need:
# Enable core plugins (enabled by default)
cluster-code config set plugins.cluster-core.enabled true
cluster-code config set plugins.k8sgpt-analyzers.enabled true
# Enable cloud provider plugins
cluster-code config set plugins.cloud-azure.enabled true
cluster-code config set plugins.cloud-aws.enabled true
cluster-code config set plugins.cloud-gcp.enabled true
# Enable OpenShift features
cluster-code config set plugins.cluster-openshift.enabled true
# Enable GitOps workflows
cluster-code config set plugins.gitops.enabled true
If you already have a Kubernetes/OpenShift cluster:
# List available contexts
kubectl config get-contexts
# Initialize Cluster Code with specific context
cluster-code init --context my-cluster-context --namespace default
# Verify connection
cluster-code status
# Create AKS cluster
cluster-code azure-cluster-create \
--type aks \
--name my-first-aks \
--resource-group my-rg \
--region eastus \
--nodes 3
# Connect to cluster (automatic after creation)
cluster-code azure-cluster-connect \
--name my-first-aks \
--resource-group my-rg
# Create EKS cluster
cluster-code aws-cluster-create \
--type eks \
--name my-first-eks \
--region us-east-1 \
--nodes 2
# Connect to cluster (automatic after creation)
cluster-code aws-cluster-connect \
--name my-first-eks \
--region us-east-1
# Quick health check
cluster-code status
# Detailed cluster information
cluster-code status --detailed
Expected Output:
Cluster Health Summary:
✅ API Server: Healthy
✅ Nodes: All Ready (3/3)
✅ System Pods: All Running
✅ Resource Usage: Normal (CPU: 25%, Memory: 40%)
Connected to: my-first-aks
Kubernetes Version: 1.28.9
Nodes: 3
Namespaces: 12
# Comprehensive cluster diagnostics
cluster-code diagnose
# Diagnose specific namespace
cluster-code diagnose --namespace production
# Analyze specific resource type
cluster-code diagnose --analyzer pod
What it does:
# List nodes with health status
cluster-code node-status
# List pods with issues
cluster-code analyze pod --all-namespaces
# View service connectivity
cluster-code service-describe --all-namespaces
# Start interactive chat session
cluster-code chat
# Or ask specific questions
cluster-code chat "Why is my pod in CrashLoopBackOff?"
cluster-code chat "How do I scale my deployment?"
cluster-code chat "Show me pods with high memory usage"
# Add Helm repository
helm repo add bitnami https://charts.bitnami.com/bitnami
# Deploy nginx with Cluster Code
cluster-code helm-deploy \
--chart bitnami/nginx \
--release my-nginx \
--namespace web \
--create-namespace
# Check deployment status
kubectl get pods -n web
# Create a simple kustomization
mkdir -p my-app/base
cat > my-app/base/kustomization.yaml <<EOF
resources:
- deployment.yaml
- service.yaml
EOF
# Apply with Cluster Code
cluster-code kustomize-apply --path ./my-app/base
#!/bin/bash
# Save as daily-health-check.sh
echo "🏥 Daily Cluster Health Check"
echo "=============================="
echo ""
# Check cluster status
cluster-code status --detailed
# Run diagnostics
cluster-code diagnose --severity-threshold warning
# Check node health
cluster-code node-status
# Check for expiring certificates (OpenShift)
if kubectl get routes &>/dev/null; then
cluster-code routes-analyze --all-namespaces
fi
echo ""
echo "✅ Health check complete!"
#!/bin/bash
# Deploy complete application stack
# 1. Create namespace
kubectl create namespace myapp
# 2. Deploy database
cluster-code helm-deploy \
--chart bitnami/postgresql \
--release myapp-db \
--namespace myapp \
--set postgresqlPassword=secret123
# 3. Deploy application
cluster-code kustomize-apply \
--path ./app/overlays/production \
--namespace myapp \
--wait
# 4. Verify deployment
cluster-code diagnose --namespace myapp
#!/bin/bash
# Troubleshoot failing pods
POD_NAME="my-app-xyz"
NAMESPACE="production"
echo "🔍 Troubleshooting pod: $POD_NAME"
echo ""
# 1. Analyze pod with AI
cluster-code analyze pod $POD_NAME --namespace $NAMESPACE
# 2. Get detailed resource description
cluster-code resource-describe pod $POD_NAME --namespace $NAMESPACE --analyze
# 3. View logs with pattern analysis
cluster-code pod-logs $POD_NAME --namespace $NAMESPACE --analyze --tail 100
# 4. Interactive troubleshooting
cluster-code chat "Help me fix pod $POD_NAME in $NAMESPACE namespace"
Create .cluster-code.json in your project root:
{
"cluster": {
"default_context": "production-cluster",
"default_namespace": "myapp"
},
"plugins": {
"k8sgpt-analyzers": {
"enabled": true,
"analysis_depth": "deep"
},
"gitops": {
"enabled": true,
"default_tool": "helm"
}
},
"diagnostics": {
"severity_threshold": "warning",
"exclude_namespaces": ["kube-system", "kube-public"]
}
}
Override configuration with environment variables:
# Set default cluster context
export CLUSTER_CODE_CONTEXT="my-cluster"
# Set log level
export CLUSTER_CODE_LOG_LEVEL="debug"
# Use local LLM
export CLUSTER_CODE_LLM_PROVIDER="local"
export CLUSTER_CODE_LLM_ENDPOINT="http://localhost:8080"
For privacy and cost control, use self-hosted LLMs:
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Pull a model
ollama pull deepseek-coder-v2:16b
# Configure Cluster Code
cluster-code config set ai.provider "local"
cluster-code config set ai.local_endpoint "http://localhost:11434"
cluster-code config set ai.model "deepseek-coder-v2:16b"
# Install LiteLLM
pip install litellm
# Start proxy
litellm --model ollama/deepseek-coder-v2
# Configure Cluster Code
cluster-code config set ai.provider "local"
cluster-code config set ai.local_endpoint "http://localhost:8000"
Learn more about Local LLM Support
If cluster-code command is not found after installation:
# Check npm global bin directory
npm config get prefix
# Add to PATH (Linux/Mac)
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
# Or reinstall with sudo (not recommended)
sudo npm install -g @cluster-code/cluster-code
# Or install the unscoped alias
sudo npm install -g cluster-code
# Fix npm permissions (Linux/Mac)
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Reinstall
npm install -g @cluster-code/cluster-code
# Or install the unscoped alias
npm install -g cluster-code
# List installed plugins
cluster-code plugin list
# Reinstall plugin
cluster-code plugin install cloud-azure
# Or manually enable in config
cluster-code config set plugins.cloud-azure.enabled true
Now that you have Cluster Code installed and configured, explore:
If you run into issues:
cluster-code --log-level debug <command>cluster-code config showWelcome to Cluster Code! 🎉