CustomResponsePolicy

microgateway.airlock.com/v1alpha1


Premium Featureauth or filter module

CustomResponsePolicy is a Direct Attached Policy for the Kubernetes Gateway API.
It defines a rule-based policy for replacing local responses with custom responses.
Note: For requests matching any valid HTTPRoute to which the policy is attached, the policy fully overrides any global custom response configuration in GatewayParameters (no merging).

---
config:
  theme: base
  themeVariables:
    secondaryColor: '#ffffff'
---
block
  columns 7

  classDef al_ref_box fill:#F2F2F2,stroke:#555;
  classDef al_mgw_box fill:#70991F,stroke:#555;
  classDef al_gwapi_box fill:#326CE5,stroke:#555;
  classDef al_std_box fill:#808B8F,stroke:#555;
  classDef al_self_box fill:#70991F,stroke:#777,stroke-width:5px; 

  
  space:2
  block:Targets:3
    columns 3
    HTTPRoute["<a href='../../../gateway-api/http-route/v1'>&nbsp;&nbsp;HTTPRoute&nbsp;&nbsp;</a>"]
    space:2
    class HTTPRoute al_gwapi_box
  end
  class Targets al_ref_box
  space:2
  
  space:7
  
  space:3
  
  CustomResponsePolicy["<a href='../../../microgateway/custom-response-policy/v1alpha1'>&nbsp;&nbsp;<b>CustomResponsePolicy</b>&nbsp;&nbsp;</a>"]
  class CustomResponsePolicy al_self_box
  
  
  space:2
  block:Ref:1
    columns 1
    CustomResponse["<a href='../../../microgateway/custom-response/v1alpha1'>&nbsp;&nbsp;CustomResponse&nbsp;&nbsp;</a>"]
    class CustomResponse al_mgw_box
  end
  class Ref al_ref_box
  
  

  CustomResponsePolicy -- "<i>attaches to</i>" --> Targets
  CustomResponsePolicy -- "<br><i>references</i>" --> Ref
apiVersion: microgateway.airlock.com/v1alpha1
kind: CustomResponsePolicy
metadata:
  name: custom-response-policy-example
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: backend
  policies:
    local:
      # Only use custom 401 for requests to /api
      - requestConditions:
          path:
            matcher:
              prefix: /api
        responses:
        - statusCodeCondition:
            matcher:
              exact: 401
          customResponseRef:
            name: api-401

      # Use default responses for requests to /default
      - requestConditions:
          path:
            matcher:
              prefix: /default
        responses: []

      # Customize all local error responses for other requests
      - responses:
         - statusCodeCondition:
             matcher:
               exact: 401
           customResponseRef:
             name: custom-401
         - statusCodeCondition:
             matcher:
               exact: 404
           customResponseRef:
             name: custom-404
         - statusCodeCondition:
             matcher:
               range:
                 start: 400
                 end: 499
           customResponseRef:
             name: custom-400
         - statusCodeCondition:
             matcher:
               range:
                 start: 500
                 end: 599
           customResponseRef:
             name: custom-5xx

    upstream:
      # Don't replace upstream error responses on API endpoints
      - requestConditions:
          path:
            matcher:
              prefix: /api
        responses: []

      # Replace all other upstream error responses
      - responses:
          - responseConditions:
              statusCode:
                matcher:
                  range:
                    start: 400
                    end: 499
            customResponseRef:
              name: upstream-4xx
          - responseConditions:
              statusCode:
                matcher:
                  range:
                    start: 500
                    end: 599
            customResponseRef:
              name: upstream-5xx

CustomResponsePolicy

Field Description Type Required Default Allowed Values
metadata defines the resource’s metadata ObjectMeta yes
spec defines the desired custom response configuration. object yes
status describes the current status of the CustomResponsePolicy. object no

CustomResponsePolicy.spec

Field Description Type Required Default Allowed Values
policies configures replacement policies for different kinds of responses. object yes
targetRefs are the resources this policy is being attached to. Referenced resources must be in the same namespace as the policy.
Support: HTTPRoute.
object[] yes

