Documentation
¶
Index ¶
- 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)
- func ResolveConfig(ctx context.Context, cl client.Client, plugin *configurationv1.KongPlugin) (json.RawMessage, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
func ResolveConfig ¶ added in v2.2.6
func ResolveConfig(ctx context.Context, cl client.Client, plugin *configurationv1.KongPlugin) (json.RawMessage, error)
ResolveConfig returns the effective configuration of the given KongPlugin, resolving the Secret references declared in spec.configFrom and spec.configPatches. The two are mutually exclusive, enforced by the KongPlugin CRD validation rules. With neither set, spec.config is returned as-is.
Types ¶
This section is empty.