Skip to content

Commit

Permalink
fix(infra): pass dynamic tunnel host port to cluster-server-install
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry authored and AngelOnFira committed Jul 6, 2024
1 parent 63806c8 commit c6145ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
14 changes: 14 additions & 0 deletions lib/bolt/core/src/context/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,20 @@ impl ProjectContextData {
}
}

pub async fn host_tunnel(self: &Arc<Self>) -> String {
let k8s_infra = terraform::output::read_k8s_infra(self).await;

let tunnel_port = if let config::ns::ClusterKind::SingleNode { tunnel_port, .. } =
&self.ns().cluster.kind
{
*tunnel_port
} else {
5000
};

format!("{}:{tunnel_port}", *k8s_infra.traefik_tunnel_external_ip)
}

/// Origin used for building links to the API endpoint.
pub fn origin_api(&self) -> String {
if let Some(domain_main_api) = self.domain_main_api() {
Expand Down
4 changes: 0 additions & 4 deletions lib/bolt/core/src/context/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,10 +1320,6 @@ impl ServiceContextData {
"TLS_ROOT_CA_CERT_PEM".into(),
(*tls.root_ca_cert_pem).clone(),
);
env.insert(
"K8S_TRAEFIK_TUNNEL_EXTERNAL_IP".into(),
(*k8s_infra.traefik_tunnel_external_ip).clone(),
);
// }

Ok(env)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pub fn tunnel(name: &str) -> GlobalResult<String> {
Ok(instance(Instance {
name: name.to_string(),
static_config: tunnel_static_config(),
dynamic_config: tunnel_dynamic_config(&util::env::var("K8S_TRAEFIK_TUNNEL_EXTERNAL_IP")?),
dynamic_config: tunnel_dynamic_config(&util::env::var("RIVET_HOST_TUNNEL")?),
tcp_server_transports,
}))
}
Expand All @@ -194,7 +194,7 @@ fn tunnel_static_config() -> String {
config
}

fn tunnel_dynamic_config(tunnel_external_ip: &str) -> String {
fn tunnel_dynamic_config(host_tunnel: &str) -> String {
let mut config = String::new();
for TunnelService { name, .. } in TUNNEL_SERVICES.iter() {
config.push_str(&formatdoc!(
Expand All @@ -208,7 +208,7 @@ fn tunnel_dynamic_config(tunnel_external_ip: &str) -> String {
serversTransport = "{name}"
[[tcp.services.{name}.loadBalancer.servers]]
address = "{tunnel_external_ip}:5000"
address = "{host_tunnel}"
tls = true
"#
))
Expand Down

0 comments on commit c6145ee

Please sign in to comment.