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
- Variables
- func Controller(ing *networkingv1.Ingress, classes map[string]string, defaultClass string) string
- func ForwardAuthMatches(m *unstructured.Unstructured) bool
- func IsDefaultClass(ic *networkingv1.IngressClass) bool
- func Middleware(namespace string) *unstructured.Unstructured
- func MiddlewareRef(namespace string) string
- func Unwire(ctx context.Context, c client.Client) (ingresses, middlewares int, err error)
- func WithMiddleware(current, ref string) string
- func WithoutMiddleware(current, ref string) string
- type Reconciler
Constants ¶
const ( ReasonProgrammed = "Programmed" ReasonControllerUnsupported = "ControllerUnsupported" ReasonWiringFailed = "WiringFailed" ReasonPendingRestart = "PendingRestart" ReasonSidecarMissing = "SidecarMissing" ReasonNoTargets = "NoTargets" )
Reasons of the Programmed condition.
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 ¶
var MiddlewareGVK = schema.GroupVersionKind{Group: "traefik.io", Version: "v1alpha1", Kind: "Middleware"}
MiddlewareGVK is Traefik's Middleware.
Functions ¶
func Controller ¶
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 ¶
MiddlewareRef is how an Ingress in namespace refers to the operator's Middleware there.
func Unwire ¶
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 ¶
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 ¶
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 ¶
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.