# Proxmox Deployment - Script Reference

**Last Updated**: 2024-12-19

## Overview

This document provides a complete reference for all deployment and utility scripts.

## Script Categories

### Deployment Scripts

#### `quick-deploy.sh`
**Purpose**: Interactive full deployment  
**Usage**: `./scripts/quick-deploy.sh`  
**Description**: Guides through all deployment steps interactively

#### `deploy-crossplane-provider.sh`
**Purpose**: Deploy Crossplane provider to Kubernetes  
**Usage**: `./scripts/deploy-crossplane-provider.sh`  
**Options**:
- `BUILD_PROVIDER=false` - Skip building provider
- `NAMESPACE=crossplane-system` - Target namespace

#### `deploy-test-vms.sh`
**Purpose**: Deploy test VMs to both instances  
**Usage**: `./scripts/deploy-test-vms.sh`  
**Options**:
- `WAIT_TIMEOUT=300` - Timeout in seconds

### Setup Scripts

#### `setup-dns-records.sh`
**Purpose**: Create DNS records via Cloudflare API  
**Usage**: 
```bash
export CLOUDFLARE_ZONE_ID="zone-id"
export CLOUDFLARE_API_TOKEN="token"
./scripts/setup-dns-records.sh
```

#### `setup-proxmox-agents.sh`
**Purpose**: Install agents on Proxmox nodes  
**Usage**: 
```bash
SITE=us-sfvalley NODE=ML110-01 ./scripts/setup-proxmox-agents.sh
```

#### `setup-monitoring.sh`
**Purpose**: Configure Prometheus and Grafana  
**Usage**: `./scripts/setup-monitoring.sh`

#### `setup-dev-environment.sh`
**Purpose**: Set up development environment  
**Usage**: `./scripts/setup-dev-environment.sh`

### Verification Scripts

#### `verify-provider-deployment.sh`
**Purpose**: Verify provider deployment status  
**Usage**: `./scripts/verify-provider-deployment.sh`

#### `test-proxmox-connectivity.sh`
**Purpose**: Test Proxmox connectivity and authentication  
**Usage**: 
```bash
export PROXMOX_TOKEN='user@realm!token-id=token-secret'
./scripts/test-proxmox-connectivity.sh
```

#### `validate-configs.sh`
**Purpose**: Validate all configuration files  
**Usage**: `./scripts/validate-configs.sh`

#### `check-dependencies.sh`
**Purpose**: Check if required dependencies are installed  
**Usage**: `./scripts/check-dependencies.sh`

### Utility Scripts

#### `create-proxmox-secret.sh`
**Purpose**: Create Kubernetes secret for credentials  
**Usage**: `./scripts/create-proxmox-secret.sh`

#### `discover-proxmox-resources.sh`
**Purpose**: Discover Proxmox resources  
**Usage**: `./scripts/discover-proxmox-resources.sh`

## Script Execution Order

### Initial Deployment

1. **Check Dependencies**
   ```bash
   ./scripts/check-dependencies.sh
   ```

2. **Validate Configurations**
   ```bash
   ./scripts/validate-configs.sh
   ```

3. **Test Connectivity**
   ```bash
   ./scripts/test-proxmox-connectivity.sh
   ```

4. **Setup DNS**
   ```bash
   ./scripts/setup-dns-records.sh
   ```

5. **Deploy Provider**
   ```bash
   ./scripts/deploy-crossplane-provider.sh
   ```

6. **Create Secret**
   ```bash
   ./scripts/create-proxmox-secret.sh
   ```

7. **Apply ProviderConfig**
   ```bash
   kubectl apply -f crossplane-provider-proxmox/examples/provider-config.yaml
   ```

8. **Verify Deployment**
   ```bash
   ./scripts/verify-provider-deployment.sh
   ```

9. **Deploy Test VMs**
   ```bash
   ./scripts/deploy-test-vms.sh
   ```

10. **Setup Monitoring**
    ```bash
    ./scripts/setup-monitoring.sh
    ```

### Or Use Quick Deploy

```bash
./scripts/quick-deploy.sh
```

## Environment Variables

### Cloudflare
- `CLOUDFLARE_ZONE_ID` - Cloudflare zone ID
- `CLOUDFLARE_API_TOKEN` - Cloudflare API token
- `DOMAIN` - Domain name (default: sankofa.nexus)

### Proxmox
- `PROXMOX_USERNAME` - Proxmox username
- `PROXMOX_PASSWORD` - Proxmox password
- `PROXMOX_TOKEN` - Proxmox API token

### Kubernetes
- `NAMESPACE` - Target namespace (default: crossplane-system)
- `BUILD_PROVIDER` - Build provider (default: true)

## Script Output

All scripts provide:
- Color-coded output (green=success, red=error, yellow=warning)
- Timestamped logs
- Clear error messages
- Exit codes (0=success, non-zero=failure)

## Troubleshooting

### Script Fails with "command not found"
```bash
# Check if script is executable
chmod +x scripts/*.sh

# Check dependencies
./scripts/check-dependencies.sh
```

### Script Fails with Permission Denied
```bash
# Make script executable
chmod +x scripts/<script-name>.sh
```

### Validation Script Fails
```bash
# Install yamllint
pip3 install yamllint

# Or use Python validation
python3 -c "import yaml; yaml.safe_load_all(open('file.yaml'))"
```

## Related Documentation

- [Quick Start Guide](./QUICK_START.md)
- [Deployment Checklist](./DEPLOYMENT_CHECKLIST.md)
- [Development Guide](./DEVELOPMENT.md)

