Skip to content
kix /docs
Install the CLI

Reference kix helpers

httpRoute.fromPaths

Build one Gateway API HTTPRoute with a separate backend rule for each path.

kix.httpRoute.fromPaths returns an unsealed Gateway API HTTPRoute definition. Build it with scope.mkCR from a CRD reference for HTTPRoute, which adds the instance namespace, labels, validation, and dependency metadata. The HTTPRoute CRD comes with the Gateway API implementation, so the package declares it with scope.mkCRDRef; without that dependency the cluster build refuses the route (cross-resource check 21).

routeCrd = scope.mkCRDRef {
group = "gateway.networking.k8s.io";
kind = "HTTPRoute";
plural = "httproutes";
version = "v1";
};
route = scope.mkCR self.routeCrd (kix.httpRoute.fromPaths {
name = scope.instanceName;
host = "app.example.com";
parentRef = gateway.out.gatewayRef;
paths = [
{
path = "/api";
svc = self.apiService;
port = 8080;
}
{
path = "/";
pathType = "Exact";
svc = self.frontendService;
}
];
});
ArgumentDefaultMeaning
namerequiredHTTPRoute name.
hostrequiredThe single entry written to spec.hostnames.
parentRefrequiredGateway reference with name and optional namespace.
pathsrequiredList of backend path records described below.
timeoutsnullGateway API rule timeouts, copied to every generated rule.

Each paths entry accepts:

FieldDefaultMeaning
pathrequiredHTTP path value.
svcrequiredKix Service resource used for the backend name and dependency.
portsvc.out.portNumeric backend Service port. Required when the Service exports no out.port.
pathType"Prefix"Prefix or PathPrefix becomes Gateway API PathPrefix; Exact remains Exact. Other values are evaluation errors.

The helper writes one HTTPRoute rule per path. Gateway API determines rule precedence, so list order does not control which matching rule wins.

kix.expose { paths = ...; } uses this helper when the package receives a Gateway provider, and adds the CRD reference as the part <partName>Crd (routeCrd by default). Use the helper directly when a package needs an HTTPRoute outside the standard exposure interface.