Add a kubernetes client.

This commit is contained in:
Tom Alexander 2024-07-14 23:08:10 -04:00
parent 41cc65e7d3
commit 2a54401717
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 1103 additions and 7 deletions

1099
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -20,10 +20,13 @@ include = [
[dependencies]
# default form, http1, json, matched-path, original-uri, query, tokio, tower-log, tracing
axum = { version = "0.7.5", default-features = false, features = ["tokio", "http1", "http2", "json"] }
k8s-openapi = { version = "0.22.0", default-features = false, features = ["v1_30"] }
# default client, config, rustls-tls
kube = { version = "0.92.1", default-features = false, features = ["client", "config", "rustls-tls", "derive", "runtime"] }
serde = { version = "1.0.204", features = ["derive"] }
# default std
serde_json = { version = "1.0.120", default-features = false, features = ["std"] }
tokio = { version = "1.38.0", default-features = false, features = ["macros", "process", "rt", "rt-multi-thread", "signal"] }
tokio = { version = "1.38.0", default-features = false, features = ["macros", "process", "rt-multi-thread", "signal"] }
tower-http = { version = "0.5.2", default-features = false, features = ["trace", "timeout"] }
# default attributes, std, tracing-attributes
tracing = { version = "0.1.40", default-features = false, features = ["attributes", "std", "tracing-attributes", "async-await"] }

View File

@ -6,6 +6,7 @@ use axum::routing::get;
use axum::routing::post;
use axum::Json;
use axum::Router;
use kube::Client;
use serde::Serialize;
use tokio::signal;
use tower_http::timeout::TimeoutLayer;
@ -28,6 +29,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
)
.with(tracing_subscriber::fmt::layer())
.init();
let kubernetes_client: Client = Client::try_default()
.await
.expect("Set KUBECONFIG to a valid kubernetes config.");
let app = Router::new()
.route("/health", get(health))
.route("/hook", post(hook))