### Starting Docker Compose for FastCGI Server (Shell) Source: https://github.com/zalando/skipper/blob/master/fastcgiserver/README.md This command builds the Docker images if they are not already built and starts the services defined in the docker-compose.yml file. It is used to launch the PHP-FPM server required for testing the FastCGI backend, which will listen on port 9000. ```Shell docker-compose up --build ``` -------------------------------- ### Installing Skipper from Binary (Shell) Source: https://github.com/zalando/skipper/blob/master/readme.md Download and install the Skipper binary for Linux AMD64 from the latest GitHub release. This process involves using curl to fetch the compressed archive, extracting it, and moving the executable to a directory in the user's PATH (e.g., GOBIN). A final step verifies the installation by checking the version. ```Shell curl -LO https://github.com/zalando/skipper/releases/download/v0.14.8/skipper-v0.14.8-linux-amd64.tar.gz tar xzf skipper-v0.14.8-linux-amd64.tar.gz mv skipper-v0.14.8-linux-amd64/* $GOBIN/ skipper -version ``` -------------------------------- ### Build Skipper Binary (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Provides commands to clone the Skipper repository from GitHub and compile the executable binary using the standard `make` command. Requires Go and a build environment setup. The resulting binary will be located at `./bin/skipper`. ```sh git clone https://github.com/zalando/skipper.git cd skipper make skipper ``` -------------------------------- ### Initializing Custom Skipper Proxy (Go) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/built-your-own.md This Go source code is the main entry point for a custom Skipper proxy. It initializes configuration, sets logging levels, adds a custom filter (from an external example package), and starts the Skipper proxy instance. It relies on the Skipper library and logrus. ```go /* This command provides an executable version of skipper with the default set of filters. For the list of command line options, run: skipper -help For details about the usage and extensibility of skipper, please see the documentation of the root skipper package. To see which built-in filters are available, see the skipper/filters package documentation. */ package main import ( log "github.com/sirupsen/logrus" lfilters "github.com/szuecs/skipper-example-proxy/filters" "github.com/zalando/skipper" "github.com/zalando/skipper/config" ) func main() { cfg := config.NewConfig() if err := cfg.Parse(); err != nil { log.Fatalf("Error processing config: %s", err) } log.SetLevel(cfg.ApplicationLogLevel) opt := cfg.ToOptions() opt.CustomFilters = append(opt.CustomFilters, lfilters.NewMyFilter()) log.Fatal(skipper.Run(opt)) } ``` -------------------------------- ### Run Skipper Static Backends (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Starts two separate Skipper instances acting as simple backend services on ports 9001 and 9002. Each backend uses inline routes to match all requests and respond with a static string ("1" or "2") using the `inlineContent` filter, terminating the request processing with ``. The first command includes `&` to run in the background. ```sh ./bin/skipper -inline-routes='r1: * -> inlineContent("1") -> ' --address :9001 & ./bin/skipper -inline-routes='r1: * -> inlineContent("2") -> ' --address :9002 ``` -------------------------------- ### Installing Skipper from Source (Shell) Source: https://github.com/zalando/skipper/blob/master/readme.md Clone the Skipper Git repository and build the project from source using the Makefile. This requires Go to be installed. The process compiles the source code and places the executable in the local bin directory. ```Shell git clone https://github.com/zalando/skipper.git make ./bin/skipper -version ``` -------------------------------- ### Example Skipper Route Configurations (eskip/sh) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/basics.md Presents concrete examples of Skipper route definitions written in the eskip syntax, shown within a shell block. These examples demonstrate how to apply various predicates like 'Path' and 'Cookie', chain multiple filters such as 'setRequestHeader' and 'setQuery', and define different backend types including URLs and the 'tee' filter. They illustrate practical routing scenarios. ```sh baidu: Path("/baidu") -> setRequestHeader("Host", "www.baidu.com") -> setPath("/s") -> setQuery("wd", "godoc skipper") -> "http://www.baidu.com"; google: * -> setPath("/search") -> setQuery("q", "godoc skipper") -> "https://www.google.com"; yandex: * && Cookie("yandex", "true") -> setPath("/search/") -> setQuery("text", "godoc skipper") -> tee("http://127.0.0.1:12345/") -> "https://yandex.ru"; ``` -------------------------------- ### Installing Pathmux Go Package Source: https://github.com/zalando/skipper/blob/master/pathmux/README.md This command installs the pathmux Go package using the standard Go toolchain. It fetches the package from the specified GitHub repository, making it available for use in Go projects. Requires a working Go environment. ```Shell go get github.com/zalando/pathmux ``` -------------------------------- ### VS Code Debug Launch Configuration (JSON) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Example `.vscode/launch.json` file configuring Visual Studio Code for debugging the Skipper Go application using Delve. It specifies the program entry point, debug mode, command-line arguments for Skipper, and an action to open a browser when the application signals it's ready. ```json { "version": "0.2.0", "configurations": [ { "name": "Launch Package", "type": "go", "request": "launch", "mode": "debug", "program": "${workspaceFolder}/cmd/skipper/main.go", "args": [ "-application-log-level=debug", "-address=:9999", "-inline-routes=PathSubtree(\"/\") -> inlineContent(\"Hello World\") -> " // example OIDC setup, using https://developer.microsoft.com/en-us/microsoft-365/dev-program // "-oidc-secrets-file=${workspaceFolder}/.vscode/launch.json", // "-inline-routes=* -> oauthOidcAnyClaims(\"https://login.microsoftonline.com//v2.0\",\"\",\"\",\"http://localhost:9999/authcallback\", \"profile\", \"\", \"\", \"x-auth-email:claims.email x-groups:claims.groups\") -> inlineContent(\"restricted access\") -> ", ], "serverReadyAction": { "pattern": "route settings applied", "uriFormat": "http://localhost:9999", "action": "openExternally" } } ] } ``` -------------------------------- ### Run Skipper Proxy with Round Robin (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Starts a Skipper instance configured as a proxy listening on port 9999. It uses inline routes to define a rule (`r1`) that matches all incoming requests (`*`) and distributes them using a round-robin algorithm between two backend addresses. ```sh ./bin/skipper -inline-routes='r1: * -> ' --address :9999 ``` -------------------------------- ### Starting Skipper with OPA Integration and Inline Route (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md A shell command demonstrating how to start the Skipper gateway enabling the Open Policy Agent integration, referencing the OPA configuration file (`opaconfig.yaml`), and defining a simple inline route that incorporates the `opaAuthorizeRequest` filter. ```Shell skipper -enable-open-policy-agent -open-policy-agent-config-template opaconfig.yaml \ -inline-routes 'notfound: * -> opaAuthorizeRequest("") -> inlineContent("

