wip: nats multi cluster, fixing helm command to follow multiple k8s config by providing the helm command from the topology itself, fix cli_logger that can now be initialized multiple times, some more stuff
This commit is contained in:
@@ -3,15 +3,27 @@ use std::str::FromStr;
|
||||
use harmony::{
|
||||
inventory::Inventory,
|
||||
modules::helm::chart::{HelmChartScore, HelmRepository, NonBlankString},
|
||||
topology::K8sAnywhereTopology,
|
||||
topology::{HelmCommand, K8sAnywhereConfig, K8sAnywhereTopology, TlsRouter, Topology},
|
||||
};
|
||||
use harmony_macros::hurl;
|
||||
use log::info;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// env_logger::init();
|
||||
let values_yaml = Some(
|
||||
deploy_nats(K8sAnywhereTopology::with_config(
|
||||
K8sAnywhereConfig::remote_k8s_from_env_var("HARMONY_NATS_SITE_1"),
|
||||
))
|
||||
.await;
|
||||
deploy_nats(K8sAnywhereTopology::with_config(
|
||||
K8sAnywhereConfig::remote_k8s_from_env_var("HARMONY_NATS_SITE_2"),
|
||||
))
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn deploy_nats<T: Topology + HelmCommand + TlsRouter + 'static>(topology: T) {
|
||||
topology.ensure_ready().await.unwrap();
|
||||
|
||||
let values_yaml = Some(format!(
|
||||
r#"config:
|
||||
cluster:
|
||||
enabled: true
|
||||
@@ -27,10 +39,12 @@ async fn main() {
|
||||
# port: 7422
|
||||
websocket:
|
||||
enabled: true
|
||||
ingress:
|
||||
enabled: true
|
||||
hosts:
|
||||
- nats-demo.sto1.nationtech.io
|
||||
ingress:
|
||||
enabled: true
|
||||
className: openshift-default
|
||||
pathType: Prefix
|
||||
hosts:
|
||||
- nats-ws.{}
|
||||
gateway:
|
||||
enabled: false
|
||||
# name: my-gateway
|
||||
@@ -38,9 +52,9 @@ async fn main() {
|
||||
natsBox:
|
||||
container:
|
||||
image:
|
||||
tag: nonroot"#
|
||||
.to_string(),
|
||||
);
|
||||
tag: nonroot"#,
|
||||
topology.get_internal_domain().await.unwrap().unwrap(),
|
||||
));
|
||||
let namespace = "nats";
|
||||
let nats = HelmChartScore {
|
||||
namespace: Some(NonBlankString::from_str(namespace).unwrap()),
|
||||
@@ -58,14 +72,9 @@ natsBox:
|
||||
)),
|
||||
};
|
||||
|
||||
harmony_cli::run(
|
||||
Inventory::autoload(),
|
||||
K8sAnywhereTopology::from_env(),
|
||||
vec![Box::new(nats)],
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
harmony_cli::run(Inventory::autoload(), topology, vec![Box::new(nats)], None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
info!(
|
||||
"Enjoy! You can test your nats cluster by running : `kubectl exec -n {namespace} -it deployment/nats-box -- nats pub test hi`"
|
||||
|
||||
Reference in New Issue
Block a user