enhancement: Add installation and configuration helper scripts #36

Open
opened 2026-02-22 13:12:42 +00:00 by cpfarhood · 0 comments
cpfarhood commented 2026-02-22 13:12:42 +00:00 (Migrated from github.com)

Summary

Add interactive helper scripts to simplify installation, configuration, and maintenance of the dev container Helm deployment.

Proposed Helper Scripts

1. Interactive Installer (chart/scripts/install.sh)

Features:

  • Interactive prompts for common configuration
  • Environment detection and recommendations
  • Secret creation assistance
  • Deployment validation
#!/bin/bash
# Interactive installer for dev container

echo "🚀 Dev Container Interactive Installer"
echo "======================================"

# Prompt for basic configuration
read -p "Instance name (e.g., mydev): " NAME
read -p "GitHub repository URL: " GITHUB_REPO
read -p "IDE choice [vscode|antigravity|none]: " IDE_TYPE

# Detect environment
echo "🔍 Detecting Kubernetes environment..."
STORAGE_CLASSES=$(kubectl get storageclass -o name | wc -l)
if [ $STORAGE_CLASSES -gt 0 ]; then
    echo "✅ Found $STORAGE_CLASSES storage classes"
else
    echo "⚠️  No storage classes found"
fi

# Generate values file
cat > my-devcontainer-values.yaml <<EOF
name: $NAME
githubRepo: $GITHUB_REPO
ide:
  type: $IDE_TYPE
EOF

# Install
helm install $NAME ./chart -f my-devcontainer-values.yaml

2. Configuration Helper (chart/scripts/configure.sh)

Features:

  • Post-installation configuration
  • Secret management
  • MCP sidecar configuration
  • Access setup (port-forward, ingress)
#!/bin/bash
# Post-installation configuration helper

DEPLOYMENT_NAME="$1"

echo "🔧 Configuring Dev Container: $DEPLOYMENT_NAME"

# Secret configuration
echo "Setting up secrets..."
read -s -p "GitHub token (optional): " GITHUB_TOKEN
read -s -p "VNC password (optional): " VNC_PASSWORD

if [ ! -z "$GITHUB_TOKEN" ] || [ ! -z "$VNC_PASSWORD" ]; then
    kubectl create secret generic devcontainer-$DEPLOYMENT_NAME-secrets-env \
        ${GITHUB_TOKEN:+--from-literal=GITHUB_TOKEN="$GITHUB_TOKEN"} \
        ${VNC_PASSWORD:+--from-literal=VNC_PASSWORD="$VNC_PASSWORD"}
fi

# Access setup
echo "🌐 Setting up access..."
echo "Choose access method:"
echo "1) Port-forward (local access)"
echo "2) Create ingress (cluster access)"  
echo "3) LoadBalancer service (cloud)"
read -p "Choice [1-3]: " ACCESS_METHOD

case $ACCESS_METHOD in
    1) 
        echo "Starting port-forward on http://localhost:5800"
        kubectl port-forward deployment/devcontainer-$DEPLOYMENT_NAME 5800:5800 &
        ;;
    2)
        # Create ingress
        ;;
    3)
        # Patch service to LoadBalancer
        ;;
esac

3. Upgrade Helper (chart/scripts/upgrade.sh)

Features:

  • Safe upgrade process with backup
  • Configuration migration
  • Rollback capability
  • Health checks
#!/bin/bash
# Safe upgrade helper

RELEASE_NAME="$1"
VALUES_FILE="$2"

echo "🔄 Upgrading Dev Container: $RELEASE_NAME"

# Backup current configuration
echo "Creating configuration backup..."
helm get values $RELEASE_NAME > backup-$RELEASE_NAME-$(date +%Y%m%d).yaml

# Pre-upgrade health check
kubectl rollout status deployment/devcontainer-$RELEASE_NAME

# Perform upgrade
echo "Performing upgrade..."
helm upgrade $RELEASE_NAME ./chart -f $VALUES_FILE

# Post-upgrade validation
echo "Validating upgrade..."
kubectl rollout status deployment/devcontainer-$RELEASE_NAME

if [ $? -eq 0 ]; then
    echo "✅ Upgrade successful!"
else
    echo "❌ Upgrade failed, rolling back..."
    helm rollback $RELEASE_NAME
fi

