Skip to content
Documentation menu

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.

workerroute.yaml
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-worker

Spec

What you set, with the limits the API server enforces.

FieldDescription
pattern
stringrequired

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 ^\*?[A-Za-z0-9.-]+(/\S*)?$

workerScriptRef
object

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
string

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: ""

zoneRef
objectrequiredimmutable

ZoneRef references the Zone, in the same namespace, the Worker route belongs to. Immutable after creation.

zoneRef.name
string

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.

FieldDescription
cloudflareMetadata
object

CloudflareMetadata holds identifiers and metadata returned by the Cloudflare API.

cloudflareMetadata.routeID
string

RouteID is the Cloudflare route identifier.

cloudflareMetadata.script
string

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.zoneID
string

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.

ColumnSource
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.

cloudflare_v1alpha1_workerroute.yaml
# 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

On GitHub