Skip to Content
Security and networking

Networking

Serve a Function at a path and a host of its own with a Route, ask its callers to authenticate, and allow a Function's outbound connections with an EgressPolicy.

This page lists the spec and status fields of Route and EgressPolicy, each with its type, its limits and its description. The Platform page explains the concept, and the metadata of every kind is the same.

Route

apiVersion: funcd.io/v1alpha1
kind: Route
metadata:
  name: devices
  namespace: default
  resourceGroup: rg1
spec:
  host: devices.example.com
  rules:
    - path: /
      backend:
        function: devices-api
apiVersionkind
funcd.io/v1alpha1Route

Route.spec

FieldType and limitsDescription
authobject, Route.spec.authThe edge authentication of the rules that set none. Unset uses the Namespace's spec.edgeDefaults.auth, else open.
enabledbooleanfalse turns the Route off: it serves nothing, leaves its paths to other Routes and reports Disabled. Unset is true, except on a Route that a Site or a Function owns in a namespace whose defaultExposure is explicit.
hoststringThe host the rules answer on, matched in lower case and without a port or a trailing dot. Empty is the namespace host, <namespace>.<server.baseDomain>, or, in the default namespace, every host except another namespace's own host, <other>.<server.baseDomain> or a name under it, while that namespace uses it; a host that another namespace's Route names is not excluded, and the longer matching path wins there. In the default namespace, an explicit defaultExposure refuses an empty host (HostRequired). A host that names another namespace, <other>.<server.baseDomain> or a name under it, is refused (HostReserved) while that namespace uses it, and always for a rule at or under /function.
rulesarray of Route.spec.rules[], requiredThe path rules, at least one; two rules may not have the same path and the same methods. Across all Routes, the longest matching path wins, and a rule with a host wins a tie. A Route serves all its rules or none: a missing backend or one conflicting rule keeps every rule off.

Route.spec.auth

FieldType and limitsDescription
modestring, one of "", authenticated, open, oidcHow the edge checks callers. authenticated requires a bearer token, or an X-Api-Key header, of an identity that RBAC lets get Functions in the namespace: 401 without a valid one, 403 when it may not; while server.auth.edge is off, every caller gets 401. open lets anonymous callers in. oidc signs callers in with the OIDCProvider that provider names, and passes the signed-in user to the code behind it in the X-Funcd-Principal headers. Empty takes the enclosing stance, if any, else the namespace's spec.edgeDefaults.auth.mode, else open.
providerstring, a DNS-1123 labelWith mode oidc, the OIDCProvider of the namespace that signs callers in; required with oidc and refused with another mode.
unauthenticatedstring, one of "", redirect, 401, allowWith mode oidc, what a call that is not signed in gets: redirect, the default, sends a GET or HEAD navigation to the provider with 302 and gives any other call 401; 401 gives every such call 401; allow passes every call, with no principal. Refused with another mode.

Route.spec.rules[]

FieldType and limitsDescription
authobject, Route.spec.authThe edge authentication of this rule's requests. Unset uses the Route's auth, then the Namespace's spec.edgeDefaults.auth, then open.
backendobject, Route.spec.rules[].backend, requiredWhat the rule serves: set exactly one of function, static and site.
methodsarray of string values, each one of GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONSThe request methods the rule matches; empty matches every method.
pathstring, requiredThe path the rule matches, starting with /. In the default namespace, a Route with no host may not have a rule at or under /function, the path that calls Functions by name (ReservedPath).
pathTypestring, one of "", Prefix, ExactPrefix, the default, matches path and every path under it by whole segments, so /api matches /api/x but not /apix; a trailing slash changes nothing, and / matches every path. Exact matches path alone. The backend receives the rest of the path, or / for an Exact rule.

Route.spec.rules[].backend

FieldType and limitsDescription
functionstring, a DNS-1123 labelA Function of the Route's namespace that the rule calls; the Route is not Ready (BackendNotFound) while it is missing. A request whose rest of the path lies under /health/ gets 404 and reaches no worker.
sitestring, a DNS-1123 labelA Site of this Route's namespace: the rule serves the build that Site serves now, and its config.json at <path>/config.json, following each new build. A Prefix rule; the Route may not carry the Site's own name.
staticobject, Route.spec.rules[].backend.staticServes the objects of a Bucket prefix directly, with no Function. It answers GET and HEAD, and 405 to any other method.

Route.spec.rules[].backend.static