CustomResponsePolicy.spec.policies

Field Description Type Required Default Allowed Values
local configures policies for customizing direct responses originating from the Gateway itself during its processing (i.e., not from the upstream/backend). The first matching policy (from top to bottom) applies.
If local is not specified or if the request does not match any policy, default responses will be served.
object[] no
upstream configures policies for replacing upstream (backend) responses with custom responses. The first matching policy (from top to bottom) applies.
If upstream is not specified or if the request does not match any policy, the original upstream responses will be forwarded to the client.
object[] no

CustomResponsePolicy.spec.policies.local[]

Field Description Type Required Default Allowed Values
requestConditions defines additional request properties which must all be matched in order for this policy to apply. A policy without request conditions will always match. object no
responses specifies the local response customization rules to apply when the request matches this policy.

The rules are processed as follows:
  • The first rule (from top to bottom) where the statusCodeCondition matches the local response’s status code determines the custom response to be sent.
  • If no rule matches (or if no rules are defined), the Gateway will send default responses.
Default error responses, available as text/html, application/json and text/plain (fallback):
  • 401 -> built-in 401 response
  • 403 -> built-in 403 response
  • 404 -> built-in 404 response
  • 429 -> built-in 429 response
  • 4xx -> built-in 400 response (status code preserved for 421, others replaced with 400)
  • 5xx -> built-in 5xx response (status code preserved for 502-504, others replaced with 500)
If you wish to customize all built-in error responses, we recommend at least the following set of rules as a starting point:
local:
  - statusCodeCondition:
      matcher:
        exact: 401
    customResponseRef:
      name: custom-401
  - statusCodeCondition:
      matcher:
        exact: 404
    customResponseRef:
      name: custom-404
  - statusCodeCondition:
      matcher:
        range:
          start: 400
          end: 499
    customResponseRef:
      name: custom-400
  - statusCodeCondition:
      matcher:
        range:
          start: 500
          end: 599
    customResponseRef:
      name: custom-5xx
Examples of local responses sent by the Gateway:
  • 301 | 302 | 303 | 307 | 308 (redirects)
  • 400 (invalid requests, blocked requests, rejected requests due to invalid configuration e.g., invalid OpenAPI spec)
  • 401 (denied by access control, OIDC/JWT authentication errors, token exchange errors)
  • 403 (CSRF protection, wrong scheme)
  • 404 (request does not match any route)
  • 408 (request timeout)
  • 429 (rate limit reached)
  • 500 (invalid route/backend/policy configuration)
  • 502 | 503 (other errors)
  • 504 (backend timeout)
Note: If EnvoyExtensionPolicy is allowed, custom filters may generate arbitrary local responses.
object[] yes

CustomResponsePolicy.spec.policies.local[].requestConditions

Field Description Type Required Default Allowed Values
header defines the matching headers of a request. object no
invert indicates whether the request condition should be inverted. bool no false true, false
mediaType defines the matching media type from the content-type header of a request. object no
method defines the matching methods of a request. enum[] no CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, TRACE
path defines the matching path of a request. object no
remoteIP defines the matching remote IPs of a request.
Note: Depending on your setup you may need to adapt the remoteIP configuration in the GatewayParameters resource to ensure correct client IP detection.
object no

CustomResponsePolicy.spec.policies.local[].requestConditions.header

Field Description Type Required Default Allowed Values
name defines the name of a header. object no
value defines the value of a header. object no

CustomResponsePolicy.spec.policies.local[].requestConditions.header.name

Field Description Type Required Default Allowed Values
matcher defines the way to match a string. In comparison to a normal StringMatcher, a value is always matched ignoring the case and can’t be inverted. object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.local[].requestConditions.header.name.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.local[].requestConditions.header.value

Field Description Type Required Default Allowed Values
matcher object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.local[].requestConditions.header.value.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
ignoreCase indicates whether the matching should be case-insensitive. In case of a regex match, the regex gets wrapped with a group (?i:...). bool no false true, false
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.local[].requestConditions.mediaType

