Docs / Reference / Workers and storage
WorkerRoute
WorkerRoute routes requests matching a URL pattern in a zone to a WorkerScript, or, without one, excludes the pattern from a broader route.
- API version
- kflare.dev/v1alpha1
- Scope
- Namespaced
- Short name
- cfroute
- Token permission
- Zone · Workers Routes · Edit
Example
Every field, with the sample's values. The live lines are the repository's sample, which applies as it is; the commented ones are the other fields, filled from other samples where one sets them. Some exclude each other, so check the rules before you uncomment several.
apiVersion: kflare.dev/v1alpha1
kind: WorkerRoute
metadata:
name: example-workerroute
namespace: default
annotations:
kflare.dev/deletion-policy: retain
spec:
zoneRef:
name: example-zone
pattern: example.com/api/*
workerScriptRef:
name: example-workerSpec
What you set, with the limits the API server enforces.
| Field | Description |
|---|---|
patternstringrequired | Pattern selects the requests the route applies to, such as "example.com/api/*" or "*.example.com/*". It has no scheme or port, may start with "*" (any subdomain) and end with "*" (any path), and its hostname must be in the zone. Patterns are unique within a zone. Limits: at most 1024 characters; matches |
workerScriptRefobject | WorkerScriptRef references the WorkerScript, in the same namespace and the zone's account, that handles matching requests. The route waits until the WorkerScript has uploaded its Worker: Cloudflare refuses a route to a Worker that does not exist (10019). Omit it to exclude the pattern from a broader route, so that no Worker runs for it. |
workerScriptRef.namestring | Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names Default: |
zoneRefobjectrequiredimmutable | ZoneRef references the Zone, in the same namespace, the Worker route belongs to. Immutable after creation. |
zoneRef.namestring | Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names Default: |
Status
What kflare reports. conditions holds the Ready condition, whose reason says why a resource isn't ready.
| Field | Description |
|---|---|
cloudflareMetadataobject | CloudflareMetadata holds identifiers and metadata returned by the Cloudflare API. |
cloudflareMetadata.routeIDstring | RouteID is the Cloudflare route identifier. |
cloudflareMetadata.scriptstring | Script is the Worker route's script at the last sync: the name of the WorkerScript its workerScriptRef names. Empty when the Worker route has none. |
cloudflareMetadata.zoneIDstring | ZoneID is the Cloudflare zone the Worker route belongs to (denormalized from the Zone status). |
conditions[]object | Conditions represent the latest available observations of the Worker route state. |
kubectl get
The columns kubectl get workerroutes prints.
| Column | Source |
|---|---|
| PATTERN | .spec.pattern |
| WORKER | .spec.workerScriptRef.name |
| ROUTE ID | .status.cloudflareMetadata.routeID |
| READY | .status.conditions[?(@.type=="Ready")].status |
| AGE | .metadata.creationTimestamp |
Samples
From the repository's config/samples, comments included.
# Generated by kflare-gen from generator/generator.yaml. DO NOT EDIT.
#
# WorkerRoute is the Schema for the workerroutes API.
# It routes requests matching a URL pattern in a zone to a WorkerScript,
# or, without one, excludes the pattern from a broader route.
apiVersion: kflare.dev/v1alpha1
kind: WorkerRoute
metadata:
name: example-workerroute
namespace: default
annotations:
# The retain policy keeps the Worker route in Cloudflare when this resource
# is deleted. Without it, deleting the resource deletes the Worker route.
kflare.dev/deletion-policy: retain
spec:
zoneRef:
name: example-zone
# Pattern selects the requests the route applies to, such as
# "example.com/api/*" or "*.example.com/*". It has no scheme or port,
# may start with "*" (any subdomain) and end with "*" (any path), and
# its hostname must be in the zone. Patterns are unique within a zone.
pattern: example.com/api/*
# WorkerScriptRef references the WorkerScript, in the same namespace
# and the zone's account, that handles matching requests. The route
# waits until the WorkerScript has uploaded its Worker: Cloudflare
# refuses a route to a Worker that does not exist (10019). Omit it to
# exclude the pattern from a broader route, so that no Worker runs for
# it.
workerScriptRef:
name: example-worker