Documentation
¶
Overview ¶
Package controller orchestrates Ingress and Gateway-API informers, extracting hostnames into a sorted, deduplicated set that downstream reconcilers (CoreDNS, /etc/hosts) write into the cluster.
Index ¶
- func ExtractHostnames(ingresses []*networkingv1.Ingress, gateways []*gatewayv1.Gateway, ...) []string
- func FilterGateways(gateways []*gatewayv1.Gateway, className string) []*gatewayv1.Gateway
- func FilterHTTPRoutes(routes []*gatewayv1.HTTPRoute, survivors []*gatewayv1.Gateway) []*gatewayv1.HTTPRoute
- func FilterIngresses(ingresses []*networkingv1.Ingress, className string) []*networkingv1.Ingress
- type Controller
- type Options
- type ReconcileFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractHostnames ¶
func ExtractHostnames( ingresses []*networkingv1.Ingress, gateways []*gatewayv1.Gateway, routes []*gatewayv1.HTTPRoute, ) []string
ExtractHostnames flattens hostnames from the given Ingresses, Gateways, and HTTPRoutes into a single lowercased, deduplicated, sorted slice. Wildcard patterns ("*.example.com") and empty strings are dropped because CoreDNS "rewrite name" (and /etc/hosts) cannot express them. Nil entries are tolerated.
func FilterGateways ¶ added in v0.3.0
FilterGateways returns only Gateways whose spec.gatewayClassName matches className. Empty className disables the filter (all non-nil Gateways pass through). Unlike Ingress, Gateway requires gatewayClassName as a non-optional field — there is no "ambiguous Gateway" case to drop.
func FilterHTTPRoutes ¶ added in v0.3.0
func FilterHTTPRoutes(routes []*gatewayv1.HTTPRoute, survivors []*gatewayv1.Gateway) []*gatewayv1.HTTPRoute
FilterHTTPRoutes returns only HTTPRoutes attached (via parentRefs) to one of the supplied surviving Gateways. A nil survivors slice disables the filter (every non-nil route passes through). HTTPRoutes have no class of their own — they inherit it through the Gateway they target, so the filter follows the parentRefs.
ParentRef.Namespace is optional; the Gateway-API spec defaults it to the route's own namespace, and the filter applies that default before matching. A multi-parent route is kept whenever AT LEAST ONE parentRef points at a surviving Gateway: the hostname still reaches the proxy that way, so hairpin is still required.
func FilterIngresses ¶ added in v0.3.0
func FilterIngresses(ingresses []*networkingv1.Ingress, className string) []*networkingv1.Ingress
FilterIngresses returns only Ingresses whose spec.ingressClassName matches className. An empty className disables the filter — every non-nil Ingress passes through, preserving the v0.1/v0.2 behaviour for clusters with a single ingress-controller.
When a filter IS set, Ingresses without an explicit ingressClassName are dropped: they are ambiguous, and silently hairpinning them via the wrong ingress-controller is exactly the failure mode operators with multiple controllers want this filter to prevent (upstream issue #17).
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller watches Ingress resources (and optionally Gateway+HTTPRoute) and fans every event into a single rate-limited workqueue key so reconcile calls coalesce naturally.
func New ¶
func New(opts *Options) *Controller
New builds a Controller. Logger == nil silences output. The supplied Options pointer is NOT mutated — defaulting happens on the local copy so callers can safely reuse the struct (e.g. in tests). A nil opts pointer is treated as an empty Options{} rather than panicking — keeps callers safe during early bootstrap where Options may be assembled piece-meal.
type Options ¶
type Options struct {
Core kubernetes.Interface
Gateway gatewayclient.Interface
EnableGW bool
Reconciler ReconcileFunc
ResyncPeriod time.Duration
Logger *slog.Logger
// IngressClass, when non-empty, restricts hostname extraction to
// Ingresses whose spec.ingressClassName matches it. Ingresses without an
// explicit class are dropped under the filter — see FilterIngresses for
// the rationale (hairpin-proxy upstream issue #17: multiple
// ingress-controllers with different PROXY-protocol settings).
IngressClass string
// GatewayClass, when non-empty, restricts hostname extraction to
// Gateways whose spec.gatewayClassName matches it, and to HTTPRoutes
// attached (via parentRefs) to one of the surviving Gateways.
GatewayClass string
}
Options bundles Controller dependencies.