# Build and Deploy Guide (No GitHub Required)

## Overview

This guide shows how to build and deploy the Crossplane provider without using GitHub Container Registry.

## Option 1: Local Image (Recommended for Development)

### Build Image

```bash
cd crossplane-provider-proxmox

# Build the Docker image
docker build -t crossplane-provider-proxmox:latest .
```

### Load into Cluster

**For kind:**
```bash
kind load docker-image crossplane-provider-proxmox:latest
```

**For minikube:**
```bash
minikube image load crossplane-provider-proxmox:latest
```

**For Docker Desktop Kubernetes:**
```bash
# Image is already available, no load needed
```

### Deploy

```bash
# Deploy the provider
kubectl apply -f config/provider.yaml

# Verify deployment
kubectl get pods -n crossplane-system
```

---

## Option 2: Docker Hub (Public Registry)

### Setup

1. Create account at https://hub.docker.com
2. Login:
   ```bash
   docker login
   ```

### Build and Push

```bash
cd crossplane-provider-proxmox

# Build with Docker Hub tag
docker build -t sankofa/crossplane-provider-proxmox:latest .

# Push to Docker Hub
docker push sankofa/crossplane-provider-proxmox:latest
```

### Update Configuration

Edit `config/provider.yaml`:
```yaml
image: docker.io/sankofa/crossplane-provider-proxmox:latest
imagePullPolicy: Always
```

### Deploy

```bash
kubectl apply -f config/provider.yaml
```

---

## Option 3: Private Container Registry

### Harbor / Private Registry

1. **Build image:**
   ```bash
   docker build -t registry.example.com/sankofa/crossplane-provider-proxmox:latest .
   ```

2. **Login to registry:**
   ```bash
   docker login registry.example.com
   ```

3. **Push image:**
   ```bash
   docker push registry.example.com/sankofa/crossplane-provider-proxmox:latest
   ```

4. **Create image pull secret:**
   ```bash
   kubectl create secret docker-registry regcred \
     --docker-server=registry.example.com \
     --docker-username=USERNAME \
     --docker-password=PASSWORD \
     --docker-email=EMAIL \
     -n crossplane-system
   ```

5. **Update provider.yaml:**
   ```yaml
   image: registry.example.com/sankofa/crossplane-provider-proxmox:latest
   imagePullPolicy: Always
   ```
   
   And add image pull secret:
   ```yaml
   spec:
     template:
       spec:
         imagePullSecrets:
         - name: regcred
   ```

6. **Deploy:**
   ```bash
   kubectl apply -f config/provider.yaml
   ```

---

## Option 4: Local Registry (Docker Registry)

### Setup Local Registry

```bash
# Run local registry
docker run -d -p 5000:5000 --name registry registry:2

# Build and tag
docker build -t localhost:5000/crossplane-provider-proxmox:latest .

# Push to local registry
docker push localhost:5000/crossplane-provider-proxmox:latest
```

### Update Configuration

Edit `config/provider.yaml`:
```yaml
image: localhost:5000/crossplane-provider-proxmox:latest
imagePullPolicy: Always
```

**Note**: For Kubernetes, use the registry's service IP or hostname, not `localhost`.

---

## Option 5: Build in Cluster (Kaniko/Cloud Native Build)

For production, consider using:
- **Kaniko**: Build images in Kubernetes without Docker
- **BuildKit**: Cloud-native build system
- **Tekton**: CI/CD pipelines with in-cluster builds

---

## Quick Start (Local Development)

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

# 2. Load (if using kind/minikube)
kind load docker-image crossplane-provider-proxmox:latest
# OR
minikube image load crossplane-provider-proxmox:latest

# 3. Deploy
kubectl apply -f config/provider.yaml

# 4. Verify
kubectl get pods -n crossplane-system -l app=crossplane-provider-proxmox
kubectl logs -n crossplane-system -l app=crossplane-provider-proxmox
```

---

## Current Configuration

**Image**: `crossplane-provider-proxmox:latest` (local)  
**Pull Policy**: `IfNotPresent`

This configuration works out-of-the-box for local development without requiring any external registry.

---

## Troubleshooting

### Image Pull Errors

```bash
# Check if image exists locally
docker images | grep crossplane-provider-proxmox

# For kind, verify image is loaded
docker exec -it kind-control-plane crictl images | grep crossplane

# For minikube, check images
minikube ssh docker images | grep crossplane
```

### Build Errors

```bash
# Check Dockerfile
cat crossplane-provider-proxmox/Dockerfile

# Build with verbose output
docker build --progress=plain -t crossplane-provider-proxmox:latest .
```

---

**Last Updated**: Current  
**Registry**: Local (no external registry required)

