This commit is contained in:
parent
39aaf7c374
commit
c46be79fc4
@ -4,6 +4,7 @@ use crate::modules::application::{Application, ApplicationFeature};
|
||||
use crate::modules::monitoring::application_monitoring::application_monitoring_score::ApplicationMonitoringScore;
|
||||
use crate::modules::monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDPrometheus;
|
||||
|
||||
use crate::topology::MultiTargetTopology;
|
||||
use crate::{
|
||||
inventory::Inventory,
|
||||
modules::monitoring::{
|
||||
@ -33,6 +34,7 @@ impl<
|
||||
+ 'static
|
||||
+ TenantManager
|
||||
+ K8sclient
|
||||
+ MultiTargetTopology
|
||||
+ std::fmt::Debug
|
||||
+ PrometheusApplicationMonitoring<CRDPrometheus>,
|
||||
> ApplicationFeature<T> for Monitoring
|
||||
|
@ -1,9 +1,28 @@
|
||||
use non_blank_string_rs::NonBlankString;
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::modules::helm::chart::{HelmChartScore, HelmRepository};
|
||||
use crate::{
|
||||
modules::helm::chart::{HelmChartScore, HelmRepository},
|
||||
topology::DeploymentTarget,
|
||||
};
|
||||
|
||||
pub fn ntfy_helm_chart_score(
|
||||
namespace: String,
|
||||
host: String,
|
||||
target: DeploymentTarget,
|
||||
) -> HelmChartScore {
|
||||
// TODO not actually the correct logic, this should be fixed by using an ingresss which is the
|
||||
// correct k8s standard.
|
||||
//
|
||||
// Another option is to delegate to the topology the ingress technology it wants to use Route,
|
||||
// Ingress or other
|
||||
let route_enabled = match target {
|
||||
DeploymentTarget::LocalDev => false,
|
||||
DeploymentTarget::Staging => true,
|
||||
DeploymentTarget::Production => true,
|
||||
};
|
||||
let ingress_enabled = !route_enabled;
|
||||
|
||||
pub fn ntfy_helm_chart_score(namespace: String, host: String) -> HelmChartScore {
|
||||
let values = format!(
|
||||
r#"
|
||||
replicaCount: 1
|
||||
@ -28,10 +47,10 @@ service:
|
||||
port: 8080
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
enabled: {ingress_enabled}
|
||||
|
||||
route:
|
||||
enabled: true
|
||||
enabled: {route_enabled}
|
||||
host: {host}
|
||||
|
||||
autoscaling:
|
||||
|
@ -11,7 +11,7 @@ use crate::{
|
||||
inventory::Inventory,
|
||||
modules::monitoring::ntfy::helm::ntfy_helm_chart::ntfy_helm_chart_score,
|
||||
score::Score,
|
||||
topology::{HelmCommand, K8sclient, Topology, k8s::K8sClient},
|
||||
topology::{k8s::K8sClient, HelmCommand, K8sclient, MultiTargetTopology, Topology},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
@ -20,7 +20,7 @@ pub struct NtfyScore {
|
||||
pub host: String,
|
||||
}
|
||||
|
||||
impl<T: Topology + HelmCommand + K8sclient> Score<T> for NtfyScore {
|
||||
impl<T: Topology + HelmCommand + K8sclient + MultiTargetTopology> Score<T> for NtfyScore {
|
||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
||||
Box::new(NtfyInterpret {
|
||||
score: self.clone(),
|
||||
@ -77,7 +77,7 @@ impl NtfyInterpret {
|
||||
vec![
|
||||
"sh",
|
||||
"-c",
|
||||
format!("NTFY_PASSWORD={password} ntfy user add --role={role} {username}")
|
||||
format!("NTFY_PASSWORD={password} ntfy user add --role={role} --ignore-exists {username}")
|
||||
.as_str(),
|
||||
],
|
||||
)
|
||||
@ -89,13 +89,13 @@ impl NtfyInterpret {
|
||||
|
||||
/// We need a ntfy interpret to wrap the HelmChartScore in order to run the score, and then bootstrap the config inside ntfy
|
||||
#[async_trait]
|
||||
impl<T: Topology + HelmCommand + K8sclient> Interpret<T> for NtfyInterpret {
|
||||
impl<T: Topology + HelmCommand + K8sclient + MultiTargetTopology> Interpret<T> for NtfyInterpret {
|
||||
async fn execute(
|
||||
&self,
|
||||
inventory: &Inventory,
|
||||
topology: &T,
|
||||
) -> Result<Outcome, InterpretError> {
|
||||
ntfy_helm_chart_score(self.score.namespace.clone(), self.score.host.clone())
|
||||
ntfy_helm_chart_score(self.score.namespace.clone(), self.score.host.clone(), topology.current_target())
|
||||
.interpret(inventory, topology)
|
||||
.await?;
|
||||
|
||||
|
@ -166,7 +166,8 @@ impl K8sPrometheusCRDAlertingInterpret {
|
||||
|
||||
let install_output = Command::new("helm")
|
||||
.args([
|
||||
"install",
|
||||
"upgrade",
|
||||
"--install",
|
||||
&chart_name,
|
||||
tgz_path.to_str().unwrap(),
|
||||
"--namespace",
|
||||
|
Loading…
Reference in New Issue
Block a user