# Chain-138 Infrastructure Deployment Guide

## 🚀 Deployment Phases

### Phase 1: Azure Infrastructure (Terraform)
Deploys Azure resources:
- Resource Group
- AKS Cluster
- Key Vault
- Storage Account
- Network Resources

**Commands:**
```bash
./scripts/deployment/deploy-infrastructure-phase1.sh
# Or manually:
cd terraform
terraform init
terraform plan
terraform apply
```

### Phase 2: Kubernetes Resources
Creates Kubernetes namespace and base resources:
- Namespace: besu-network
- Service Accounts
- RBAC
- ConfigMaps

**Commands:**
```bash
./scripts/deployment/deploy-infrastructure-phase2.sh
# Or manually:
kubectl create namespace besu-network
kubectl apply -k k8s/base
```

### Phase 3: Besu Network
Deploys Besu network components:
- Validators (Helm)
- Sentries (Helm)
- RPC Nodes (Helm)

**Commands:**
```bash
./scripts/deployment/deploy-infrastructure-phase3.sh
# Or manually:
helm install besu-validators ./helm/besu-network -f helm/besu-network/values-validators.yaml -n besu-network
helm install besu-sentries ./helm/besu-network -f helm/besu-network/values-sentries.yaml -n besu-network
helm install besu-rpc ./helm/besu-network -f helm/besu-network/values-rpc.yaml -n besu-network
```

### Phase 4: Monitoring and Explorer
Deploys monitoring stack:
- Prometheus
- Grafana
- Blockscout Explorer

**Commands:**
```bash
./scripts/deployment/deploy-infrastructure-phase4.sh
```

## 📋 Quick Start

### All Phases at Once
```bash
./scripts/deployment/deploy-infrastructure-all-phases.sh
```

### Step by Step
```bash
# 1. Check prerequisites
./scripts/deployment/deploy-chain138-infrastructure.sh

# 2. Begin deployment
./scripts/deployment/begin-infrastructure-deployment.sh

# 3. Deploy phases
./scripts/deployment/deploy-infrastructure-phase1.sh
./scripts/deployment/deploy-infrastructure-phase2.sh
./scripts/deployment/deploy-infrastructure-phase3.sh
./scripts/deployment/deploy-infrastructure-phase4.sh

# 4. Verify
./scripts/deployment/verify-chain138-complete.sh
```

## ✅ Prerequisites

- Azure CLI installed and authenticated
- Terraform >= 1.0
- kubectl configured
- Helm 3.x
- Besu CLI tools (for genesis)

## 🔧 Configuration

### Terraform
Edit `terraform/terraform.tfvars` with your values:
- Resource group name
- Region
- Cluster configuration
- Network settings

### Kubernetes
Ensure kubeconfig is set:
```bash
az aks get-credentials --resource-group <rg> --name <cluster>
```

### Genesis
Ensure `genesis.json` exists with WETH9/WETH10 predeployed.

## 📊 Verification

After deployment, verify:
```bash
# Check pods
kubectl get pods -n besu-network
kubectl get pods -n monitoring

# Check services
kubectl get svc -n besu-network

# Run verification
./scripts/deployment/verify-chain138-complete.sh
```

## 🎯 Next Steps

After infrastructure deployment:
1. Get RPC endpoint
2. Update .env with RPC URL
3. Deploy contracts
4. Configure bridges
5. Test cross-chain transfers
