Documentation
¶
Index ¶
- func GRPCPluginsForRule(ctx context.Context, logger logr.Logger, cl client.Client, ...) ([]configurationv1.KongPlugin, error)
- func GRPCRequestTerminationForBackendNotFound(ctx context.Context, logger logr.Logger, cl client.Client, ...) (*configurationv1.KongPlugin, error)
- func PluginsForRule(ctx context.Context, logger logr.Logger, cl client.Client, ...) ([]configurationv1.KongPlugin, error)
- func RequestTerminationForBackendNotFound(ctx context.Context, logger logr.Logger, cl client.Client, ...) (*configurationv1.KongPlugin, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GRPCPluginsForRule ¶ added in v2.3.0
func GRPCPluginsForRule( ctx context.Context, logger logr.Logger, cl client.Client, grpcRoute *gwtypes.GRPCRoute, rule gwtypes.GRPCRouteRule, pRef *gwtypes.ParentReference, ) ([]configurationv1.KongPlugin, error)
GRPCPluginsForRule creates or retrieves the KongPlugins for all filters of the given GRPCRoute rule. Mirrors PluginsForRule for GRPCRoute's own filter type (GRPCRouteFilter), but unlike the HTTPRoute path it doesn't need a merge step: GRPCRouteRule's Filters are CEL-validated to at most one RequestHeaderModifier and at most one ResponseHeaderModifier per rule (see translateGRPCFromFilter), so each translated filter maps 1:1 to its own KongPlugin. RequestMirror is not yet translated (see translateGRPCFromFilter), and ExtensionRef filters are retrieved as-is exactly like the HTTPRoute path.
func GRPCRequestTerminationForBackendNotFound ¶ added in v2.3.0
func GRPCRequestTerminationForBackendNotFound( ctx context.Context, logger logr.Logger, cl client.Client, grpcRoute *gwtypes.GRPCRoute, pRef *gwtypes.ParentReference, serviceName string, ) (*configurationv1.KongPlugin, error)
GRPCRequestTerminationForBackendNotFound creates a plugin that terminates requests to a backend-less gRPC service, mirroring RequestTerminationForBackendNotFound's role for HTTPRoute.
Kong's own default for a service with an empty upstream is a bare HTTP 503, which Kong (via its HTTP_TO_GRPC_STATUS table) does not map to a specific gRPC status for gRPC content types, so a gRPC client is left to fall back on its own HTTP-status conversion. We explicitly terminate with status_code 500 and content_type application/grpc so Kong frames the response as gRPC: this mirrors the "Internal" gRPC status (13) that HTTP 500 conventionally maps to (matching the Google API HTTP-to-gRPC status mapping), analogous to HTTPRoute's 500-on-no-backend requirement.
func PluginsForRule ¶ added in v2.1.8
func PluginsForRule( ctx context.Context, logger logr.Logger, cl client.Client, httpRoute *gwtypes.HTTPRoute, rule gwtypes.HTTPRouteRule, pRef *gwtypes.ParentReference, ) ([]configurationv1.KongPlugin, error)
PluginsForRule creates or retrieves the KongPlugins for all filters of the given HTTPRoute rule.
Workflow:
- Translates the rule's built-in filters into plugin configurations, merging filters that map to the same Kong plugin type into a single configuration. This is required because Kong enforces a unique-plugin-per-entity constraint: a route cannot have two plugins of the same type bound to it (e.g. URLRewrite and RequestHeaderModifier both map to request-transformer).
- For each resulting plugin configuration: - Derives the KongPlugin name using namegen (from the contributing filters). - Builds a new KongPlugin resource with appropriate name, namespace, labels, annotations, and config. - Calls translator.VerifyAndUpdate to handle existing plugin reconciliation.
- Retrieves the KongPlugin referenced by each ExtensionRef filter.
- Returns all plugins.
Self-managed plugin:
A plugin referenced via ExtensionRef. These are returned as-is without rebuild, annotation modification, or existence checks. The user is responsible for managing the plugin lifecycle.
Parameters:
- ctx: Context for API calls.
- logger: Structured logger.
- cl: Kubernetes client.
- httpRoute: Source HTTPRoute.
- rule: The HTTPRouteRule being processed.
- pRef: Parent (Gateway) reference.
Returns:
- kongPlugins: The translated plugin(s).
- err: Any error encountered.
func RequestTerminationForBackendNotFound ¶ added in v2.2.0
func RequestTerminationForBackendNotFound( ctx context.Context, logger logr.Logger, cl client.Client, httpRoute *gwtypes.HTTPRoute, pRef *gwtypes.ParentReference, serviceName string, ) (*configurationv1.KongPlugin, error)
RequestTerminationForBackendNotFound creates a plugin that converts Kong's default 503 for backend-less services into the Gateway API conformance-required 500 response.
Types ¶
This section is empty.