wiring

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wiring sends a proxy's protected routes to the engine (0004 §4.4). For Traefik: an operator-owned ForwardAuth Middleware in each namespace with protected Ingresses, attached to those Ingresses through Traefik's router.middlewares annotation.

Index

Constants

View Source
const (
	ReasonProgrammed            = "Programmed"
	ReasonControllerUnsupported = "ControllerUnsupported"
	ReasonWiringFailed          = "WiringFailed"
	ReasonPendingRestart        = "PendingRestart"
	ReasonSidecarMissing        = "SidecarMissing"
	ReasonNoTargets             = "NoTargets"
)

Reasons of the Programmed condition.

View Source
const (
	// MiddlewareName is the operator's Middleware in each protected
	// namespace; not "inkwall", so it can't take over one made by hand.
	MiddlewareName = "inkwall-waf"
	// MiddlewaresAnnotation lists an Ingress router's Middlewares.
	MiddlewaresAnnotation = "traefik.ingress.kubernetes.io/router.middlewares"
	// WiredAnnotation marks an Ingress the operator wired, with the
	// Middleware it added, so it removes exactly that.
	WiredAnnotation = "waf.inkwall.dev/wired"
)

Names of the Traefik wiring.

Variables

View Source
var MiddlewareGVK = schema.GroupVersionKind{Group: "traefik.io", Version: "v1alpha1", Kind: "Middleware"}

MiddlewareGVK is Traefik's Middleware.

Functions

func Controller

func Controller(ing *networkingv1.Ingress, classes map[string]string, defaultClass string) string

Controller returns the controller of the IngressClass serving ing, or "" when it can't be told. classes maps class names to their controllers; defaultClass is the class marked default, if any.

func ForwardAuthMatches

func ForwardAuthMatches(m *unstructured.Unstructured) bool

ForwardAuthMatches reports whether a Middleware's spec is the operator's.

func IsDefaultClass

func IsDefaultClass(ic *networkingv1.IngressClass) bool

IsDefaultClass reports whether an IngressClass is the cluster default.

func Middleware

func Middleware(namespace string) *unstructured.Unstructured

Middleware returns the operator's Middleware for namespace.

func MiddlewareRef

func MiddlewareRef(namespace string) string

MiddlewareRef is how an Ingress in namespace refers to the operator's Middleware there.

func Unwire

func Unwire(ctx context.Context, c client.Client) (ingresses, middlewares int, err error)

Unwire undoes the wiring at uninstall: it removes the operator's Middleware from every Ingress it wired, keeping the user's own, then deletes the Middlewares it created. Traefik then stops sending those routes to the engine, which a proxy pod started after the uninstall doesn't have. Run it with the operator stopped, or it wires them again. It returns how many Ingresses and Middlewares it changed.

func WithMiddleware

func WithMiddleware(current, ref string) string

WithMiddleware returns the annotation value with ref added (first, so the engine sees the request before other Middlewares change it), unchanged if present.

func WithoutMiddleware

func WithoutMiddleware(current, ref string) string

WithoutMiddleware returns the annotation value without ref.

Types

type Reconciler

type Reconciler struct {
	Client client.Client
	// APIReader reads Middlewares uncached.
	APIReader client.Reader
	// PodWebhook is the MutatingWebhookConfiguration that injects the
	// engine: a proxy pod created after it without the engine was missed
	// by the webhook (SidecarMissing), one created before it predates
	// Inkwall (PendingRestart).
	PodWebhook string
	// TraefikPods selects Traefik's pods (integrations.Selectors).
	TraefikPods labels.Selector
}

Reconciler wires protected routes. It runs on the leader.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (reconcile.Result, error)

Reconcile wires every protected Traefik Ingress, unwires the rest, and reports Programmed.

func (*Reconciler) SetupWithManager

func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager registers the controller.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL