Skip to main content

Module ingress

Module ingress 

Source
Expand description

Kubernetes Ingress watcher and router.

KubernetesIngressWatcher polls the Kubernetes API for Ingress resources and maintains a live route table. IngressRouter implements Application and routes incoming HTTP requests to the appropriate upstream service using the live rule table.

§Prerequisites

The watcher communicates with the Kubernetes API over plain HTTP/1.1. For in-cluster use, expose the API via kubectl proxy and point the watcher at http://localhost:8001:

kubectl proxy &
export RWS_K8S_API_SERVER=http://localhost:8001
export RWS_K8S_TOKEN=
export RWS_K8S_NAMESPACE=default

§Example

use rust_web_server::ingress::{IngressRouter, KubernetesIngressWatcher};
use rust_web_server::server::Server;

let watcher = KubernetesIngressWatcher::from_env().expect("K8s env not set");
watcher.start();

let app = IngressRouter::new(watcher);
// Server::run(app);  // pass to your server

Structs§

IngressRouter
An Application that routes incoming requests using the live Ingress rule table.
IngressRule
A single routing rule parsed from a Kubernetes Ingress resource.
KubernetesIngressWatcher
Watches a Kubernetes API server for Ingress resources and maintains a live routing table.

Functions§

parse_ingress_list
Parse a Kubernetes Ingress list JSON body into a Vec<IngressRule>.