-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
265 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
.PHONY: run | ||
run: | ||
cargo run | ||
cargo run -- --config-file "./settings/tainter.toml" | ||
|
||
.PHONY: test | ||
test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[server] | ||
host = "0.0.0.0" | ||
port = "8080" | ||
|
||
[log] | ||
max_level = "info" | ||
|
||
[[reconciler.matchers]] | ||
[reconciler.matchers.taint] | ||
effect = "NoExecute" | ||
key = "pressure" | ||
value = "memory" | ||
|
||
[[reconciler.matchers.conditions]] | ||
type = "NetworkInterfaceCard" | ||
status = "Kaput|Ruined" | ||
|
||
[[reconciler.matchers.conditions]] | ||
type = "PrivateLink" | ||
status = "severed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,45 @@ | ||
use k8s_openapi::serde::Deserialize; | ||
use clap::Parser; | ||
use kube::Client; | ||
use std::error::Error; | ||
|
||
use crate::settings::Settings; | ||
|
||
mod reconciler; | ||
mod settings; | ||
mod tainter; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(version, about, long_about = None)] | ||
struct Args { | ||
/// Path to TOML file from which configuration is read. | ||
#[arg(short, long)] | ||
config_file: String, | ||
} | ||
|
||
// Adding the actix_web::main attribute also implicitly adds tokio::main. | ||
// See https://stackoverflow.com/a/66419283. | ||
#[actix_web::main] | ||
async fn main() { | ||
// TODO read settings file and initialize. | ||
// let settings = Config::builder().add_source(config::File::with_name("example_config")).build().unwrap(); | ||
// | ||
// println!("{:?}", settings); | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
let args = Args::parse(); | ||
println!( | ||
"Reading configuration from file at path {}", | ||
args.config_file | ||
); | ||
let settings = Settings::new(args.config_file.as_str())?; | ||
|
||
tracing_subscriber::fmt() | ||
.json() | ||
// TODO ability to configure log level. | ||
.with_max_level(tracing::Level::INFO) | ||
.with_max_level(settings.log.max_level) | ||
.with_current_span(false) | ||
.init(); | ||
|
||
// let tainter = tainter::Tainter::new("localhost".to_string(), 8000); | ||
// tainter.start().await.unwrap(); | ||
tracing::info!("Initializing Kubernetes client"); | ||
|
||
let client = Client::try_default().await?; | ||
|
||
let tainter = tainter::Tainter::new(settings, client); | ||
|
||
tainter.start().await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.