Field Description Type Required Default Allowed Values
matcher object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.local[].requestConditions.mediaType.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.local[].requestConditions.path

Field Description Type Required Default Allowed Values
matcher object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.local[].requestConditions.path.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
ignoreCase indicates whether the matching should be case-insensitive. In case of a regex match, the regex gets wrapped with a group (?i:...). bool no false true, false
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.local[].requestConditions.remoteIP

Field Description Type Required Default Allowed Values
cidrRanges defines the IPv4 or IPv6 CIDR ranges, e.g. 196.148.3.128/26 or 2001:db8::/28. string[] yes
invert indicates whether the match should be inverted. bool no false true, false

CustomResponsePolicy.spec.policies.local[].responses[]

Field Description Type Required Default Allowed Values
customResponseRef selects the custom response to send. object yes
statusCodeCondition specifies a condition which the status code of the original local response must satisfy in order for this custom response to be sent. object yes

CustomResponsePolicy.spec.policies.local[].responses[].customResponseRef

Field Description Type Required Default Allowed Values
name of the CustomResponse resource string yes

CustomResponsePolicy.spec.policies.local[].responses[].statusCodeCondition

Field Description Type Required Default Allowed Values
matcher matches one or more status codes. object yes exact{}, range{}

CustomResponsePolicy.spec.policies.local[].responses[].statusCodeCondition.matcher

Field Description Type Required Default Allowed Values
exact matches a specific status code. int32 no [100, 599]
range matches an inclusive range of status codes. object no

CustomResponsePolicy.spec.policies.local[].responses[].statusCodeCondition.matcher.range

Field Description Type Required Default Allowed Values
end of the range (inclusive). int32 yes [100, 599]
start of the range (inclusive). int32 yes [100, 599]

CustomResponsePolicy.spec.policies.upstream[]

Field Description Type Required Default Allowed Values
requestConditions defines additional request properties which must all be matched in order for this policy to apply. A policy without request conditions will always match. object no
responses specifies the upstream response customization rules to apply when the request matches this policy.

The rules are processed as follows:
  • The first rule (from top to bottom) where the responseConditions matches the upstream response determines the custom response to be sent.
  • If no rule matches (or if no upstream rules are defined), the unmodified upstream response is forwarded to the client.
object[] yes

CustomResponsePolicy.spec.policies.upstream[].requestConditions

Field Description Type Required Default Allowed Values
header defines the matching headers of a request. object no
invert indicates whether the request condition should be inverted. bool no false true, false
mediaType defines the matching media type from the content-type header of a request. object no
method defines the matching methods of a request. enum[] no CONNECT, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, TRACE
path defines the matching path of a request. object no
remoteIP defines the matching remote IPs of a request.
Note: Depending on your setup you may need to adapt the remoteIP configuration in the GatewayParameters resource to ensure correct client IP detection.
object no

CustomResponsePolicy.spec.policies.upstream[].requestConditions.header

Field Description Type Required Default Allowed Values
name defines the name of a header. object no
value defines the value of a header. object no

CustomResponsePolicy.spec.policies.upstream[].requestConditions.header.name

Field Description Type Required Default Allowed Values
matcher defines the way to match a string. In comparison to a normal StringMatcher, a value is always matched ignoring the case and can’t be inverted. object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.upstream[].requestConditions.header.name.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.upstream[].requestConditions.header.value

Field Description Type Required Default Allowed Values
matcher object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.upstream[].requestConditions.header.value.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
ignoreCase indicates whether the matching should be case-insensitive. In case of a regex match, the regex gets wrapped with a group (?i:...). bool no false true, false
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.upstream[].requestConditions.mediaType

Field Description Type Required Default Allowed Values
matcher object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.upstream[].requestConditions.mediaType.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.upstream[].requestConditions.path

Field Description Type Required Default Allowed Values
matcher object yes contains{}, exact{}, prefix{}, regex{}, suffix{}

CustomResponsePolicy.spec.policies.upstream[].requestConditions.path.matcher

