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
- Variables
- func Controller(ing *networkingv1.Ingress, classes map[string]string, defaultClass string) string
- func ForwardAuthMatches(m *unstructured.Unstructured) bool
- func IngressRoutes(ctx context.Context, c client.Client) (routes []unstructured.Unstructured, installed bool, err error)
- func IsDefaultClass(ic *networkingv1.IngressClass) bool
- func Middleware(namespace string) *unstructured.Unstructured
- func MiddlewareRef(namespace string) string
- func WithMiddleware(current, ref string) string
- func WithRouteMiddleware(ir *unstructured.Unstructured, want bool) (bool, error)
- func WithoutMiddleware(current, ref string) string
- type Reconciler
- type Unwired
Constants ¶
const ( ReasonProgrammed = "Programmed" ReasonControllerUnsupported = "ControllerUnsupported" ReasonWiringFailed = "WiringFailed" ReasonPendingRestart = "PendingRestart" ReasonSidecarMissing = "SidecarMissing" ReasonNoTargets = "NoTargets" ReasonInjectionDisabled = "InjectionDisabled" )
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 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.
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 ¶
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 ¶
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 ¶
MiddlewareRef is how an Ingress in namespace refers to the operator's Middleware there.
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 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 ¶
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 ¶
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 ¶
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.