Authorized Hello

") -> ' ``` -------------------------------- ### Installing Skipper Helm Chart - Shell Source: https://github.com/zalando/skipper/blob/master/packaging/helm/skipper-aws/README.md Provides command-line instructions using Git and Helm to download the Skipper repository and install the AWS-specific Helm chart. Requires Git and Helm CLI tools to be installed and configured. ```sh git clone https://github.com/zalando/skipper.git cd skipper/packaging/helm/skipper-aws helm install --name skipper-aws . ``` -------------------------------- ### Test Skipper Proxy with Curl (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Demonstrates how to test the round-robin proxy setup using the `curl` command. Repeated calls to `http://localhost:9999/foo` show that the proxy alternates requests between the two backend services, resulting in alternating '1' and '2' responses. ```sh curl -s http://localhost:9999/foo 1 curl -s http://localhost:9999/foo 2 curl -s http://localhost:9999/foo 1 curl -s http://localhost:9999/foo 2 ``` -------------------------------- ### Installing htpasswd Tool - Debian/Ubuntu Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md Installs the `apache2-utils` package using `apt-get`, which provides the `htpasswd` command-line utility needed to create Basic Authentication password files. This is a prerequisite for using Skipper's Basic Auth filter and requires a Debian-based system with appropriate package manager access. ```sh apt-get install apache2-utils ``` -------------------------------- ### Running Skipper with Network Backend Inline Route Source: https://github.com/zalando/skipper/blob/master/docs/reference/backends.md Shell command to start the Skipper proxy with an inline route definition that directs GET requests to a network backend URL after adding a header. ```Shell ./bin/skipper -inline-routes 'r0: Method("GET") -> setRequestHeader("X-Passed-Skipper", "true") -> "https://www.zalando.de/";' ``` -------------------------------- ### Example OPA Configuration Template (YAML) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md This YAML snippet provides an example configuration template for an embedded Open Policy Agent instance in Skipper. It defines a service to fetch policy bundles (here from S3) and configures bundle discovery, allowing different OPA instances per filter to load specific policies based on a placeholder like `{{ .bundlename }}`. ```YAML services: - name: bundle-service url: https://my-example-opa-bucket.s3.eu-central-1.amazonaws.com credentials: s3_signing: environment_credentials: {} labels: environment: production discovery: name: discovery prefix: "/applications/{{ .bundlename }}" ``` -------------------------------- ### Starting Skipper with YAML Config File (sh) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/basics.md This command starts a local Skipper instance and directs it to load its configuration from a specified YAML file (e.g., 'config.yaml') using the '-config-file' flag. This is an alternative to providing numerous configuration options via individual command-line flags. ```sh ./bin/skipper -config-file=config.yaml ``` -------------------------------- ### Starting Pseudo Backend with Netcat Source: https://github.com/zalando/skipper/blob/master/docs/reference/plugins.md Uses the netcat utility to start a simple listener on port 9000. This acts as a backend service for Skipper to forward requests to, allowing inspection of incoming headers. ```sh % nc -l 9000 ``` -------------------------------- ### Starting Skipper with etcd URLs Source: https://github.com/zalando/skipper/blob/master/docs/data-clients/etcd.md Explains how to start the Skipper service by providing the etcd cluster endpoints using the `-etcd-urls` flag. Skipper will then synchronize its route configuration from these etcd instances. ```Shell skipper -etcd-urls http://localhost:2379,http://localhost:4001 ``` -------------------------------- ### Running Skipper Docker Container (Shell/Docker) Source: https://github.com/zalando/skipper/blob/master/readme.md Pull and run the latest Skipper Docker container from the specified registry. This provides a quick way to start the default Skipper instance without building or installing it directly on the host machine. ```Shell docker run registry.opensource.zalan.do/teapot/skipper:latest ``` -------------------------------- ### Skipper Log Output (GeoIP Plugin Loading and Request) Source: https://github.com/zalando/skipper/blob/master/docs/reference/plugins.md Shows example log messages from Skipper during startup and request processing. It indicates successful loading of the geoip plugin, listener setup, route application, and an error due to the backend being terminated by Ctrl-C. ```sh [APP]INFO[0000] found plugin geoip at plugins/filters/geoip/geoip.so [APP]INFO[0000] loaded plugin geoip (geoip) from plugins/filters/geoip/geoip.so [APP]INFO[0000] attempting to load plugin from plugins/filters/geoip/geoip.so [APP]INFO[0000] plugin geoip already loaded with InitFilter [APP]INFO[0000] Expose metrics in codahale format [APP]INFO[0000] support listener on :9911 [APP]INFO[0000] proxy listener on :9090 [APP]INFO[0000] route settings, reset, route: : * -> geoip() -> "http://127.0.0.1:9000" [APP]INFO[0000] certPathTLS or keyPathTLS not found, defaulting to HTTP [APP]INFO[0000] route settings received [APP]INFO[0000] route settings applied [APP]ERRO[0082] error while proxying, route with backend http://127.0.0.1:9000, status code 500: dialing failed false: EOF 107.12.53.5 - - [28/Nov/2018:14:39:40 +0100] "GET / HTTP/1.1" 500 22 "-" "curl/7.49.0" 2753 localhost:9090 - - ``` -------------------------------- ### Example eskip file content Source: https://github.com/zalando/skipper/blob/master/docs/data-clients/etcd.md Provides an example of how multiple Skipper routes can be defined in a local `.eskip` file format, with each route ID and its expression terminated by a semicolon. ```eskip (file format) hello: * -> status(200) -> inlineContent("Hello, world!") -> ; helloTest: Path("/test") -> status(200) -> inlineContent("Hello, test!") -> ; ``` -------------------------------- ### Starting Fake Service Listener (Netcat) Source: https://github.com/zalando/skipper/blob/master/docs/reference/egress.md Uses the `netcat` command (`nc`) to start a simple TCP listener on port 8080. This acts as a dummy backend service to which Skipper will forward requests, allowing the demonstration of injected headers. ```Shell nc -l 8080 ``` -------------------------------- ### Starting Custom Skipper Proxy (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/built-your-own.md This shell command starts the compiled Skipper proxy binary. It uses the `-inline-routes` flag to define a simple route that applies the custom `myFilter()`, sets the status code to 250, and then shunts the request. The output shows the proxy initializing and applying the route configuration. ```shell # start the proxy [:/tmp/go/skipper]% ./skipper -inline-routes='* -> myFilter() -> status(250) -> ' [APP]INFO[0000] Expose metrics in codahale format [APP]INFO[0000] enable swarm: false [APP]INFO[0000] Replacing tee filter specification [APP]INFO[0000] Replacing teenf filter specification [APP]INFO[0000] Replacing lua filter specification [APP]INFO[0000] support listener on :9911 [APP]INFO[0000] Dataclients are updated once, first load complete [APP]INFO[0000] proxy listener on :9090 [APP]INFO[0000] TLS settings not found, defaulting to HTTP [APP]INFO[0000] route settings, reset, route: : * -> myFilter() -> status(250) -> [APP]INFO[0000] route settings received [APP]INFO[0000] route settings applied 127.0.0.1 - - [22/Jun/2023:21:13:46 +0200] "GET /foo HTTP/1.1" 250 0 "-" "curl/7.49.0" 0 127.0.0.1:9090 - - ``` -------------------------------- ### Running Skipper with Loopback Backend Inline Routes Source: https://github.com/zalando/skipper/blob/master/docs/reference/backends.md Shell command to start the Skipper proxy with inline route definitions that include a loopback backend route and a default network backend route. ```Shell $ ./bin/skipper -inline-routes 'r0: PathSubtree("/api") -> setRequestHeader("X-Passed-Skipper", "true") -> modPath(/^\/api/, "") -> ; r1: * -> "https://www.zalando.de/";' ``` -------------------------------- ### Running Skipper with Shunt Backend Inline Routes Source: https://github.com/zalando/skipper/blob/master/docs/reference/backends.md Shell command to start the Skipper proxy with inline route definitions, including a route using the shunt backend to handle requests that don't match the first route. ```Shell $ ./bin/skipper -inline-routes 'r0: Host("zalando") -> "https://www.zalando.de/"; rest: * -> status(404) -> inlineContent("no matching route") -> "http://localhost:9999/";' ``` -------------------------------- ### Deploying Skipper Helm Chart from Registry Command Line Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/ingress-controller.md This command uses the Helm registry plugin to deploy the Skipper Helm chart from the specified quay.io repository. The `--install` flag performs an installation, `--wait` ensures Helm waits for the deployment to complete, and the final argument is the user-defined release name for the Helm deployment. ```Command Line helm registry upgrade quay.io/baez/skipper -- \ --install \ --wait \ "your release name e.g. skipper" ``` -------------------------------- ### Initial Routing Skipper DSL Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/shadow-traffic.md Defines the initial Skipper route configuration where all incoming traffic (*) is directed to the main backend at https://main.example.org. This represents the state before implementing shadow traffic. ```Skipper DSL main: * -> "https://main.example.org"; ``` -------------------------------- ### Starting Skipper with etcd and Prefix Source: https://github.com/zalando/skipper/blob/master/docs/data-clients/etcd.md Demonstrates starting Skipper with the `-etcd-prefix` option to isolate routes for different Skipper deployments within the same etcd cluster. The prefix modifies the base etcd path used by Skipper (default is `/skipper`). ```Shell skipper -etcd-urls https://cluster-config -etcd-prefix skipper1 ``` -------------------------------- ### Building Skipper Proxy Binary (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/built-your-own.md These shell commands are used to fetch necessary Go module dependencies, including Skipper and the custom filter example, and then build the Go application into an executable binary named `skipper` in the current directory. ```shell [:/tmp/go/skipper]% go mod tidy go: finding module for package github.com/zalando/skipper/config go: finding module for package github.com/szuecs/skipper-example-proxy/filters go: finding module for package github.com/sirupsen/logrus go: finding module for package github.com/zalando/skipper go: found github.com/sirupsen/logrus in github.com/sirupsen/logrus v1.9.3 go: found github.com/szuecs/skipper-example-proxy/filters in github.com/szuecs/skipper-example-proxy v0.0.0-20230622190245-63163cbaabc8 go: found github.com/zalando/skipper in github.com/zalando/skipper v0.16.117 go: found github.com/zalando/skipper/config in github.com/zalando/skipper v0.16.117 go: finding module for package github.com/nxadm/tail go: finding module for package github.com/kr/text go: finding module for package github.com/rogpeppe/go-internal/fmtsort go: found github.com/kr/text in github.com/kr/text v0.2.0 go: found github.com/rogpeppe/go-internal/fmtsort in github.com/rogpeppe/go-internal v1.10.0 ... [:/tmp/go/skipper]% go build -o skipper . ``` -------------------------------- ### Running Skipper with Dynamic Backend Inline Route Source: https://github.com/zalando/skipper/blob/master/docs/reference/backends.md Shell command to start the Skipper proxy with an inline route definition that utilizes the dynamic backend after a filter sets the target URL. ```Shell $ ./bin/skipper -inline-routes 'r0: * -> setDynamicBackendUrl("https://www.zalando.de") -> ;' ``` -------------------------------- ### Implement Filter with Cleanup (Go) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Extends the basic filter implementation to include resource cleanup. By implementing the `filters.FilterCloser` interface and providing a `Close()` method, the filter ensures that any held resources are properly released when the associated route is shut down. ```go type myFilter struct{} func NewMyFilter() *myFilter { return &myFilter{} } func (spec *myFilter) Name() string { return "myFilter" } func (spec *myFilter) CreateFilter(config []interface{}) (filters.Filter, error) { return NewMyFilter(), nil } func (f *myFilter) Request(ctx filters.FilterContext) { // change data in ctx.Request() for example } func (f *myFilter) Response(ctx filters.FilterContext) { // change data in ctx.Response() for example } func (f *myFilter) Close() error { // cleanup your filter } ``` -------------------------------- ### Starting Skipper with Basic Auth Route - Shell Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md Starts the Skipper gateway listening on address `:8080`. It configures an inline route (`-inline-routes`) named `r` that matches all requests (`*`). This route applies the `basicAuth` filter using the specified password file (`foo.passwd`), then returns a `status(200)` on success, and uses `` to stop further processing. ```sh ./bin/skipper -address :8080 -inline-routes 'r: * -> basicAuth("foo.passwd") -> status(200) -> ' ``` -------------------------------- ### Skipper DataClient Plugin Structure (Go) Source: https://github.com/zalando/skipper/blob/master/docs/reference/plugins.md Provides a minimal example of a Skipper data client plugin written in Go. It defines the required `InitDataClient` function and implements the `routing.DataClient` interface with `LoadAll` and `LoadUpdate` methods for providing route definitions. ```go package main import ( "github.com/zalando/skipper/eskip" "github.com/zalando/skipper/routing" ) func InitDataClient([]string) (routing.DataClient, error) { var dc DataClient = "" return dc, nil } type DataClient string func (dc DataClient) LoadAll() ([]*eskip.Route, error) { return eskip.Parse(string(dc)) } func (dc DataClient) LoadUpdate() ([]*eskip.Route, []string, error) { return nil, nil, nil } ``` -------------------------------- ### Running Skipper with an Eskip File (Shell) Source: https://github.com/zalando/skipper/blob/master/readme.md Start the Skipper process, instructing it to load route definitions from a specified eskip file. The command '-routes-file' points to the configuration. Running it in the background (&) allows executing subsequent commands in the same terminal. ```Shell skipper -routes-file example.eskip & ``` -------------------------------- ### Defining Internal RouteGroup for East-West Traffic (Kubernetes YAML) Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/east-west-usage.md Defines a Zalando RouteGroup custom resource for internal cluster service-to-service calls within an East-West setup. It routes traffic for the host `demo.skipper.cluster.local` to the `example` service on port 80. This is an alternative to using a standard Kubernetes Ingress resource for defining internal routes. Requires the RouteGroup CRD installed and a running Skipper instance. ```YAML apiVersion: zalando.org/v1 kind: RouteGroup metadata: name: demo namespace: default spec: hosts: - demo.skipper.cluster.local backends: - name: backend type: service serviceName: example servicePort: 80 defaultBackends: - backendName: backend ``` -------------------------------- ### Skipper Predicate Plugin Structure (Go) Source: https://github.com/zalando/skipper/blob/master/docs/reference/plugins.md Provides a minimal example of a Skipper predicate plugin written in Go. It defines the required `InitPredicate` function, a predicate specification (`noopSpec`), and a predicate implementation (`noopPredicate`) with a `Match` method. ```go package main import ( "github.com/zalando/skipper/routing" "net/http" ) type noopSpec struct{} func InitPredicate(opts []string) (routing.PredicateSpec, error) { return noopSpec{}, nil } func (s noopSpec) Name() string { return "MatchAll" } func (s noopSpec) Create(config []interface{}) (routing.Predicate, error) { return noopPredicate{}, nil } type noopPredicate struct{} func (p noopPredicate) Match(*http.Request) bool { return true } ``` -------------------------------- ### Deploying Skipper Daemonset Kubernetes Bash Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/ingress-controller.md Applies all Kubernetes manifests found in the `docs/kubernetes/deploy/daemonset` directory. This command is used to install Skipper as a Daemonset, typically exposing it via `hostNetwork`. Requires `kubectl` and access to the manifest files. ```bash kubectl create -f docs/kubernetes/deploy/daemonset ``` -------------------------------- ### Deploying Skipper Deployment Kubernetes Bash Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/ingress-controller.md Applies all Kubernetes manifests found in the `docs/kubernetes/deploy/deployment` directory. This command is used to install Skipper as a standard Deployment, often used with HPA. Requires `kubectl` and access to the manifest files. ```bash kubectl create -f docs/kubernetes/deploy/deployment ``` -------------------------------- ### Creating Go Project File (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/built-your-own.md These shell commands demonstrate how to create the project directory, initialize a Go module, and create the main Go source file (`main.go`) using command-line tools. The content for `main.go` is piped into the file. ```shell [:~]% mkdir -p /tmp/go/skipper [:~]% cd /tmp/go/skipper [:/tmp/go/skipper]% go mod init myproject go: creating new go.mod: module myproject [:/tmp/go/skipper]% cat >main.go package main import ( log "github.com/sirupsen/logrus" lfilters "github.com/szuecs/skipper-example-proxy/filters" "github.com/zalando/skipper" "github.com/zalando/skipper/config" ) func main() { cfg := config.NewConfig() if err := cfg.Parse(); err != nil { log.Fatalf("Error processing config: %s", err) } log.SetLevel(cfg.ApplicationLogLevel) opt := cfg.ToOptions() opt.CustomFilters = append(opt.CustomFilters, lfilters.NewMyFilter()) log.Fatal(skipper.Run(opt)) } CTRL-D [:/tmp/go/skipper]% ``` -------------------------------- ### Configuring Network Backend Route in Skipper Source: https://github.com/zalando/skipper/blob/master/docs/reference/backends.md Defines a route in Skipper that uses a network backend to forward requests to a specific HTTP/HTTPS URL after applying filters. This example routes GET requests and adds a header before forwarding. ```Skipper r0: Method("GET") -> setRequestHeader("X-Passed-Skipper", "true") -> "https://www.zalando.de/"; ``` -------------------------------- ### Creating a Simple Eskip Route File (Shell/Eskip) Source: https://github.com/zalando/skipper/blob/master/readme.md Create a basic route definition in the eskip configuration language and save it to a file named 'example.eskip'. This route defines a mapping where requests to the path '/hello' are forwarded to 'https://www.example.org'. This file serves as the route configuration for Skipper. ```Shell echo 'hello: Path("/hello") -> "https://www.example.org"' > example.eskip ``` -------------------------------- ### Configuring Service Rate Limit - YAML/Skipper Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/ingress-usage.md This example shows how to apply the `ratelimit` filter via a Kubernetes Ingress annotation to limit the total requests allowed per minute to a backend service on each Skipper instance. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: zalando.org/skipper-filter: ratelimit(50, "1m") name: app spec: rules: - host: app-default.example.org http: paths: - backend: service: name: app-svc port: number: 80 pathType: ImplementationSpecific ``` -------------------------------- ### Building and Testing Skipper from Source (Shell/Make) Source: https://github.com/zalando/skipper/blob/master/readme.md Execute a series of make commands to prepare dependencies, install the Skipper executable, run linters, and perform short checks on the source code. This process is part of the development workflow for building and verifying changes to the Skipper project. It assumes necessary build tools and Go environment are set up. ```Shell make deps make install make lint make shortcheck ``` -------------------------------- ### Matching Request Between Timeframe (Interval) Source: https://github.com/zalando/skipper/blob/master/docs/reference/predicates.md Examples using the `Between` predicate to match a route only if the incoming request occurs within a specified time range (inclusive of the start time, exclusive of the end time). The timeframe can be defined using RFC3339 strings with or without timezone/location, or using Unix timestamps in seconds. ```Skipper DSL Between("2016-01-01T12:00:00+02:00", "2016-02-01T12:00:00+02:00") ``` ```Skipper DSL Between("2021-02-18T00:00:00", "2021-02-18T01:00:00", "Europe/Berlin") ``` ```Skipper DSL Between(1451642400, 1454320800) ``` -------------------------------- ### Defining Internal Ingress for East-West Traffic (Kubernetes YAML) Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/east-west-usage.md Defines a standard Kubernetes Ingress object configured for internal cluster service-to-service calls within an East-West setup. It routes traffic arriving at the host `demo.skipper.cluster.local` to the `example` service on port 80, bypassing external load balancers. Requires a running Skipper instance configured for East-West traffic and a Kubernetes cluster. ```YAML apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: demo namespace: default spec: rules: - host: demo.skipper.cluster.local http: paths: - backend: service: name: example port: number: 80 pathType: ImplementationSpecific ``` -------------------------------- ### Create Test HTML File (Shell) Source: https://github.com/zalando/skipper/blob/master/packaging/readme.md Creates a simple HTML file named `hello.html` containing basic HTML content. This file serves as a static asset to be served by Skipper during testing. ```Shell echo '

