Skip to content

Cluster Controller

On Kubernetes, the controller creates aggregators on request, checks the request against policy, allocates resources and announces the aggregator on relays. An operator reconciles the resource l2aggregators.metrics.dgrid.io.

API

All endpoints need Authorization: Bearer <ADMIN_TOKEN>.

Method and path Purpose
POST /v1/l2s Create an aggregator
GET /v1/l2s List
GET /v1/l2s/{name} One aggregator with status
DELETE /v1/l2s/{name} Delete. A deletion event is published
Field Default Meaning
l2_id required Name. Lowercase letters, digits and -, at most 40 characters
l2_type cluster cluster or global
retention_days 30 1 to 3650
expected_series 1000 Used to size storage
window_seconds 10 1 to 3600
node_policy allowlist allowlist or tofu
nodes [] pubkey, node_id, cluster_id of each node
metadata {} For selection policies
url_host empty Address for nodes outside the cluster
grpc_port, ping_port 50051, 50052 Announced ports

Policy

policy.json has two parts:

{
  "precheck": [
    {"id": "too-many-l2s", "deny": [{"field": "existing", "op": "ge", "value": 10}]},
    {"id": "open-global-l2", "deny": [
      {"field": "l2_type", "op": "eq", "value": "global"},
      {"field": "node_policy", "op": "eq", "value": "tofu"}]}
  ],
  "allocator": [
    {"when": [{"field": "storage_gb", "op": "le", "value": 50}], "set": {"cpu": "100m", "memory": "128Mi", "db_cpu": "100m", "db_memory": "256Mi"}},
    {"when": [], "set": {"cpu": "2", "memory": "2Gi", "db_cpu": "4", "db_memory": "8Gi"}}
  ]
}

A request is rejected with 403 if all conditions of a precheck rule hold. The first matching allocator rule sets the resources. Rules can use all fields of the request, and cluster_id, storage_gb and node_count. precheck rules can also use existing.

Announcement

Once an aggregator is ready, the controller publishes an event of kind 6003 with its key. Nodes that list the controller's key in trusted_clusters then trust it.