Field Description Type Required Default Allowed Values
contains defines a substring match on the substring specified here. Empty contains match is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
exact defines an explicit match on the string specified here.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
ignoreCase indicates whether the matching should be case-insensitive. In case of a regex match, the regex gets wrapped with a group (?i:...). bool no false true, false
prefix defines a prefix match on the prefix specified here. Empty prefix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
regex defines a regex match on the regular expression specified here. Google’s RE2 regex engine is used.
The regex matches only single-line by default, even with “.*”. To match a multi-line string prepend (?s) to your regex.
Only one of exact, prefix, suffix, regex or contains can be set.
string no
suffix defines a suffix match on the suffix specified here. Empty suffix is not allowed, please use regex instead.
Only one of exact, prefix, suffix, regex or contains can be set.
string no

CustomResponsePolicy.spec.policies.upstream[].requestConditions.remoteIP

Field Description Type Required Default Allowed Values
cidrRanges defines the IPv4 or IPv6 CIDR ranges, e.g. 196.148.3.128/26 or 2001:db8::/28. string[] yes
invert indicates whether the match should be inverted. bool no false true, false

CustomResponsePolicy.spec.policies.upstream[].responses[]

Field Description Type Required Default Allowed Values
customResponseRef selects the custom response to send. object yes
responseConditions specifies conditions which the upstream response must all satisfy in order for this custom response to be sent. object yes

CustomResponsePolicy.spec.policies.upstream[].responses[].customResponseRef

Field Description Type Required Default Allowed Values
name of the CustomResponse resource string yes

CustomResponsePolicy.spec.policies.upstream[].responses[].responseConditions

Field Description Type Required Default Allowed Values
statusCode specifies a condition on the original upstream response’s status code. object yes

CustomResponsePolicy.spec.policies.upstream[].responses[].responseConditions.statusCode

Field Description Type Required Default Allowed Values
matcher matches one or more status codes. object yes exact{}, range{}

CustomResponsePolicy.spec.policies.upstream[].responses[].responseConditions.statusCode.matcher

Field Description Type Required Default Allowed Values
exact matches a specific status code. int32 no [100, 599]
range matches an inclusive range of status codes. object no

CustomResponsePolicy.spec.policies.upstream[].responses[].responseConditions.statusCode.matcher.range

Field Description Type Required Default Allowed Values
end of the range (inclusive). int32 yes [100, 599]
start of the range (inclusive). int32 yes [100, 599]

CustomResponsePolicy.spec.targetRefs[]

Field Description Type Required Default Allowed Values
group is the group of the target resource. string yes gateway.networking.k8s.io
kind is kind of the target resource. string yes HTTPRoute
name is the name of the target resource. string yes

CustomResponsePolicy.status

Field Description Type
ancestors is a list of ancestor resources (usually Gateways) that are associated with the policy, and the status of the policy with respect to each ancestor. When this policy attaches to a parent, the controller that manages the parent and the ancestors MUST add an entry to this list when the controller first sees the policy and SHOULD update the entry as appropriate when the relevant ancestor is modified.

Note that choosing the relevant ancestor is left to the Policy designers; an important part of Policy design is designing the right object level at which to namespace this status.

Note also that implementations MUST ONLY populate ancestor status for the Ancestor resources they are responsible for. Implementations MUST use the ControllerName field to uniquely identify the entries in this list that they are responsible for.

Note that to achieve this, the list of PolicyAncestorStatus structs MUST be treated as a map with a composite key, made up of the AncestorRef and ControllerName fields combined.

A maximum of 16 ancestors will be represented in this list. An empty list means the Policy is not relevant for any ancestors.

If this slice is full, implementations MUST NOT add further entries.
Instead they MUST consider the policy unimplementable and signal that on any related resources such as the ancestor that would be referenced here. For example, if this list was full on BackendTLSPolicy, no additional Gateways would be able to reference the Service targeted by the BackendTLSPolicy.
object[]

CustomResponsePolicy.status.ancestors[]

Field Description Type
ancestorRef corresponds with a ParentRef in the spec that this PolicyAncestorStatus struct describes the status of. object
conditions