Hello, world!

' > hello.html ``` -------------------------------- ### Example JSON Response for Redis Endpoints HTTP Endpoint - json Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/ratelimit.md This JSON structure demonstrates the expected format for the response body from an HTTP endpoint configured with the `-swarm-redis-remote` flag, providing a list of Redis server addresses for cluster ratelimit coordination. ```json { "endpoints": [ {"address": "10.2.0.1:6379"}, {"address": "10.2.0.2:6379"}, {"address": "10.2.0.3:6379"}, {"address": "10.2.0.4:6379"}, {"address": "10.2.0.5:6379"} ] } ``` -------------------------------- ### Skipper Filter Plugin Structure (Go) Source: https://github.com/zalando/skipper/blob/master/docs/reference/plugins.md Provides a minimal example of a Skipper filter plugin written in Go. It defines the required `InitFilter` function, a filter specification (`noopSpec`), and a filter implementation (`noopFilter`) with `Request` and `Response` methods. ```go package main import ( "github.com/zalando/skipper/filters" ) type noopSpec struct{} func InitFilter(opts []string) (filters.Spec, error) { return noopSpec{}, nil } func (s noopSpec) Name() string { return "noop" } func (s noopSpec) CreateFilter(config []interface{}) (filters.Filter, error) { return noopFilter{}, nil } type noopFilter struct{} func (f noopFilter) Request(filters.FilterContext) {} func (f noopFilter) Response(filters.FilterContext) {} ``` -------------------------------- ### Defining Combined Internal/External RouteGroup (Kubernetes YAML) Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/east-west-usage.md Defines a Zalando RouteGroup custom resource configured to handle both internal cluster (`demo.skipper.cluster.local`) and external (`demo.example.com`) traffic for the same backend service. It lists both hosts under the `hosts` field and directs traffic to the `example` service on port 80. This is an alternative to using a standard Kubernetes Ingress resource for defining combined routes. Requires the RouteGroup CRD installed and a running Skipper instance. ```YAML apiVersion: zalando.org/v1 kind: RouteGroup metadata: name: demo namespace: default spec: hosts: - demo.skipper.cluster.local - demo.example.com backends: - name: backend type: service serviceName: example servicePort: 80 defaultBackends: - backendName: backend ``` -------------------------------- ### Testing Skipper/OPA Authorization with Curl (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md Example `curl` commands used to test the configured Skipper gateway integrating with OPA. These commands demonstrate requests that should result in authorized and forbidden responses based on the hypothetical policy applied via the `opaAuthorizeRequest` filter. ```Shell curl http://localhost:9090/ -i ``` ```Shell curl http://localhost:9090/foobar -H "Authorization: Basic charlie" -i ``` ```Shell curl http://localhost:9090/foobar -i ``` -------------------------------- ### Displaying Simple Eskip File Content Source: https://github.com/zalando/skipper/blob/master/docs/data-clients/eskip-file.md Displays the content of a simple `example.eskip` file using a shell command. The file defines a single route named `hello` that maps requests to `/hello` to a target URL. ```sh % cat example.eskip ``` ```eskip hello: Path("/hello") -> "https://www.example.org" ``` -------------------------------- ### Implementing Basic OpenTracing Tracer Plugin in Go Source: https://github.com/zalando/skipper/blob/master/docs/reference/plugins.md This Go code implements a simple OpenTracing tracer plugin for Skipper using the basictracer library. The `InitTracer` function serves as the entry point, creating and returning a new basic tracer instance with an in-memory recorder and a simple sampling function. It demonstrates the required signature for Skipper tracer plugins but does not utilize the input options in this minimal example. ```go package main import ( basic "github.com/opentracing/basictracer-go" opentracing "github.com/opentracing/opentracing-go" ) func InitTracer(opts []string) (opentracing.Tracer, error) { return basic.NewTracerWithOptions(basic.Options{ Recorder: basic.NewInMemoryRecorder(), ShouldSample: func(traceID uint64) bool { return traceID%64 == 0 }, MaxLogsPerSpan: 25, }), nil } ``` -------------------------------- ### Running Skipper with GeoIP Filter Plugin Source: https://github.com/zalando/skipper/blob/master/docs/reference/plugins.md Starts the Skipper proxy executable, enabling the geoip filter plugin with a specified database path and configuring an inline route. The route applies the geoip filter to all incoming requests before forwarding them to the netcat backend. ```sh % ./bin/skipper -filter-plugin geoip,db=$HOME/Downloads/GeoLite2-City_20181127/GeoLite2-City.mmdb -inline-routes '* -> geoip() -> "http://127.0.0.1:9000"' ``` -------------------------------- ### Running Skipper with Eskip File (Shell) Source: https://github.com/zalando/skipper/blob/master/docs/data-clients/eskip-file.md Launches the Skipper proxy server (`skipper` binary) instructing it to load its route configurations from the specified Eskip file (`example.eskip`) using the `-routes-file` command-line flag. This is the standard way to serve static routes from a file. ```sh % skipper -routes-file example.eskip ``` -------------------------------- ### Run Skipper Docker Container (Shell) Source: https://github.com/zalando/skipper/blob/master/packaging/readme.md Starts the Skipper Docker image in detached mode (`-d`). It mounts the current directory containing the routes file, maps port 9090 from the host to the container, and launches the `skipper` process, pointing it to the mounted routes file. ```Shell docker run -d -v $(pwd):/var/skipper -p 9090:9090 my-repo/skipper:latest-SNAPSHOT skipper -routes-file /var/skipper/routes.eskip ``` -------------------------------- ### Example OPA Configuration YAML for Skipper Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md Provides a sample `opaconfig.yaml` file used to configure Skipper's integration with Open Policy Agent, detailing settings for OPA bundle retrieval from a service URL (like the Rego Playground) and configuration for the Envoy external authorization plugin. ```YAML bundles: play: resource: bundles/{{ .bundlename }} polling: long_polling_timeout_seconds: 45 services: - name: play url: https://play.openpolicyagent.org plugins: envoy_ext_authz_grpc: # This needs to match the package, defaulting to envoy/authz/allow path: envoy/http/public/allow dry-run: false decision_logs: console: true ``` -------------------------------- ### Implement Basic Custom Predicate (Go) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Provides the basic structure for creating a custom Skipper predicate in Go. It implements the `routing.PredicateSpec` interface for naming and creation, and the `routing.Predicate` interface with a `Match` method that returns a boolean indicating whether the predicate conditions are met for a given HTTP request. ```go type myPredicate struct{} func NewMyPredicate() routing.PredicateSpec { return &myPredicate{} } func (spec *myPredicate) Name() string { return "myPredicate" } func (spec *myPredicate) Create(config []interface{}) (routing.Predicate, error) { return NewMyPredicate(), nil } func (f *myPredicate) Match(r *http.Request) bool { // match data in *http.Request for example return true } ``` -------------------------------- ### Defining Minimal Routing with Zalando RouteGroup YAML Source: https://github.com/zalando/skipper/blob/master/dataclients/kubernetes/routegroup-proposal.md This snippet presents a minimal Zalando RouteGroup definition. It specifies a host (`example.org`), defines a backend service (`app-svc`), and sets that backend as the default for the specified host, achieving the same routing goal as the minimal Ingress example. ```yaml apiVersion: zalando.org/v1 kind: RouteGroup metadata: name: app spec: hosts: - example.org backends: - name: app type: service serviceName: app-svc servicePort: 80 defaultBackends: - backendName: app ``` -------------------------------- ### Creating htpasswd File - Basic Auth Setup Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md Creates or updates a password file named `foo.passwd`. The `-b` flag uses the password provided directly on the command line, `-c` creates the file if it doesn't exist, and `-B` uses bcrypt encryption. Defines the user `captain` with the password `apassword` for Basic Auth. ```sh htpasswd -bcB foo.passwd captain apassword ``` -------------------------------- ### Installing RouteGroup CRD - Shell Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/routegroups.md Provides the shell command using `kubectl apply` to install the RouteGroup Custom Resource Definition (CRD) YAML file into a Kubernetes cluster. This makes the `RouteGroup` kind available for use and allows the creation of RouteGroup resources. ```Shell kubectl apply -f dataclients/kubernetes/deploy/apply/routegroups_crd.yaml ``` -------------------------------- ### Deploying Demo Application Kubernetes Bash Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/ingress-controller.md Applies all Kubernetes manifests found in the `docs/kubernetes/deploy/demo` directory. This command deploys the simple backend application and its associated Service for testing the configured Skipper ingress. Requires `kubectl` and access to the demo manifest files. ```bash kubectl create -f docs/kubernetes/deploy/demo/ ``` -------------------------------- ### Getting Routing Table via Support Listener (sh) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/basics.md This command uses 'curl' to send an HTTP GET request to the '/routes' endpoint of the Skipper support listener (defaulting to port 9911). It retrieves the full currently active routing table in eskip format, which is useful for debugging and verification. ```sh % curl localhost:9911/routes ``` -------------------------------- ### Providing Examples of Predicates and Filters in RouteGroup YAML Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/routegroup-crd.md This YAML snippet provides examples of how predicates and filters are defined within the `predicates` and `filters` lists of a RouteGroup route object. It demonstrates the use of specific predicate functions like `Cookie()` and `Header()`, and filter functions like `setQuery()` and `compress()`, using their eskip format. ```yaml predicates: - Cookie("alpha", "enabled") - Header("X-Test", "true") filters: - setQuery("test", "alpha") - compress() ``` -------------------------------- ### Implement Basic Custom Filter (Go) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/development.md Shows the basic structure for creating a custom Skipper filter in Go. It implements the `filters.Spec` interface to define the filter's name and factory method, and the `filters.Filter` interface with `Request` and `Response` methods for processing HTTP data. ```go type myFilter struct{} func NewMyFilter() *myFilter { return &myFilter{} } func (spec *myFilter) Name() string { return "myFilter" } func (spec *myFilter) CreateFilter(config []interface{}) (filters.Filter, error) { return NewMyFilter(), nil } func (f *myFilter) Request(ctx filters.FilterContext) { // change data in ctx.Request() for example } func (f *myFilter) Response(ctx filters.FilterContext) { // change data in ctx.Response() for example } ``` -------------------------------- ### Conflicting Skipper Ingress Example (Live Service) YAML Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/ingress-usage.md This snippet presents the second part of a conflicting Ingress scenario. This Ingress ('service-x-live') defines the same host ('service-x.example.org') as the previous example but points to a different, presumably operational service ('service-x-live'), highlighting how overlapping Ingress definitions can cause unpredictable routing in Skipper. ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: service-x-live spec: rules: - host: service-x.example.org http: paths: - backend: service: name: service-x-live port: number: 80 pathType: ImplementationSpecific ``` -------------------------------- ### Integrating Base64 Module into GopherLua Go Example Source: https://github.com/zalando/skipper/blob/master/script/base64/README.md This Go code demonstrates how to initialize a GopherLua state and preload the custom base64 module using `base64.Loader`. It then executes an embedded Lua script string that requires the base64 module, decodes a base64 string, prints the decoded result, encodes it back, and prints the encoded output, including basic error handling for the decode operation. ```Go package main import "github.com/yuin/gopher-lua" import "github.com/zalando/skipper/script/base64" var script string = ` local base64 = require("base64") data, err = base64.decode("dXNlcjpwYXNzd29yZA==") if err ~= nil then error(err) else print("DATA="..data) end print("ENC="..base64.encode(data)) ` func main() { L := lua.NewState() defer L.Close() L.PreloadModule("base64", base64.Loader) if err := L.DoString(script); err != nil { panic(err) } } ``` -------------------------------- ### Starting Skipper with Bearer Injection and Secrets Source: https://github.com/zalando/skipper/blob/master/docs/reference/egress.md Starts the Skipper proxy with an inline route definition. The route matches the host 'host1', applies the `bearerinjector` filter using the secret read from `/tmp/secrets/mytoken`, and forwards the request to the service at `http://127.0.0.1:8080/`. It configures Skipper to monitor the `/tmp/secrets` directory for credentials and sets the update interval to 10 seconds. ```Shell skipper -inline-routes='Host("host1") -> bearerinjector("/tmp/secrets/mytoken") -> "http://127.0.0.1:8080/"' -credentials-paths=/tmp/secrets -credentials-update-interval=10s ``` -------------------------------- ### View Demo App Deployment Manifest Kubernetes Bash Source: https://github.com/zalando/skipper/blob/master/docs/kubernetes/ingress-controller.md Displays the content of the `deployment.yaml` file within the demo directory, which defines a simple backend application Deployment. This application is used to test the Skipper ingress setup. Requires the file and `cat`. ```bash # cat docs/kubernetes/deploy/demo/deployment.yaml ``` -------------------------------- ### OpenID Connect ID Token Example - JSON Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/auth.md An example JSON payload representing the claims typically found within an OpenID Connect ID token. This structure includes standard claims like `email`, `name`, and potentially custom claims like `groups`. Filters like `oidcClaimsQuery` operate on this type of structure for authorization decisions. ```json { "email": "someone@example.org", "groups": [ "CD-xyz", "appX-Tester" ], "name": "Some One" } ``` -------------------------------- ### Testing Route (Local Backend) with Skipper (sh) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/basics.md This command starts a local Skipper instance listening on port 8080 to act as a simple backend service for testing purposes. The inline route '*' matches all requests, the 'inlineContent' filter returns a static "Hello world!" body, the 'status' filter sets the HTTP status code to 200, and the '' filter terminates the request processing without forwarding to an external backend. ```sh ./bin/skipper -address :8080 -inline-routes 'r: * -> inlineContent("Hello world!") -> status(200) -> ' ``` -------------------------------- ### Getting Paged Routing Table via Support Listener (sh) Source: https://github.com/zalando/skipper/blob/master/docs/tutorials/basics.md This command uses 'curl' to send an HTTP GET request to the '/routes' endpoint, but includes 'offset' and 'limit' query parameters. This allows retrieving a specific subset or page of the routing table, which is necessary when the number of routes exceeds the default limit (e.g., 1024), preventing the transfer of the entire table. ```sh curl localhost:9911/routes?offset=2048&limit=512 ```