Files
zeekay 04e5aac8c4 feat(operator): Cloudflare connector + Pages CR
Implement the stubbed CloudflareReconciler with real CF DNS sync (create/
adopt/update/delete via a finalizer) so DnsRecords with syncToCloudflare=true
land at the edge, and add a PagesProject CR + reconciler that deploys a CF
Pages site, attaches its custom domain, and wires DNS by composing the DNS
layer (emits an owned CNAME DnsRecord rather than a second CF-DNS code path).

- internal/cloudflare: minimal CF API v4 client (DNS CRUD + Pages), one do()
  HTTP path, scoped Bearer auth, idempotent delete/add. httptest-covered.
- CloudflareReconciler: real upsert + finalizer cleanup; nil client => no-op.
- PagesProject{,Spec,Status} CR + reconciler (Owns child DnsRecord for GC).
- main.go: one shared cloudflare.Client injected into both reconcilers.
- CRDs, RBAC, DeepCopy regenerated; deployable manager manifest (CF_API_TOKEN
  from KMS-synced secret, optional); hanzo.bot sample.

Tests: go test ./... green (CF client + both reconcilers, fake client + mock CF).
2026-06-16 12:11:20 -07:00

75 lines
1.8 KiB
YAML

apiVersion: v1
kind: Namespace
metadata:
name: dns-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: dns-operator
namespace: dns-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dns-operator-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: manager-role
subjects:
- kind: ServiceAccount
name: dns-operator
namespace: dns-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: dns-operator
namespace: dns-system
labels:
app: dns-operator
spec:
replicas: 1
selector:
matchLabels:
app: dns-operator
template:
metadata:
labels:
app: dns-operator
spec:
serviceAccountName: dns-operator
containers:
- name: manager
image: ghcr.io/hanzoai/dns-operator:v0.1.0 # pinned; CI publishes on tag
args: ["--leader-elect"]
env:
# Scoped Cloudflare API token (Zone:DNS:Edit + Account:Pages:Edit),
# KMS-synced. Optional: absent → CF reconcilers no-op, not crash.
- name: CF_API_TOKEN
valueFrom:
secretKeyRef:
name: cloudflare-api-token
key: api-token
optional: true
# hanzodns/CoreDNS Postgres backend (optional).
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: dns-operator-db
key: DATABASE_URL
optional: true
livenessProbe:
httpGet: {path: /healthz, port: 8081}
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet: {path: /readyz, port: 8081}
initialDelaySeconds: 5
periodSeconds: 10
resources:
requests: {cpu: 10m, memory: 64Mi}
limits: {memory: 128Mi}
terminationGracePeriodSeconds: 10