pub struct KubernetesIngressWatcher { /* private fields */ }Expand description
Watches a Kubernetes API server for Ingress resources and maintains a live routing table.
Implementations§
Source§impl KubernetesIngressWatcher
impl KubernetesIngressWatcher
Sourcepub fn new(api_server: impl Into<String>, token: impl Into<String>) -> Self
pub fn new(api_server: impl Into<String>, token: impl Into<String>) -> Self
Create a watcher from explicit values.
api_server should be a plain-HTTP URL such as http://localhost:8001.
The default namespace is "default".
Sourcepub fn from_service_account() -> Result<Self, String>
pub fn from_service_account() -> Result<Self, String>
Attempt to configure from the Kubernetes service account files at
/var/run/secrets/kubernetes.io/serviceaccount/.
In-cluster TLS to kubernetes.default.svc is not yet implemented.
Use kubectl proxy and configure via environment variables instead:
kubectl proxy &
export RWS_K8S_API_SERVER=http://localhost:8001Sourcepub fn from_env() -> Result<Self, String>
pub fn from_env() -> Result<Self, String>
Configure from environment variables RWS_K8S_API_SERVER, RWS_K8S_TOKEN,
and (optionally) RWS_K8S_NAMESPACE.
Returns Err if RWS_K8S_API_SERVER is not set.
Sourcepub fn namespace(self, ns: impl Into<String>) -> Self
pub fn namespace(self, ns: impl Into<String>) -> Self
Override the namespace filter. Use "all" or empty string for all namespaces.
Sourcepub fn poll_interval_secs(self, secs: u64) -> Self
pub fn poll_interval_secs(self, secs: u64) -> Self
Override the polling interval in seconds (default: 30).
Sourcepub fn start(&self)
pub fn start(&self)
Spawn a background thread that polls the Kubernetes API at the configured interval. Call once at startup.
Sourcepub fn rules(&self) -> Vec<IngressRule>
pub fn rules(&self) -> Vec<IngressRule>
Return a snapshot of the current rule list.