Monitor an application within a tenant #86
| @ -275,6 +275,7 @@ impl K8sAnywhereTopology { | |||||||
|             .args(["-c", "kubectl get crd -A | grep -i prometheuses"]) |             .args(["-c", "kubectl get crd -A | grep -i prometheuses"]) | ||||||
|             .status() |             .status() | ||||||
|             .map_err(|e| InterpretError::new(format!("could not connect to cluster: {}", e)))?; |             .map_err(|e| InterpretError::new(format!("could not connect to cluster: {}", e)))?; | ||||||
|  | 
 | ||||||
|         if !status.success() { |         if !status.success() { | ||||||
|             if let Some(Some(k8s_state)) = self.k8s_state.get() { |             if let Some(Some(k8s_state)) = self.k8s_state.get() { | ||||||
|                 match k8s_state.source { |                 match k8s_state.source { | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ use async_trait::async_trait; | |||||||
| use kube::api::ObjectMeta; | use kube::api::ObjectMeta; | ||||||
| use log::{debug, info}; | use log::{debug, info}; | ||||||
| use serde::Serialize; | use serde::Serialize; | ||||||
| use tokio::process::Command; | use std::process::Command; | ||||||
| 
 | 
 | ||||||
| use crate::modules::monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus; | use crate::modules::monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus; | ||||||
| use crate::modules::monitoring::kube_prometheus::crd::crd_default_rules::build_default_application_rules; | use crate::modules::monitoring::kube_prometheus::crd::crd_default_rules::build_default_application_rules; | ||||||
| @ -117,12 +117,13 @@ impl<T: Topology + K8sclient + PrometheusApplicationMonitoring<CRDPrometheus>> I | |||||||
| 
 | 
 | ||||||
| impl K8sPrometheusCRDAlertingInterpret { | impl K8sPrometheusCRDAlertingInterpret { | ||||||
|     async fn crd_exists(&self, crd: &str) -> bool { |     async fn crd_exists(&self, crd: &str) -> bool { | ||||||
|         let output = Command::new("kubectl") |         let status = Command::new("sh") | ||||||
|             .args(["get", "crd", crd]) |             .args(["-c", "kubectl get crd -A | grep -i", crd]) | ||||||
|             .output() |             .status() | ||||||
|             .await; |             .map_err(|e| InterpretError::new(format!("could not connect to cluster: {}", e))) | ||||||
|  |             .unwrap(); | ||||||
| 
 | 
 | ||||||
|         matches!(output, Ok(o) if o.status.success()) |         status.success() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async fn install_chart( |     async fn install_chart( | ||||||
| @ -136,9 +137,8 @@ impl K8sPrometheusCRDAlertingInterpret { | |||||||
|         debug!("Using temp directory: {}", temp_path.display()); |         debug!("Using temp directory: {}", temp_path.display()); | ||||||
|         let chart = format!("{}/{}", chart_path, chart_name); |         let chart = format!("{}/{}", chart_path, chart_name); | ||||||
|         let pull_output = Command::new("helm") |         let pull_output = Command::new("helm") | ||||||
|             .args(&["pull", &chart, "--destination", temp_path.to_str().unwrap()]) |             .args(["pull", &chart, "--destination", temp_path.to_str().unwrap()]) | ||||||
|             .output() |             .output() | ||||||
|             .await |  | ||||||
|             .map_err(|e| InterpretError::new(format!("Helm pull error: {}", e)))?; |             .map_err(|e| InterpretError::new(format!("Helm pull error: {}", e)))?; | ||||||
| 
 | 
 | ||||||
|         if !pull_output.status.success() { |         if !pull_output.status.success() { | ||||||
| @ -165,7 +165,7 @@ impl K8sPrometheusCRDAlertingInterpret { | |||||||
|         debug!("Installing chart from: {}", tgz_path.display()); |         debug!("Installing chart from: {}", tgz_path.display()); | ||||||
| 
 | 
 | ||||||
|         let install_output = Command::new("helm") |         let install_output = Command::new("helm") | ||||||
|             .args(&[ |             .args([ | ||||||
|                 "install", |                 "install", | ||||||
|                 &chart_name, |                 &chart_name, | ||||||
|                 tgz_path.to_str().unwrap(), |                 tgz_path.to_str().unwrap(), | ||||||
| @ -176,7 +176,6 @@ impl K8sPrometheusCRDAlertingInterpret { | |||||||
|                 "--atomic", |                 "--atomic", | ||||||
|             ]) |             ]) | ||||||
|             .output() |             .output() | ||||||
|             .await |  | ||||||
|             .map_err(|e| InterpretError::new(format!("Helm install error: {}", e)))?; |             .map_err(|e| InterpretError::new(format!("Helm install error: {}", e)))?; | ||||||
| 
 | 
 | ||||||
|         if !install_output.status.success() { |         if !install_output.status.success() { | ||||||
| @ -209,13 +208,11 @@ impl K8sPrometheusCRDAlertingInterpret { | |||||||
|                 "https://grafana.github.io/helm-charts", |                 "https://grafana.github.io/helm-charts", | ||||||
|             ]) |             ]) | ||||||
|             .output() |             .output() | ||||||
|             .await |  | ||||||
|             .unwrap(); |             .unwrap(); | ||||||
| 
 | 
 | ||||||
|         let _ = Command::new("helm") |         let _ = Command::new("helm") | ||||||
|             .args(["repo", "update"]) |             .args(["repo", "update"]) | ||||||
|             .output() |             .output() | ||||||
|             .await |  | ||||||
|             .unwrap(); |             .unwrap(); | ||||||
| 
 | 
 | ||||||
|         let output = Command::new("helm") |         let output = Command::new("helm") | ||||||
| @ -230,7 +227,6 @@ impl K8sPrometheusCRDAlertingInterpret { | |||||||
|                 "namespaceScope=true", |                 "namespaceScope=true", | ||||||
|             ]) |             ]) | ||||||
|             .output() |             .output() | ||||||
|             .await |  | ||||||
|             .unwrap(); |             .unwrap(); | ||||||
| 
 | 
 | ||||||
|         if !output.status.success() { |         if !output.status.success() { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user