4. Diagnostic Helper (chart/scripts/diagnose.sh)

Features:

  • Health check diagnostics
  • Common issue detection
  • Log collection
  • Configuration validation
#!/bin/bash
# Diagnostic and troubleshooting helper

RELEASE_NAME="$1"

echo "🏥 Dev Container Diagnostics: $RELEASE_NAME"
echo "=========================================="

# Basic health checks
echo "📋 Basic Health Checks"
kubectl get deployment devcontainer-$RELEASE_NAME
kubectl get pods -l instance=$RELEASE_NAME
kubectl get pvc userhome-$RELEASE_NAME

# Resource usage
echo -e "\n💾 Resource Usage"
kubectl top pod -l instance=$RELEASE_NAME

# Recent events
echo -e "\n📅 Recent Events"
kubectl get events --field-selector involvedObject.name=devcontainer-$RELEASE_NAME

# Common issues
echo -e "\n🔍 Common Issue Checks"

# Check storage class
STORAGE_CLASS=$(helm get values $RELEASE_NAME -o json | jq -r '.storage.className')
if ! kubectl get storageclass $STORAGE_CLASS >/dev/null 2>&1; then
    echo "❌ Storage class '$STORAGE_CLASS' not found"
fi

# Check secrets
SECRET_NAME=$(helm get values $RELEASE_NAME -o json | jq -r '.envSecretName // "devcontainer-'$RELEASE_NAME'-secrets-env"')
if ! kubectl get secret $SECRET_NAME >/dev/null 2>&1; then
    echo "⚠️  Secret '$SECRET_NAME' not found (optional)"
fi

# Port accessibility
echo -e "\n🌐 Access Test"
kubectl port-forward deployment/devcontainer-$RELEASE_NAME 5800:5800 --timeout=5s >/dev/null 2>&1 &
PORT_FORWARD_PID=$!
sleep 2
if kill -0 $PORT_FORWARD_PID 2>/dev/null; then
    echo "✅ Port-forward successful"
    kill $PORT_FORWARD_PID
else
    echo "❌ Port-forward failed"
fi

5. Cleanup Helper (chart/scripts/cleanup.sh)

Features:

  • Safe resource cleanup
  • PVC data preservation options
  • Complete removal or partial cleanup
#!/bin/bash
# Cleanup helper with data preservation options

RELEASE_NAME="$1"

echo "🧹 Dev Container Cleanup: $RELEASE_NAME"

echo "What would you like to clean up?"
echo "1) Helm release only (keep PVC data)"
echo "2) Release + ConfigMaps/Secrets"  
echo "3) Complete cleanup (WARNING: deletes PVC data)"
read -p "Choice [1-3]: " CLEANUP_LEVEL

case $CLEANUP_LEVEL in
    1)
        helm uninstall $RELEASE_NAME
        ;;
    2) 
        helm uninstall $RELEASE_NAME
        kubectl delete secret devcontainer-$RELEASE_NAME-secrets-env --ignore-not-found
        kubectl delete configmap devcontainer-$RELEASE_NAME-config --ignore-not-found
        ;;
    3)
        read -p "This will DELETE ALL DATA. Type 'DELETE' to confirm: " CONFIRM
        if [ "$CONFIRM" = "DELETE" ]; then
            helm uninstall $RELEASE_NAME
            kubectl delete pvc userhome-$RELEASE_NAME --ignore-not-found
            kubectl delete secret devcontainer-$RELEASE_NAME-secrets-env --ignore-not-found
        else
            echo "Cleanup cancelled"
        fi
        ;;
esac

Script Features

Common Functionality

  • Color-coded output for better UX
  • Progress indicators
  • Error handling and rollback
  • Logging and audit trails
  • Cross-platform compatibility (Linux/macOS)

Integration with Chart

# Makefile integration
install-interactive:
	./scripts/install.sh

upgrade-safe:
	./scripts/upgrade.sh $(RELEASE) $(VALUES_FILE)

diagnose:
	./scripts/diagnose.sh $(RELEASE)

Benefits

  • Lower Barrier to Entry: Non-Helm experts can deploy easily
  • Reduced Errors: Interactive validation prevents common mistakes
  • Faster Troubleshooting: Built-in diagnostics
  • Safer Operations: Backup and rollback capabilities
  • Better UX: User-friendly interactive experience

