Networking
How a call reaches a worker, and how a worker reaches the rest.
A call reaches funcd's edge, which terminates TLS, matches the call to a Route, authenticates it when the Route asks
for it, and applies the rate and size limits. A Route serves a Site's static files or calls a Function, and a Function
can also be called at /function/<name>. The edge also passes a Lake's queries to the Lake's gateway, and an
add-on object's requests to its engine. When the Function has no worker running, the activator holds the call, starts a
worker and passes the call on once the worker is ready. An idle Function scales back to zero.
A worker reaches other Functions and its stores through its local API. When egress control is on, its outbound connections go through the egress gateway, which applies the namespace's EgressPolicy.
With egress control on and the gateway running, the edge also listens on funcd's bridge address at the data plane's
port, where a worker or an add-on engine, such as a tunnel's connector, reaches it directly. funcd names such a caller
by its source address, as the gateway does, and serves it only what resolves to the caller's own namespace: another
namespace's host, Function by name or sign-in callback, or an X-Funcd-Namespace header that names another namespace,
gets 403. The gateway never connects a worker to an address the data plane listens on, so this is the one way from the
container network to the edge. A request from outside the container network is served as before.
OIDC sign-in
A Route, a workload's own address or a namespace can ask the edge to sign its callers in with an OpenID Connect provider. The edge does it before it wakes a worker. A call with a session, or with a token of the provider, goes on with the user's identity in headers that only the edge sets. A page load with neither goes to the provider, which sends the browser back to the edge, and any other call gets 401. OIDC sign-in shows the whole exchange.
Local API
Each worker has its own local API, an HTTP socket that funcd opens for it under <dataDir>/invoke and that only the
shim calls. funcd sets the caller's identity when it provisions the worker, so a request can never act for another
Function. A pooled worker's socket serves each Function in the pool as the member that the request names.
The providers serve their parts of the local API, called facets, each under its own path. The kv, blob, sql,
secret, job and addon facets ask Cedar before each call: job starts a run of a Job that the Function binds, and
addon passes a request to the engine of an add-on object that it binds. The local API also serves invoke and
fetch, which call another Function over a link that the caller declares. Such a call goes through the data plane once
Cedar allows it. The local API also serves health, which checks the worker's bindings.
Egress
Egress control is opt-in (server.network.egress) and is available on Linux with containerd. When it is off, a
worker's outbound connections stay open. When it is on, nftables rules on the worker bridge, funcd0, block traffic
between workers, redirect a worker's outbound TCP to the egress gateway and drop the rest. The rules also redirect a
worker's DNS queries to funcd's DNS forwarder, which records the domain behind each answer. An add-on engine takes the
same path: with egress control on, its own fence keeps only funcd's way in and no way out.
For each connection, the egress gateway recovers the address that the worker dialled, identifies the worker by its
source address, and takes the domain from the forwarder's records, never from what the client sends. It then asks
Cedar whether the worker's Function, Job or Lake, or the add-on object of an engine, may egress::connect there. Cedar
decides from the namespace's EgressPolicies, whose rules name domains, exact or wildcard, CIDRs and ports, for the
workloads they apply to. The
gateway connects an allowed connection through to its destination and closes a refused one. It audits every
connection.