Expand description
Kubernetes Ingress watcher and router.
KubernetesIngressWatcher watches 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 by
default. 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=defaultOr, with the http-client or http2 feature enabled, connect directly
to the in-cluster API server over TLS — see
KubernetesIngressWatcher::from_service_account.
§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 serverStructs§
- Ingress
Router - An
Applicationthat routes incoming requests using the live Ingress rule table. - Ingress
Rule - A single routing rule parsed from a Kubernetes Ingress resource.
- Kubernetes
Ingress Watcher - Watches a Kubernetes API server for Ingress resources and maintains a live routing table.
Enums§
- Path
Type - Mirrors Kubernetes’
Ingress.spec.rules[].http.paths[].pathType.
Functions§
- parse_
ingress_ list - Parse a Kubernetes Ingress list JSON body into a
Vec<IngressRule>.