# Build and Deploy Instructions

**Date**: 2025-12-11  
**Status**: ✅ **CODE FIXED - NEEDS IMAGE LOADING**

---

## Build Status

✅ **Provider code fixed and built successfully**
- Fixed compilation errors
- Added `findVMNode` function
- Fixed variable scoping issue
- Image built: `crossplane-provider-proxmox:latest`

---

## Deployment Steps

### 1. Build Provider Image

```bash
cd crossplane-provider-proxmox
docker build -t crossplane-provider-proxmox:latest .
```

✅ **COMPLETE**

### 2. Load Image into Kind Cluster

**Required**: `kind` command must be installed

```bash
kind load docker-image crossplane-provider-proxmox:latest --name sankofa
```

⚠️ **PENDING**: `kind` command not available in current environment

**Alternative Methods**:

#### Option A: Install kind
```bash
# Install kind
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.20.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

# Then load image
kind load docker-image crossplane-provider-proxmox:latest --name sankofa
```

#### Option B: Use Registry
```bash
# Tag and push to registry
docker tag crossplane-provider-proxmox:latest <registry>/crossplane-provider-proxmox:latest
docker push <registry>/crossplane-provider-proxmox:latest

# Update provider.yaml to use registry image
# Change imagePullPolicy from "Never" to "Always" or "IfNotPresent"
```

#### Option C: Manual Copy (Advanced)
```bash
# Save image to file
docker save crossplane-provider-proxmox:latest -o provider-image.tar

# Copy to kind node and load
docker cp provider-image.tar kind-sankofa-control-plane:/tmp/
docker exec kind-sankofa-control-plane ctr -n=k8s.io images import /tmp/provider-image.tar
```

### 3. Restart Provider

```bash
kubectl rollout restart deployment/crossplane-provider-proxmox -n crossplane-system
kubectl rollout status deployment/crossplane-provider-proxmox -n crossplane-system
```

✅ **COMPLETE** (but using old image until step 2 is done)

### 4. Verify Deployment

```bash
kubectl get pods -n crossplane-system -l app=crossplane-provider-proxmox
kubectl logs -n crossplane-system -l app=crossplane-provider-proxmox --tail=20
```

---

## Current Status

### ✅ Completed
1. Code fixes applied
2. Provider image built
3. Templates updated to cloud image format
4. Provider deployment restarted

### ⏳ Pending
1. **Load image into kind cluster** (requires `kind` command)
2. Test VM creation with new provider

---

## Next Steps

1. **Install kind** or use alternative image loading method
2. **Load image** into cluster
3. **Restart provider** (if not already done)
4. **Test VM 100** creation
5. **Verify** task monitoring works

---

## Verification

After loading image and restarting:

1. **Check provider logs** for task monitoring:
   ```bash
   kubectl logs -n crossplane-system -l app=crossplane-provider-proxmox | grep -i "task\|importdisk\|upid"
   ```

2. **Deploy VM 100**:
   ```bash
   kubectl apply -f examples/production/vm-100.yaml
   ```

3. **Monitor creation**:
   ```bash
   kubectl get proxmoxvm vm-100 -w
   ```

4. **Check Proxmox**:
   ```bash
   qm status 100
   qm config 100
   ```

---

## Expected Behavior

With the fixed provider:
- ✅ Provider waits for `importdisk` task to complete
- ✅ No lock timeouts
- ✅ VM configured correctly after import
- ✅ Boot disk attached properly

---

**Status**: ⏳ **AWAITING IMAGE LOAD INTO CLUSTER**

