Skip to content

Commit

Permalink
Fix namespace issue in network delay deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla committed Feb 28, 2024
1 parent 8c64d19 commit 07702a7
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions node/tools/src/k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use k8s_openapi::{
use kube::{
api::{ListParams, PostParams},
core::{ObjectList, ObjectMeta},
Api, Client, CustomResource, ResourceExt,
Api, Client, ResourceExt,
};
use serde_json::json;
use std::{collections::HashMap, net::SocketAddr};
Expand Down Expand Up @@ -129,12 +129,9 @@ pub async fn create_or_reuse_namespace(client: &Client, name: &str) -> anyhow::R
}

pub async fn add_chaos_delay_for_node(client: &Client, node_name: &str) -> anyhow::Result<()> {
let chaos: NetworkChaos = NetworkChaos {
metadata: ObjectMeta {
name: Some("chaos-delay".to_string()),
..Default::default()
},
spec: NetworkChaosSpec {
let chaos = NetworkChaos::new(
"chaos-delay",
NetworkChaosSpec {
action: NetworkChaosAction::Delay,
mode: NetworkChaosMode::One,
selector: NetworkChaosSelector {
Expand All @@ -147,12 +144,12 @@ pub async fn add_chaos_delay_for_node(client: &Client, node_name: &str) -> anyho
},
duration: Some("10s".to_string()),
},
};

let deployments: Api<NetworkChaos> = Api::all(client.to_owned());
let post_params = PostParams::default();
let result = deployments.create(&post_params, &chaos).await?;
);

let chaos_deployments = Api::namespaced(client.clone(), "chaos-mesh");
let result = chaos_deployments
.create(&PostParams::default(), &chaos)
.await?;
info!(
"Chaos: {} , created",
result
Expand Down

0 comments on commit 07702a7

Please sign in to comment.