Operations
Function CRD
The Function CRD declares row-preserving compute over an
Index. The operator creates worker
resources; the gateway owns discovery, queueing, retries, leases, and
writeback through the UDF API.
apiVersion: hevlayer.com/v1alpha1
kind: Function
metadata:
name: tag-products
namespace: layer
spec:
targetNamespaces:
- products
inputs:
- id
- title
output:
attribute: tags
kind: tags
version: v1
filter:
- "Or"
- - ["tags_v", "NotEq", "v1"]
- ["tags_v", "Eq", null]
worker:
image: ghcr.io/hev/tag-products:latest
dispatch: pull
batchSize: 32
timeoutSeconds: 30
schedule:
discoveryIntervalSeconds: 300
leaseSeconds: 120
maxInFlightBatches: 8
maxConcurrentScans: 1
retry:
maxAttempts: 8
initialBackoffSeconds: 5
maxBackoffSeconds: 300
triggers:
- discovery
scaling:
pool: cpu
mode: autoscale
replicas:
min: 0
max: 6
Selection
Use targetNamespaces for explicit namespaces. Use indexSelector when
labels on Index resources should choose the namespaces.
filter preserves arbitrary JSON, including array-form Turbopuffer
filters. The operator stores the shape as-is; the gateway evaluates it
during discovery.
Worker
| Field | Purpose |
|---|---|
image | Worker image. |
dispatch | pull for SDK claim/poll workers, push for HTTP /run workers. |
port | Push-dispatch service port. |
batchSize | Rows per batch. |
timeoutSeconds | Worker call timeout. |
podSpec | Optional pod-level merge patch. |
Pull dispatch creates a Deployment. Push dispatch also creates a Service and readiness probe.
Scaling
Function scaling is inline under spec.scaling. The operator emits a
KEDA ScaledObject when mode: autoscale, using
layer_udf_queue_depth for the trigger.
The selected pool must exist in InfraRules/default. Replica maxima
above the pool’s maxReplicasPerWorkload are rejected in status.
Output
output.kind: embedding should set output.dim so consumers can
validate vector shape. Outputs are patched onto the target row through
the gateway.
Deleting a Function garbage-collects operator-managed Kubernetes resources. It does not delete already-written attributes.