From d593e2f903185b57a4e4394ce433ffba86184992 Mon Sep 17 00:00:00 2001 From: Sven Pfennig Date: Wed, 13 Mar 2024 14:30:58 +0100 Subject: [PATCH] add steps to readme Signed-off-by: Sven Pfennig --- podtato-head/README.md | 51 +++++++++++++------ .../crates/podtato-entry/Cargo.lock | 4 +- .../crates/podtato-entry/src/main.rs | 11 ++-- 3 files changed, 45 insertions(+), 21 deletions(-) diff --git a/podtato-head/README.md b/podtato-head/README.md index b692e3a..3cfac3b 100644 --- a/podtato-head/README.md +++ b/podtato-head/README.md @@ -2,20 +2,31 @@ ## Setup -- Set up cluster -kind create cluster --image kindest/node:v1.29.0 -- ~~Set up container registry~~ -- Install KWasm +- [ ] Set up a cluster +- [ ] Configure a container registry +- [ ] Install KWasm +```sh helm install -n kwasm --create-namespace kwasm-operator kwasm/kwasm-operator --set kwasmOperator.autoProvision=true -- Check out repository -- Build podtatohead -docker build podtato-head-microservices/crates/podtato-entry -t 0xe282b0/podtato-head-entry --push -docker build podtato-head-microservices/crates/podtato-parts -t 0xe282b0/podtato-head-parts --push +``` +- Check out this repository +```sh +git clone https://github.com/Liquid-Reply/kwasm-demos.git +``` - Deploy podtatohead ```sh +helm upgrade \ + --install podtato-head ./delivery/chart +``` +- Build podtatohead Wasm +```sh +docker build podtato-head-microservices/crates/podtato-entry -t /podtato-head-entry --push +docker build podtato-head-microservices/crates/podtato-parts -t /podtato-head-parts --push +``` +- Deploy podtatohead Wasm +```sh helm upgrade \ --install podtato-head ./delivery/chart \ - --set images.repositoryDirname=0xe282b0 \ + --set images.repositoryDirname= \ --set images.pullPolicy=Always \ --set entry.repositoryBasename=podtato-head-entry \ --set entry.runtimeClassName=wasmedge \ @@ -33,20 +44,28 @@ helm upgrade \ ## Exercise 1: Add Logging -## Exercise 2: Add Probes -- Startup Probe -- Readiness Probe -- Liveness Probe +## Exercise 2: Health Checks +- [ ] Startup Probe +- [ ] Readiness Probe +- [ ] Liveness Probe ## Exercise 3: Add Metrics - Metrics Endpoint ## Exercise 4: Add Tracing -- Host Functions -- Guest Instrumentation +- https://github.com/open-telemetry/opentelemetry-rust/issues/1478 +- ## Exercise 5: Load Testing - K6 +```sh +helm repo add grafana https://grafana.github.io/helm-charts +helm install k6-operator grafana/k6-operator +``` ## Exercise 6: Chaos Testing -- Chaos Mesh \ No newline at end of file +- Chaos Mesh +```sh +helm repo add chaos-mesh https://charts.chaos-mesh.org +helm install chaos-mesh chaos-mesh/chaos-mesh -n=chaos-mesh --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath=/run/k3s/containerd/containerd.sock --version 2.6.3 --create-namespace +``` \ No newline at end of file diff --git a/podtato-head/podtato-head-microservices/crates/podtato-entry/Cargo.lock b/podtato-head/podtato-head-microservices/crates/podtato-entry/Cargo.lock index dd46ca6..af93206 100644 --- a/podtato-head/podtato-head-microservices/crates/podtato-entry/Cargo.lock +++ b/podtato-head/podtato-head-microservices/crates/podtato-entry/Cargo.lock @@ -25,9 +25,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.3" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "byteorder" diff --git a/podtato-head/podtato-head-microservices/crates/podtato-entry/src/main.rs b/podtato-head/podtato-head-microservices/crates/podtato-entry/src/main.rs index c8cb8d8..bf15b2d 100644 --- a/podtato-head/podtato-head-microservices/crates/podtato-entry/src/main.rs +++ b/podtato-head/podtato-head-microservices/crates/podtato-entry/src/main.rs @@ -31,8 +31,10 @@ async fn serve_req( Some(&_) => todo!(), None => todo!(), }; - let res = reqwest::get(url).await.unwrap(); - let content_data = res.text().await.unwrap(); + let content_data = match fetch_data(&url).await { + Ok(data) => data, + Err(_) => String::new() + }; let mut response = Response::new(Full::new(Bytes::from(content_data))); if url.ends_with(".svg") { response @@ -45,7 +47,6 @@ async fn serve_req( let content = Assets::get(&path); return match content { Some(content) => { - println!("FOUND: {}", path); let content_data = content.data.to_vec(); let mut response = Response::new(Full::new(Bytes::from(content_data))); if path.ends_with(".svg") { @@ -71,6 +72,10 @@ async fn serve_req( } } +async fn fetch_data(url: &str) -> Result { + Ok(reqwest::get(url).await?.text().await?) +} + #[tokio::main(flavor = "current_thread")] pub async fn main() -> Result<(), Box> { let port = env::var("PODTATO_PORT").unwrap_or("9000".to_string());