wiring

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 35 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 routes, attached to protected Ingresses through Traefik's router.middlewares annotation, and to protected IngressRoutes' routes through their middlewares.

Index

Constants

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

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 or IngressRoute the operator wired,
	// with the Middleware it added (MiddlewareRef on an Ingress,
	// MiddlewareName on an IngressRoute), so it removes exactly that.
	WiredAnnotation = "waf.inkwall.dev/wired"
)

Names of the Traefik wiring.

View Source
const Finalizer = "waf.inkwall.dev/unwire"

Finalizer holds a WAFPolicy until the operator has unwired its routes, so a policy deleted while the operator is down is unwired once it is back. Only the wiring controller adds it; it and `inkwall-operator unwire` remove it.

Variables

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

Traefik's kinds the operator reads and writes.

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 IngressRoutes added in v0.1.1

func IngressRoutes(ctx context.Context, c client.Client) (routes []unstructured.Unstructured, installed bool, err error)

IngressRoutes lists Traefik's IngressRoutes; installed is false, with none, when their CRD isn't.

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 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 WithRouteMiddleware added in v0.1.1

func WithRouteMiddleware(ir *unstructured.Unstructured, want bool) (bool, error)

WithRouteMiddleware adds the operator's Middleware to every route of an IngressRoute (want), first, or removes it from them. A route refers to it by name only: Traefik looks it up in the IngressRoute's namespace, which needs no allowCrossNamespace. The user's Middlewares stay, in order. It reports whether ir changed.

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
	// IngressRoutes watches Traefik's IngressRoutes once their CRD is
	// installed; nil: they are only read at each reconcile.
	IngressRoutes *crdwatch.Kind
	// Disabled: the engine isn't injected (--inject=false), so new proxy
	// pods won't have it. Every route the operator wired is unwired, and
	// the policies are released from the finalizer.
	Disabled bool
	// contains filtered or unexported fields
}

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 and IngressRoute, unwires the rest, releases the deleted policies once their routes are unwired, and reports Programmed.

func (*Reconciler) SetupWithManager

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

SetupWithManager registers the controller.

type Unwired added in v0.1.1

type Unwired struct {
	Ingresses, IngressRoutes, Middlewares, Policies int
}

Unwired counts what Unwire changed.

func Unwire

func Unwire(ctx context.Context, c client.Client) (Unwired, error)

Unwire undoes the wiring at uninstall: it removes the operator's Middleware from every Ingress and IngressRoute it wired, keeping the user's own, deletes the Middlewares it created, and then removes the finalizer from every WAFPolicy, which no operator will remove any more. 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.

Jump to

Keyboard shortcuts

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