Conditions describes the status of the Policy with respect to the given Ancestor.

Possible conditions:

  • Accepted: indicates whether the policy has been accepted or rejected by a targeted resource, and why.

    Possible reasons for this condition to be True are:
    • “Accepted”
    Possible reasons for this condition to be False are:
    • “Conflicted”
    • “Invalid”
    • “TargetNotFound”

Condition[]
controllerName is a domain/path string that indicates the name of the controller that wrote this status. This corresponds with the controllerName field on GatewayClass.

Example: “example.net/gateway-controller”.

The format of this field is DOMAIN “/” PATH, where DOMAIN and PATH are valid Kubernetes names (https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names).

Controllers MUST populate this field when writing status. Controllers should ensure that entries to status populated with their ControllerName are cleaned up when they are no longer necessary.
string

CustomResponsePolicy.status.ancestors[].ancestorRef

Field Description Type
group is the group of the referent.
When unspecified, “gateway.networking.k8s.io” is inferred.
To set the core API group (such as for a “Service” kind referent), Group must be explicitly set to "" (empty string).
string
kind is kind of the referent.

There are two kinds of parent resources with “Core” support:
Support for other resources is Implementation-Specific.
string
name is the name of the referent. string
namespace is the namespace of the referent. When unspecified, this refers to the local namespace of the Route.

Note that there are specific rules for ParentRefs which cross namespace boundaries. Cross-namespace references are only valid if they are explicitly allowed by something in the namespace they are referring to. For example:
Gateway has the AllowedRoutes field, and ReferenceGrant provides a generic way to enable any other kind of cross-namespace reference.
Note: This section only applies to the Gateway API experimental channel

ParentRefs from a Route to a Service in the same namespace are “producer” routes, which apply default routing rules to inbound connections from any namespace to the Service.

ParentRefs from a Route to a Service in a different namespace are “consumer” routes, and these routing rules are only applied to outbound connections originating from the same namespace as the Route, for which the intended destination of the connections are a Service targeted as a ParentRef of the Route.

string
port is the network port this Route targets. It can be interpreted differently based on the type of parent resource.

When the parent resource is a Gateway, this targets all listeners listening on the specified port that also support this kind of Route(and select this Route). It’s not recommended to set Port unless the networking behaviors specified in a Route must apply to a specific port as opposed to a listener(s) whose port(s) may be changed. When both Port and SectionName are specified, the name and port of the selected listener must match both specified values.
Note: This section only applies to the Gateway API experimental channel

When the parent resource is a Service, this targets a specific port in the Service spec. When both Port (experimental) and SectionName are specified, the name and port of the selected port must match both specified values.

Implementations MAY choose to support other parent resources.
Implementations supporting other types of parent resources MUST clearly document how/if Port is interpreted.

For the purpose of status, an attachment is considered successful as long as the parent resource accepts it partially. For example, Gateway listeners can restrict which Routes can attach to them by Route kind, namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from the referencing Route, the Route MUST be considered successfully attached. If no Gateway listeners accept attachment from this Route, the Route MUST be considered detached from the Gateway.
int32
sectionName is the name of a section within the target resource. In the following resources, SectionName is interpreted as the following:
  • Gateway: Listener name. When both Port (experimental) and SectionName are specified, the name and port of the selected listener must match both specified values.
  • Service: Port name. When both Port (experimental) and SectionName are specified, the name and port of the selected listener must match both specified values.
Implementations MAY choose to support attaching Routes to other resources.
If that is the case, they MUST clearly document how SectionName is interpreted.

When unspecified (empty string), this will reference the entire resource.
For the purpose of status, an attachment is considered successful if at least one section in the parent resource accepts it. For example, Gateway listeners can restrict which Routes can attach to them by Route kind, namespace, or hostname. If 1 of 2 Gateway listeners accept attachment from the referencing Route, the Route MUST be considered successfully attached. If no Gateway listeners accept attachment from this Route, the Route MUST be considered detached from the Gateway.
string