# Infrastructure Management

**Last Updated:** 2025-01
**Confidence:** High

## Summary

rdev can manage project infrastructure: creating Git repos, configuring DNS, and deploying applications to Kubernetes. This enables full project lifecycle management via API.

**Key Facts:**
- Git repos via Gitea integration
- DNS via Cloudflare integration
- Deployments create K8s Deployment + Service + Ingress
- Managed projects combine all three steps
- Woodpecker CI integration for auto-deploy on build

**File Pointers:**
- Handler: `internal/handlers/infrastructure.go`
- Service: `internal/service/project_infra.go`
- Gitea adapter: `internal/adapter/gitea/client.go`
- Cloudflare adapter: `internal/adapter/cloudflare/client.go`
- Deployer adapter: `internal/adapter/deployer/deployer.go`

## Capabilities

| Feature | Endpoint | Description |
|---------|----------|-------------|
| Create repo | `POST /projects/{id}/repo` | Creates Gitea repository |
| Deploy | `POST /projects/{id}/deploy` | Deploys to Kubernetes |
| Configure DNS | `POST /projects/{id}/domain` | Creates Cloudflare record |
| Managed project | `POST /projects/create-managed` | Full lifecycle |

## Managed Project Flow

1. Create Gitea repository
2. Initialize with template
3. Create Cloudflare DNS record
4. Deploy to Kubernetes (Deployment + Service + Ingress)
5. Return project details

## Environment Variables

```
GITEA_URL, GITEA_TOKEN, GITEA_DEFAULT_ORG
CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID, DEFAULT_DOMAIN
DEPLOY_NAMESPACE, DEPLOY_TLS_ISSUER, REGISTRY_URL
```

## Related Topics

- [Project Service](../services/project-service.md)
- [Webhooks](../services/webhooks.md)
