forked from NationTech/harmony
		
	get domain for a service
This commit is contained in:
		
							parent
							
								
									a0884950d7
								
							
						
					
					
						commit
						b9e04d21da
					
				| @ -1,5 +1,3 @@ | ||||
| use std::{path::PathBuf, sync::Arc}; | ||||
| 
 | ||||
| use harmony::{ | ||||
|     inventory::Inventory, | ||||
|     modules::{ | ||||
| @ -11,7 +9,8 @@ use harmony::{ | ||||
|     }, | ||||
|     topology::K8sAnywhereTopology, | ||||
| }; | ||||
| use harmony_types::net::Url; | ||||
| use harmony_macros::hurl; | ||||
| use std::{path::PathBuf, sync::Arc}; | ||||
| 
 | ||||
| #[tokio::main] | ||||
| async fn main() { | ||||
| @ -24,7 +23,7 @@ async fn main() { | ||||
| 
 | ||||
|     let discord_receiver = DiscordWebhook { | ||||
|         name: "test-discord".to_string(), | ||||
|         url: Url::Url(url::Url::parse("https://discord.doesnt.exist.com").unwrap()), | ||||
|         url: hurl!("https://discord.doesnt.exist.com"), | ||||
|     }; | ||||
| 
 | ||||
|     let app = ApplicationScore { | ||||
|  | ||||
| @ -3,5 +3,5 @@ use async_trait::async_trait; | ||||
| 
 | ||||
| #[async_trait] | ||||
| pub trait Ingress { | ||||
|     async fn get_domain(&self) -> Result<String, PreparationError>; | ||||
|     async fn get_domain(&self, service: String) -> Result<String, PreparationError>; | ||||
| } | ||||
|  | ||||
| @ -576,7 +576,7 @@ impl TenantManager for K8sAnywhereTopology { | ||||
| #[async_trait] | ||||
| impl Ingress for K8sAnywhereTopology { | ||||
|     //TODO this is specifically for openshift/okd which violates the k8sanywhere idea
 | ||||
|     async fn get_domain(&self) -> Result<String, PreparationError> { | ||||
|     async fn get_domain(&self, service: String) -> Result<String, PreparationError> { | ||||
|         let client = self.k8s_client().await?; | ||||
| 
 | ||||
|         if let Some(Some(k8s_state)) = self.k8s_state.get() { | ||||
| @ -602,7 +602,7 @@ impl Ingress for K8sAnywhereTopology { | ||||
|                         })?; | ||||
| 
 | ||||
|                     match ic.data["status"]["domain"].as_str() { | ||||
|                         Some(domain) => Ok(domain.to_string()), | ||||
|                         Some(domain) => Ok(format!("{service}.{domain}")), | ||||
|                         None => Err(PreparationError::new("Could not find domain".to_string())), | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
| @ -143,7 +143,10 @@ impl< | ||||
| { | ||||
|     async fn ensure_installed(&self, topology: &T) -> Result<(), String> { | ||||
|         let image = self.application.image_name(); | ||||
|         let domain = topology.get_domain().await.map_err(|e| e.to_string())?; | ||||
|         let domain = topology | ||||
|             .get_domain(self.application.name()) | ||||
|             .await | ||||
|             .map_err(|e| e.to_string())?; | ||||
| 
 | ||||
|         // TODO Write CI/CD workflow files
 | ||||
|         // we can autotedect the CI type using the remote url (default to github action for github
 | ||||
|  | ||||
| @ -55,8 +55,7 @@ impl<T: Topology + K8sclient + HelmCommand + Ingress> Interpret<T> for ArgoInter | ||||
|         topology: &T, | ||||
|     ) -> Result<Outcome, InterpretError> { | ||||
|         let k8s_client = topology.k8s_client().await?; | ||||
|         let domain = topology.get_domain().await?; | ||||
|         let domain = format!("argo.{domain}"); | ||||
|         let domain = topology.get_domain("argo".into()).await?; | ||||
|         let helm_score = | ||||
|             argo_helm_chart_score(&self.score.namespace, self.score.openshift, &domain); | ||||
| 
 | ||||
|  | ||||
| @ -50,7 +50,7 @@ impl< | ||||
|             .await | ||||
|             .map(|ns| ns.name.clone()) | ||||
|             .unwrap_or_else(|| self.application.name()); | ||||
|         let domain = topology.get_domain().await.unwrap(); | ||||
|         let domain = topology.get_domain("ntfy".into()).await.unwrap(); | ||||
| 
 | ||||
|         let mut alerting_score = ApplicationMonitoringScore { | ||||
|             sender: CRDPrometheus { | ||||
| @ -62,7 +62,7 @@ impl< | ||||
|         }; | ||||
|         let ntfy = NtfyScore { | ||||
|             namespace: namespace.clone(), | ||||
|             host: format!("ntfy.{domain}"), | ||||
|             host: domain, | ||||
|         }; | ||||
|         ntfy.interpret(&Inventory::empty(), topology) | ||||
|             .await | ||||
|  | ||||
| @ -275,13 +275,13 @@ impl RHOBAlertingInterpret { | ||||
|             .await | ||||
|             .map_err(|e| InterpretError::new(e.to_string()))?; | ||||
| 
 | ||||
|         let domain = topology.get_domain().await?; | ||||
|         let alert_manager_domain = topology.get_domain("alert-manager".into()).await?; | ||||
|         let name = format!("{}-alert-manager", self.sender.namespace.clone()); | ||||
|         let backend_service = format!("{}-alert-manager", self.sender.namespace.clone()); | ||||
|         let namespace = self.sender.namespace.clone(); | ||||
|         let alert_manager_ingress = K8sIngressScore { | ||||
|             name: fqdn!(&name), | ||||
|             host: fqdn!(&domain), | ||||
|             host: fqdn!(&alert_manager_domain), | ||||
|             backend_service: fqdn!(&backend_service), | ||||
|             port: 9093, | ||||
|             path: Some("/".to_string()), | ||||
| @ -290,11 +290,12 @@ impl RHOBAlertingInterpret { | ||||
|             ingress_class_name: Some("openshift-default".to_string()), | ||||
|         }; | ||||
| 
 | ||||
|         let prometheus_domain = topology.get_domain("prometheus".into()).await?; | ||||
|         let name = format!("{}-prometheus", self.sender.namespace.clone()); | ||||
|         let backend_service = format!("{}-prometheus", self.sender.namespace.clone()); | ||||
|         let prometheus_ingress = K8sIngressScore { | ||||
|             name: fqdn!(&name), | ||||
|             host: fqdn!(&domain), | ||||
|             host: fqdn!(&prometheus_domain), | ||||
|             backend_service: fqdn!(&backend_service), | ||||
|             port: 9090, | ||||
|             path: Some("/".to_string()), | ||||
| @ -510,7 +511,7 @@ impl RHOBAlertingInterpret { | ||||
|             .apply(&grafana, Some(&self.sender.namespace.clone())) | ||||
|             .await | ||||
|             .map_err(|e| InterpretError::new(e.to_string()))?; | ||||
|         let domain = topology.get_domain().await?; | ||||
|         let domain = topology.get_domain("grafana".into()).await?; | ||||
|         let name = format!("{}-grafana", self.sender.namespace.clone()); | ||||
|         let backend_service = format!("{}-grafana", self.sender.namespace.clone()); | ||||
|         let grafana_ingress = K8sIngressScore { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user