CRD Reference
Diverge provides three Kubernetes Custom Resource Definitions (CRDs) under the divergedev.com/v1alpha1 API group:
Environment(Namespaced) — Manages an isolated preview deployment, route, and database for a service.PreviewGroup(Cluster-scoped) — Coordinates multi-service delta preview environments across namespaces for a single Pull/Merge Request.AgentTask(Namespaced) — Runs an autonomous AI coding agent inside a network-isolated sandbox pod with Macaroon capability tokens, budget guardrails, and an optional linked previewEnvironment.
1. Environment (EnvironmentSpec & EnvironmentStatus)
Section titled “1. Environment (EnvironmentSpec & EnvironmentStatus)”The spec defines the desired state of the preview environment.
source
Section titled “source”Defines where the code change originates.
provider: The Git provider. Valid enums:github,gitlab,local.project: The repository or project identifier.mr: The pull/merge request number or ID.branch: The source branch name.
deploy
Section titled “deploy”Configures how the environment is deployed.
mode: The deployment strategy. Valid enums:delta(deploy only changed services),full(deploy all services).changedServices: A list of services that have been modified.baselineRef: Reference to the baseline environment to share unchanged services with (used indeltamode).namespaceLabels: Optional map of labels to apply to the preview namespace. Useful for enabling Istio Ambient mesh (istio.io/dataplane-mode: ambient). Labels prefixed withdivergedev.com/are protected and cannot be overridden.
routing
Section titled “routing”Configures ingress, mesh, and asynchronous / storage traffic routing.
mode: The routing strategy. Valid enums:header,namespace,subdomain.headerKey: The HTTP header key used for routing (validated against RFC 7230 token format).headerValue: The HTTP header value to match.baseDomain: Base domain used whenmode: subdomain(e.g.,preview.example.com). Supports automaticexternal-dns(divergedev.com/external-dns: "true"ordivergedev.com/external-dns-hostname) annotation propagation onto generatedHTTPRoute/GRPCRouteresources andcert-manager(divergedev.com/cluster-issuerordivergedev.com/issuer) Gateway TLS andCertificateprovisioning.asyncRoutes: List of asynchronous and storage isolation routes (protocol+target+ optionalenvVarMapping). Supportedprotocolvalues:kafka: Provisions isolated topic (<target>-<env>) and consumer group (KAFKA_TOPIC,KAFKA_CONSUMER_GROUP,KAFKA_BROKERS).temporal: Assigns isolated task queue (TEMPORAL_TASK_QUEUE=<target>-<env>,TEMPORAL_NAMESPACE).redis/valkey: Isolates shared keyspaces via prefix (DIVERGE_REDIS_PREFIX,REDIS_KEY_PREFIX,REDIS_NAMESPACE,REDIS_ADDR) and evicts keys on teardown.s3/gcs/minio: Isolates shared object storage buckets via deterministic prefix (DIVERGE_STORAGE_PREFIX=previews/<namespace>/<env>/orpreviews/<namespace>/<env>/<target>/,S3_KEY_PREFIX,AWS_S3_PREFIX,GCS_KEY_PREFIX, plusDIVERGE_STORAGE_BUCKETandDIVERGE_STORAGE_ENDPOINTwhen configured).webhook: Delegates provisioning and teardown to an external HTTP webhook.
serviceConfig
Section titled “serviceConfig”Configures service-level deployment and Gateway API target settings.
serviceName: Target baseline KubernetesServicename (used for GAMMA east-west mesh routing).parentRef: Gateway API parent reference name. Supports explicitGateway/<name>andService/<name>disambiguation prefixes, thedivergedev.com/parent-kind: Gateway | Serviceannotation, and automatic clusterGatewaylookup.
database
Section titled “database”Configures the data layer isolation.
mode: Valid enums:shared,schema,snapshot,fresh.connectionRef: Secret reference containing credentials to the baseline database (auto-generated asdiverge-db-env-<env>-<hash8>when omitted inschemamode).seedSource: Optional seed data source inschemamode (public,schema:<name>, orconfigmap:<name>[/<key>]) or source cluster name incnpgsnapshotmode.
lifecycle
Section titled “lifecycle”Manages the environment lifespan.
ttl: Time-to-Live duration before auto-expiry (e.g.,72h).cleanupOnMerge: Boolean indicating if the environment should be deleted upon MR merge/close.
EnvironmentStatus
Section titled “EnvironmentStatus”The status subresource is updated by the Diverge controller to reflect the current state. Diverge uses a deep copy baseline for all status patches to ensure atomic updates.
phase: Current lifecycle phase (e.g.,Pending,Deploying,Running,Failed,Terminating).url: The preview URL for the environment.services: Status of individual services within the environment.conditions: Standard Kubernetes conditions (NamespaceReady,DatabaseReady, etc.).createdAt: Timestamp of environment creation.expiresAt: Timestamp of calculated TTL expiry.commitSHA: The git commit SHA associated with this environment, used for commit status reporting.commentID: The ID of the MR/PR comment created by the notifier, enabling updates to existing comments.commitStatusURL: The URL of the commit status check posted to GitLab/GitHub.
2. PreviewGroup (PreviewGroupSpec & PreviewGroupStatus)
Section titled “2. PreviewGroup (PreviewGroupSpec & PreviewGroupStatus)”PreviewGroup is a cluster-scoped CRD that manages a set of child Environment resources across one or more namespaces for a pull/merge request.
PreviewGroupSpec
Section titled “PreviewGroupSpec”source: Origin metadata (provider:github|gitlab|local,project,mr,branch).routing: Shared routing header configuration (headerKey,headerValue,externalURL).services: List ofServicePreviewSpecentries (name,namespace,mode:image|local|baseline,image,port,localEndpoint,database,asyncRoutes).lifecycle: Group lifespan (ttl,cleanupOnMerge).
PreviewGroupStatus
Section titled “PreviewGroupStatus”phase: Current phase (Pending,Deploying,Running,Degraded,Failed,Terminating).services: Per-service status (name,namespace,mode,environmentName,phase,url,ready).conditions: Standard Kubernetes conditions (Ready,ReferenceGrantsReady).
3. AgentTask (AgentTaskSpec & AgentTaskStatus)
Section titled “3. AgentTask (AgentTaskSpec & AgentTaskStatus)”AgentTask is a namespaced CRD that provisions an isolated autonomous coding agent sandbox with cryptographic Macaroon capability tokens and live LLM budget metering.
AgentTaskSpec
Section titled “AgentTaskSpec”objective: Natural-language objective for the coding agent (MinLength: 1).repository: Target Git repository (url,baseBranch,workingBranch).sandbox: Sandbox execution settings (provider:agent-sandbox|pod|k8s-pod|noop,poolRef,templateRef,timeoutSeconds).budgetUSD: Maximum LLM spend in USD formatted as a decimal string (e.g."5.00").budgetTokens: Maximum total LLM tokens allowed (e.g.200000).maxIterations: Maximum build-verify-fix iterations (default:5, max:20).capabilities: Allowed model identifiers or prefix wildcards encoded into the Macaroon capability token (e.g.["claude-3-7-sonnet", "gemini-2.5-pro"]).draftPR: Whether to open a draft PR/MR upon completion (default:true).suspended: Whentrue, suspends the sandbox (operatingMode: Suspended), revokes the active Macaroon token, and hibernates the linked previewEnvironment.
AgentTaskStatus
Section titled “AgentTaskStatus”phase: Current lifecycle phase (Pending,Provisioning,Active,Pausing,Paused,Completed,Failed).sandboxClaimName: Name of the provisionedSandboxClaimor sandboxPod.sandboxReady: Boolean indicating whether the sandbox pod is ready.iterations: Current autonomous loop iteration count.tokensConsumed: Cumulative LLM tokens reported viaPOST /api/v1/agenttask/meter.costUSD: Cumulative LLM spend in USD formatted to 4 decimal places.lastMeterRequestIds: Bounded 32-entry ring buffer of recent meteringrequestIdvalues for idempotent deduplication across server replicas.pullRequestURL/pullRequestID: Created draft PR/MR URL and number.conditions: Standard Kubernetes conditions (SandboxReady,PreviewEnvironmentReady,TaskCompleted).
