How zalando/skipper works
Project Type & Purpose
• Skipper is essentially a network-level proxy and router. It accepts incoming HTTP requests, applies route matching and filter modifications (such as header rewriting, query changes, and authentication), and then forwards the modified request to a backend service.
• It is designed for high-scale environments (handling hundreds of thousands of routes) and can be run as a stand-alone reverse proxy or used as a Kubernetes Ingress controller.
• The project is highly modular and extensible through custom filters, predicates, and data clients.
Main Architectural Components
a. Route Data Client Layer:
– This component is responsible for retrieving route definitions from various sources.
– Sub-modules include data clients for:
▪ etcd, Kubernetes Ingress, eskip files, route strings (see the “dataclients” directory).
▪ Custom configuration sources that may be integrated to update routes dynamically.
– The “eskip” language parser plays a central role in converting configuration into route rules.
b. Routing & Rule Engine:
– Once routes are acquired via data clients, this engine uses matching criteria (path, method, headers, host, cookies, etc.) to select the proper rule for each incoming request.
– It evaluates predicates (from the “predicates” directory) and then builds the filter chain.
– This component essentially composes the “lookup” logic, determining which set of filters will modify the request.
c. Filter & Predicate Layers:
– Skipper supports a large variety of filters that modify requests and responses (e.g., authentication, header modifications, circuit-breaking, rate limiting, etc.).
– The filters are organized by function (as seen in the “filters” directory) and include specialized modules (e.g., for JWT, authentication, traffic control, resizing, etc.).
– Predicate modules determine if a particular route should be matched. They check conditions like intervals, hostnames, and query parameters.
– Together, these layers form the decision-making and transformation pipeline before reaching the backend.
d. Core Proxy & Load Balancer:
– The proxy (referenced in the “proxy” directory) is the heart of the forwarder. It takes the filtered, processed requests from the routing engine and streams them to backend services.
– Load balancing is handled via a dedicated “loadbalancer” module that uses various algorithms to distribute traffic.
– Other lower-level modules (like “net” and “io”) assist with connection management, HTTP client handling, and efficient streaming.
e. Control and Management Components:
– Main executables are built in the “cmd” directory (notably cmd/skipper, cmd/routesrv, cmd/webhook). They include:
▪ Skipper’s main binary (which starts the HTTP router).
▪ A routesrv tool that helps reduce API server overload (leveraging Etag headers).
▪ A webhook for Kubernetes admission, ensuring manifest correctness.
– There is also support for circuit breakers (in the “circuit” directory) which provide fault tolerance.
f. Auxiliary Modules:
– Logging (“logging”), metrics (“metrics”), and tracing (“tracing”) components capture operational data, provide debug output, and enable performance monitoring.
– Packaging, documentation (“docs”), fuzz testing (“fuzz”), and plugin support (“plugins”, “eskipfile”) support deployment and external integration.
Relationships & Data Flow
• The request is initially processed by the Routing & Rule Engine which, based on request properties, selects a matching route.
• The engine uses the defined predicates to confirm if a route is valid and, once selected, builds a filter chain.
• Filters then modify the request (or response) – for example, by setting headers, performing authentication, applying rate limiting, or even “teeing” a copy to a shadow service.
• The processed request is then handled by the core Proxy, which uses the load balancer to direct traffic to a backend service.
• Throughout the flow, logging, metrics, and tracing components capture operational information that is fed back into monitoring systems.
• In parallel, dynamic route updates arrive from the Data Client Layer (by reading configuration files, contacting etcd, Kubernetes API, etc.), causing the routing engine to update its internal rule set without downtime.