Implementation Plan

  • Create basic interactive installer
  • Add configuration helper for secrets/access
  • Implement upgrade helper with safety checks
  • Build diagnostic and troubleshooting tools
  • Add cleanup helper with data protection
  • Test scripts across different environments
  • Add script documentation and examples
  • Integrate with main project documentation
## Summary Add interactive helper scripts to simplify installation, configuration, and maintenance of the dev container Helm deployment. ## Proposed Helper Scripts ### 1. Interactive Installer (`chart/scripts/install.sh`) **Features**: - Interactive prompts for common configuration - Environment detection and recommendations - Secret creation assistance - Deployment validation ```bash #!/bin/bash # Interactive installer for dev container echo "🚀 Dev Container Interactive Installer" echo "======================================" # Prompt for basic configuration read -p "Instance name (e.g., mydev): " NAME read -p "GitHub repository URL: " GITHUB_REPO read -p "IDE choice [vscode|antigravity|none]: " IDE_TYPE # Detect environment echo "🔍 Detecting Kubernetes environment..." STORAGE_CLASSES=$(kubectl get storageclass -o name | wc -l) if [ $STORAGE_CLASSES -gt 0 ]; then echo "✅ Found $STORAGE_CLASSES storage classes" else echo "⚠️ No storage classes found" fi # Generate values file cat > my-devcontainer-values.yaml <<EOF name: $NAME githubRepo: $GITHUB_REPO ide: type: $IDE_TYPE EOF # Install helm install $NAME ./chart -f my-devcontainer-values.yaml ``` ### 2. Configuration Helper (`chart/scripts/configure.sh`) **Features**: - Post-installation configuration - Secret management - MCP sidecar configuration - Access setup (port-forward, ingress) ```bash #!/bin/bash # Post-installation configuration helper DEPLOYMENT_NAME="$1" echo "🔧 Configuring Dev Container: $DEPLOYMENT_NAME" # Secret configuration echo "Setting up secrets..." read -s -p "GitHub token (optional): " GITHUB_TOKEN read -s -p "VNC password (optional): " VNC_PASSWORD if [ ! -z "$GITHUB_TOKEN" ] || [ ! -z "$VNC_PASSWORD" ]; then kubectl create secret generic devcontainer-$DEPLOYMENT_NAME-secrets-env \ ${GITHUB_TOKEN:+--from-literal=GITHUB_TOKEN="$GITHUB_TOKEN"} \ ${VNC_PASSWORD:+--from-literal=VNC_PASSWORD="$VNC_PASSWORD"} fi # Access setup echo "🌐 Setting up access..." echo "Choose access method:" echo "1) Port-forward (local access)" echo "2) Create ingress (cluster access)" echo "3) LoadBalancer service (cloud)" read -p "Choice [1-3]: " ACCESS_METHOD case $ACCESS_METHOD in 1) echo "Starting port-forward on http://localhost:5800" kubectl port-forward deployment/devcontainer-$DEPLOYMENT_NAME 5800:5800 & ;; 2) # Create ingress ;; 3) # Patch service to LoadBalancer ;; esac ``` ### 3. Upgrade Helper (`chart/scripts/upgrade.sh`) **Features**: - Safe upgrade process with backup - Configuration migration - Rollback capability - Health checks ```bash #!/bin/bash # Safe upgrade helper RELEASE_NAME="$1" VALUES_FILE="$2" echo "🔄 Upgrading Dev Container: $RELEASE_NAME" # Backup current configuration echo "Creating configuration backup..." helm get values $RELEASE_NAME > backup-$RELEASE_NAME-$(date +%Y%m%d).yaml # Pre-upgrade health check kubectl rollout status deployment/devcontainer-$RELEASE_NAME # Perform upgrade echo "Performing upgrade..." helm upgrade $RELEASE_NAME ./chart -f $VALUES_FILE # Post-upgrade validation echo "Validating upgrade..." kubectl rollout status deployment/devcontainer-$RELEASE_NAME if [ $? -eq 0 ]; then echo "✅ Upgrade successful!" else echo "❌ Upgrade failed, rolling back..." helm rollback $RELEASE_NAME fi ``` ### 4. Diagnostic Helper (`chart/scripts/diagnose.sh`) **Features**: - Health check diagnostics - Common issue detection - Log collection - Configuration validation ```bash #!/bin/bash # Diagnostic and troubleshooting helper RELEASE_NAME="$1" echo "🏥 Dev Container Diagnostics: $RELEASE_NAME" echo "==========================================" # Basic health checks echo "📋 Basic Health Checks" kubectl get deployment devcontainer-$RELEASE_NAME kubectl get pods -l instance=$RELEASE_NAME kubectl get pvc userhome-$RELEASE_NAME # Resource usage echo -e "\n💾 Resource Usage" kubectl top pod -l instance=$RELEASE_NAME # Recent events echo -e "\n📅 Recent Events" kubectl get events --field-selector involvedObject.name=devcontainer-$RELEASE_NAME # Common issues echo -e "\n🔍 Common Issue Checks" # Check storage class STORAGE_CLASS=$(helm get values $RELEASE_NAME -o json | jq -r '.storage.className') if ! kubectl get storageclass $STORAGE_CLASS >/dev/null 2>&1; then echo "❌ Storage class '$STORAGE_CLASS' not found" fi # Check secrets SECRET_NAME=$(helm get values $RELEASE_NAME -o json | jq -r '.envSecretName // "devcontainer-'$RELEASE_NAME'-secrets-env"') if ! kubectl get secret $SECRET_NAME >/dev/null 2>&1; then echo "⚠️ Secret '$SECRET_NAME' not found (optional)" fi # Port accessibility echo -e "\n🌐 Access Test" kubectl port-forward deployment/devcontainer-$RELEASE_NAME 5800:5800 --timeout=5s >/dev/null 2>&1 & PORT_FORWARD_PID=$! sleep 2 if kill -0 $PORT_FORWARD_PID 2>/dev/null; then echo "✅ Port-forward successful" kill $PORT_FORWARD_PID else echo "❌ Port-forward failed" fi ``` ### 5. Cleanup Helper (`chart/scripts/cleanup.sh`) **Features**: - Safe resource cleanup - PVC data preservation options - Complete removal or partial cleanup ```bash #!/bin/bash # Cleanup helper with data preservation options RELEASE_NAME="$1" echo "🧹 Dev Container Cleanup: $RELEASE_NAME" echo "What would you like to clean up?" echo "1) Helm release only (keep PVC data)" echo "2) Release + ConfigMaps/Secrets" echo "3) Complete cleanup (WARNING: deletes PVC data)" read -p "Choice [1-3]: " CLEANUP_LEVEL case $CLEANUP_LEVEL in 1) helm uninstall $RELEASE_NAME ;; 2) helm uninstall $RELEASE_NAME kubectl delete secret devcontainer-$RELEASE_NAME-secrets-env --ignore-not-found kubectl delete configmap devcontainer-$RELEASE_NAME-config --ignore-not-found ;; 3) read -p "This will DELETE ALL DATA. Type 'DELETE' to confirm: " CONFIRM if [ "$CONFIRM" = "DELETE" ]; then helm uninstall $RELEASE_NAME kubectl delete pvc userhome-$RELEASE_NAME --ignore-not-found kubectl delete secret devcontainer-$RELEASE_NAME-secrets-env --ignore-not-found else echo "Cleanup cancelled" fi ;; esac ``` ## Script Features ### Common Functionality - Color-coded output for better UX - Progress indicators - Error handling and rollback - Logging and audit trails - Cross-platform compatibility (Linux/macOS) ### Integration with Chart ```yaml # Makefile integration install-interactive: ./scripts/install.sh upgrade-safe: ./scripts/upgrade.sh $(RELEASE) $(VALUES_FILE) diagnose: ./scripts/diagnose.sh $(RELEASE) ``` ## Benefits - **Lower Barrier to Entry**: Non-Helm experts can deploy easily - **Reduced Errors**: Interactive validation prevents common mistakes - **Faster Troubleshooting**: Built-in diagnostics - **Safer Operations**: Backup and rollback capabilities - **Better UX**: User-friendly interactive experience ## Implementation Plan - [ ] Create basic interactive installer - [ ] Add configuration helper for secrets/access - [ ] Implement upgrade helper with safety checks - [ ] Build diagnostic and troubleshooting tools - [ ] Add cleanup helper with data protection - [ ] Test scripts across different environments - [ ] Add script documentation and examples - [ ] Integrate with main project documentation
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: farhoodlabs/devcontainer#36