Skip to content

Commit 206d509

Browse files
Deploy webtransport to k8s (#88)
* save * save * cargo fmt * save * add webtransport enabled flag * save * revert cert changes * Turn args into env vars and add converter from pem to der at startup * Deploying webtransport to k8s - wip * save * Use two loadbalancers * cargo fmt * include wildcard in cert * push ingress * Add port to webtransport * increase replicas * 1 pod per node for webtransport * add better error handling * added scripts to automate cutting images * remove tcp load balancer * add traces back * use experimental version without final drop * save * bump yew-webtransport --------- Co-authored-by: Dario Lencina <[email protected]>
1 parent 43d665c commit 206d509

25 files changed

+497
-333
lines changed

Dockerfile.actix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ COPY . /app
1212
WORKDIR /app/actix-api
1313
RUN cargo build --release
1414

15-
FROM debian:bullseye-slim as production
15+
FROM --platform=linux/amd64 debian:bullseye-slim as production
1616

1717
COPY --from=build /usr/bin/dbmate /usr/bin/dbmate
18-
COPY --from=build /app/actix-api/target/release/actix-api /usr/bin/actix-api
18+
COPY --from=build /app/actix-api/target/release/websocket_server /usr/bin/websocket_server
19+
COPY --from=build /app/actix-api/target/release/webtransport_server /usr/bin/webtransport_server
1920
COPY --from=build /app/actix-api/startup.sh /usr/bin/startup.sh
2021
COPY --from=build /app/dbmate /app/dbmate
2122

Dockerfile.yew

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ FROM --platform=linux/amd64 development as build
1212
ENV ENABLE_OAUTH=false
1313
ENV LOGIN_URL=""
1414
ENV ACTIX_UI_BACKEND_URL="wss://api.rustlemania.com"
15+
ENV WEBTRANSPORT_HOST="https://transport.rustlemania.com:4433"
16+
ENV WEBTRANSPORT_ENABLED="false"
1517
WORKDIR /app
1618
COPY . .
1719
WORKDIR /app/yew-ui

actix-api/Cargo.lock

Lines changed: 10 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actix-api/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ path = "src/bin/websocket_server.rs"
1919
actix = "0.13.0"
2020
actix-cors = "0.6.1"
2121
actix-http = "3.2.2"
22+
actix-rt = "2.8.0"
2223
actix-web = "4.1.0"
2324
actix-web-actors = "4.1.0"
2425
anyhow = "1.0.60"
@@ -41,10 +42,10 @@ rayon = "1.7.0"
4142
reqwest = { version = "0.11.11", features = ["json"]}
4243
rustls = { version = "0.21.2", features = ["dangerous_configuration"] }
4344
rustls-native-certs = "0.6.3"
44-
sec-http3 = "0.1.1"
45+
rustls-pemfile = "1.0.3"
46+
sec-http3 = { git= "https://github.com/security-union/sec-http3.git", rev = "4c505a86b98da2aaa21cd17f37908e4ce9b64f3a" }
4547
serde = "1.0.140"
4648
serde_json = "1.0.82"
47-
structopt = "0.3.26"
4849
tokio = { version = "1.28.2", features = ["full"] }
4950
tracing = "0.1.37"
5051
tracing-subscriber = { version = "0.3.17", features = ["fmt", "ansi", "env-filter", "time", "tracing-log"] }
Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,54 @@
1-
use structopt::StructOpt;
1+
use std::net::ToSocketAddrs;
2+
3+
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
24
use tracing::{error, info};
35

4-
use sec_api::webtransport;
6+
use sec_api::webtransport::{self, Certs};
7+
8+
async fn health_responder() -> impl Responder {
9+
HttpResponse::Ok().body("Ok")
10+
}
511

6-
#[tokio::main]
12+
#[actix_rt::main]
713
async fn main() {
814
// Turned this off because it's too verbose
9-
// tracing_subscriber::fmt()
10-
// .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
11-
// .with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL)
12-
// .with_writer(std::io::stderr)
13-
// .init();
15+
tracing_subscriber::fmt()
16+
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
17+
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL)
18+
.with_writer(std::io::stderr)
19+
.init();
20+
21+
let opt = webtransport::WebTransportOpt {
22+
listen: std::env::var("LISTEN_URL")
23+
.expect("expected LISTEN_URL to be set")
24+
.to_socket_addrs()
25+
.expect("expected LISTEN_URL to be a valid socket address")
26+
.next()
27+
.expect("expected LISTEN_URL to be a valid socket address"),
28+
certs: Certs {
29+
key: std::env::var("KEY_PATH")
30+
.expect("expected KEY_PATH to be set")
31+
.into(),
32+
cert: std::env::var("CERT_PATH")
33+
.expect("expected CERT_PATH to be set")
34+
.into(),
35+
},
36+
};
37+
38+
let listen = opt.listen.clone();
39+
actix_rt::spawn(async move {
40+
info!("Starting http server: {:?}", listen);
41+
let server =
42+
HttpServer::new(|| App::new().route("/healthz", web::get().to(health_responder)))
43+
.bind(&listen)
44+
.unwrap();
45+
if let Err(e) = server.run().await {
46+
error!("http server error: {}", e);
47+
}
48+
});
1449

15-
let opt = webtransport::WebTransportOpt::from_args();
16-
match webtransport::start(opt).await {
17-
Ok(_) => info!("webtransport server stopped"),
18-
Err(e) => error!("webtransport server error: {}", e),
19-
}
50+
actix_rt::spawn(async move {
51+
webtransport::start(opt).await.unwrap();
52+
})
53+
.await;
2054
}

0 commit comments

Comments
 (0)