Skip to content

Runtime actuation

A project version runs as a Deployment and a Service in your cluster, and the node must render them the same way every time from what the control plane decided, then find the kernel behind them. The runtime actuator does both. It validates the runtime deploy contract in a serve assignment, renders and applies the two objects, and, when the assignment asks for readiness, waits for the rollout, picks a kernel endpoint from the Service and completes the kernel handshake. This page covers the contract, the objects, the endpoint choice and the failures.

What is rendered from the contract

flowchart TB
  subgraph C["RUNTIME DEPLOY CONTRACT, project.runtime_deploy.v1"]
    direction LR
    ID["namespace, deployment_ref,<br/>service_ref, endpoint"]
    IMG["runtime_image_ref,<br/>runtime_image_digest"]
    SC["desired, min, max replicas,<br/>resources, rollout"]
    TR["runtime_trust, placement,<br/>kernel_control_tls"]
  end
  subgraph NS["PROJECT NAMESPACE"]
    direction TB
    subgraph DEP["DEPLOYMENT deployment_ref"]
      direction LR
      POD["Pod, service account per runtime<br/>container project-runtime"]
      SPF[("SPIFFE CSI volume<br/>/run/spiffe/workload-api")]
      POD --- SPF
    end
    SVC["SERVICE service_ref, ClusterIP<br/>80 to 8080 http<br/>7777 kernel-grpc-control"]
    SVC --> POD
  end
  ID --> DEP
  ID --> SVC
  IMG --> POD
  SC --> DEP
  TR --> POD

The Service is the node's only route to the kernel: the node finds the kernel's address through the Service's endpoints, so it reaches the same pods whichever workload kind stands behind the Service. Each runtime runs under its own service account, so the SPIFFE agent can attest one runtime apart from another.

The runtime deploy contract

The contract is control_plane_task.runtime_deploy_contract. When its required is false the actuator does nothing and reports not_required. Otherwise it must satisfy:

Field Rule
contract_version project.runtime_deploy.v1
mode kubernetes_native
namespace, deployment_ref, service_ref Kubernetes names: lowercase letters, digits and hyphens
endpoint Present
kernel_control_service_ref Equal to service_ref
kernel_control_port 7777
runtime_image_ref, runtime_image_digest Both present
desired_replicas Within min_replicas and max_replicas
rollout max_unavailable and max_surge default to 25%; progress_deadline_seconds defaults to 600 and must be above 0
resources Optional requests and limits for cpu, memory, ephemeral_storage

The contract also carries workspace_uuid, project_name, version, placement, runtime_trust, kernel_control_tls, cooldown_period and target_queue_depth, and the task carries runtime_ownership. A contract that breaks a rule fails the assignment with the rule in its message:

project runtime kernel_control_service_ref must match service_ref
project runtime desired_replicas is outside min/max bounds

The objects

The actuator applies the Deployment and then the Service with kubectl -n <namespace> apply. Both carry these labels:

app.kubernetes.io/name          <deployment_ref>
app.kubernetes.io/component     project-runtime
xratu.io/runtime-kind           project
xratu.io/kernel-control         true
xratu.io/assignment-id          <assignment>
xratu.io/workspace              <workspace_uuid>
xratu.io/project                <project_name>
xratu.io/project-version        <version>
xratu.io/dataplane-pool         <pool>
xratu.io/dataplane-node         <node>
xratu.io/runtime-image-digest   <digest>

The Deployment's selector is app.kubernetes.io/name and xratu.io/runtime-kind. Its pods:

  1. run one container, project-runtime, from runtime_image_ref, with ports 8080 (http) and 7777 (kernel-grpc-control);
  2. mount the SPIFFE workload API through the csi.spiffe.io driver, with SPIFFE_ENDPOINT_SOCKET set to its socket;
  3. run as service_account_ref from the contract, or a service account named after the deployment;
  4. carry the annotation xratu.io/runtime-image-digest, and xratu.io/spiffe-id with the SPIFFE ID the pod is expected to be issued, taken from runtime_trust.runtime_workload_identity.

The rollout is RollingUpdate with the contract's maxUnavailable, maxSurge and progressDeadlineSeconds, and replicas is desired_replicas.

The namespace and its RBAC are provisioned when the data plane is installed. A namespace that is missing fails the assignment:

project runtime namespace precondition failed: namespace '<namespace>' is missing; platform/bootstrap must pre-provision the namespace and namespaced RBAC before project deploy

To see what the node applied for a project version:

NAMESPACE=acme-projects
PROJECT=support-agent
kubectl -n "$NAMESPACE" get deployments,services,pods -l xratu.io/project="$PROJECT" --show-labels

Set NAMESPACE to the namespace in the runtime deploy contract and PROJECT to the project's name.

Finding the kernel

A readiness check first waits for the rollout, up to 180 seconds, and reads the Deployment's ready and desired replicas. It then chooses one kernel endpoint:

  1. Read the Service's EndpointSlices, or its Endpoints when it has none.
  2. Keep the endpoints marked ready, and take the port named kernel-grpc-control.
  3. Sort them by pod name, address and port, and pick the one at sha256(selection key) mod count. The selection key is the runtime's runtime_instance_id, or the assignment and deployment when it has none.

The same runtime therefore selects the same pod while the set of ready pods is unchanged. The endpoint record names its source (endpointslice or endpoints), the selected_pod, selected_node, and how many endpoints were found and how many were ready.

The node then sends runtime.handshake to that endpoint with its identity and the runtime's ownership, over the kernel control channel's TLS settings. An accepted handshake must include the kernel's startup evidence, which is validated; one without it is reported as invalid_startup_evidence. After an accepted handshake the node records the runtime session and resumes the kernel's return lane. See Readiness, handshake, and endpoint re-resolution and The kernel bridge.

Handshake outcomes

handshake_result Meaning
accepted The kernel accepted the node and returned valid startup evidence
endpoint_not_ready No ready endpoint was found behind the Service
invalid_startup_evidence The kernel accepted but its startup evidence was missing or invalid
handshake_client_not_configured The node has no kernel handshake client
The kernel's reason The kernel refused the handshake, or the call failed

Resuming the return lane after an accepted handshake needs runtime_ownership to name a runtime_instance_id, an owner_dp_node_id and a fence_epoch of at least 1. When one is missing, the continuity record reports runtime_ownership_missing and the return lane stays unresumed.