FieldType and limitsDescription
bucketstring, required, a DNS-1123 labelA Bucket of the Route's namespace whose objects the rule serves; the Route is not Ready (BucketNotFound) while it is missing.
indexstringThe object, relative to prefix, served at the rule's root; index.html when empty. A path ending in / gets the file of the index's name in that folder. It may not start with /.
prefixstringThe key prefix in the Bucket that the rule serves, ending in /; empty serves the whole Bucket. A request reads the object at this prefix plus the rest of its path.
spabooleanServe the index, with 200, for a path that matches no object, so that a client-side router handles it; when false, such a path gets 404.

Route.status

FieldType and limitsDescription
conditionsarray of ConditionThe conditions that explain the phase.
hoststringThe host the Route claims, whether or not it is Ready: spec.host in lower case without a port or a trailing dot, else the namespace host. It is empty for any host, as for a Route of the default namespace with no host, and while a backend is missing.
observedGenerationintegerThe generation of the spec that funcd last acted on.
phasestring, one of Pending, Deploying, Ready, Idle, Degraded, Failed, TerminatingWhere the object is in its lifecycle.

EgressPolicy

apiVersion: funcd.io/v1alpha1
kind: EgressPolicy
metadata:
  name: allow-example-subdomains
  namespace: default
  resourceGroup: rg1
spec:
  rules:
    - to:
        domains:
          - "*.example.com"
      ports:
        - 443
apiVersionkind
funcd.io/v1alpha1EgressPolicy

EgressPolicy.spec

FieldType and limitsDescription
appliesToarray of EgressPolicy.spec.appliesTo[]The workloads of the namespace that the rules apply to, each named with its kind: a Function, a Job, or an object of an add-on kind whose objects run an engine, spelled as its Addon spells it, whose engine the rules then let out. Empty applies them to every Function of the namespace, and to no Job or engine.
rulesarray of EgressPolicy.spec.rules[], requiredOne to 64 rules, each allowing outbound TCP connections; the rules of every EgressPolicy of the namespace add up. With server.network.egress on, on Linux with containerd, a connection that nothing allows is refused; otherwise the rules change nothing.

EgressPolicy.spec.appliesTo[]

FieldType and limitsDescription
kindstring, required, matching ^[A-Z][A-Za-z0-9]{1,62}$The workload's kind: Function, Job, or the kind of an add-on whose objects run an engine, as its Addon spells it.
namestring, required, a DNS-1123 labelThe workload's name, in the policy's namespace. It need not exist yet.

EgressPolicy.spec.rules[]

FieldType and limitsDescription
portsarray of integer valuesThe destination ports the rule allows, each 1 to 65535, at most 32; empty allows every port.
toobject, EgressPolicy.spec.rules[].to, requiredWhere the rule allows connections to: at least one domain or CIDR, and at most 64 of them together. A connection matches the rule when it goes to one of them on one of the rule's ports.

EgressPolicy.spec.rules[].to

FieldType and limitsDescription
cidrsarray of string valuesAddress ranges, such as 10.0.0.0/8, that the dialled address must fall in. A host reached by name needs a domains entry too, since funcd answers a worker's lookup only for a name that a domain rule applying to it allows.
domainsarray of string valuesHost names in lower case: exact, such as api.x.com, or a wildcard, such as *.x.com, which matches every name under x.com but not x.com. A connection matches a name only at an address that the worker's own lookup of it through funcd returned, within the answer's TTL, and never at an address that is not globally reachable, such as a private one, which needs a cidrs entry.

HTTP API

The table lists each described operation of these kinds, with its method and path. The operation's page in the API reference gives its parameters, its body, its authentication and every answer, with when it happens and what to do.

MethodPathOperation
GET/apis/funcd.io/v1alpha1/namespaces/{namespace}/routesList the Routes of a namespace
POST/apis/funcd.io/v1alpha1/namespaces/{namespace}/routesCreate a Route
GET/apis/funcd.io/v1alpha1/namespaces/{namespace}/routes/{name}Read a Route
PUT/apis/funcd.io/v1alpha1/namespaces/{namespace}/routes/{name}Replace a Route
DELETE/apis/funcd.io/v1alpha1/namespaces/{namespace}/routes/{name}Delete a Route
GET/apis/funcd.io/v1alpha1/namespaces/{namespace}/egresspoliciesList the EgressPolicies of a namespace
POST/apis/funcd.io/v1alpha1/namespaces/{namespace}/egresspoliciesCreate an EgressPolicy
GET/apis/funcd.io/v1alpha1/namespaces/{namespace}/egresspolicies/{name}Read an EgressPolicy
PUT/apis/funcd.io/v1alpha1/namespaces/{namespace}/egresspolicies/{name}Replace an EgressPolicy
DELETE/apis/funcd.io/v1alpha1/namespaces/{namespace}/egresspolicies/{name}Delete an EgressPolicy

On this page