Error running http_client example in Kubernetes
Just putting this error message in here for preserving (whilst I figure out why the error is being thrown) Pretty sure it is because I need to ensure that the server and client examples are able to communicate inside Kubernetes
The origin of the error is from running this command which is in the documentation here
sudo ./kubernetes/cluster/kubectl.sh run -it --rm --restart=Never client-demo --image=tpmccallum/http_client:latest /http_client.wasm
sudo ./kubernetes/cluster/kubectl.sh run -it --rm --restart=Never client-demo --image=tpmccallum/http_client:latest /http_client.wasm hello
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: IO(Error { kind: WriteZero, message: "failed to write whole buffer" })', src/main.rs:5:70
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[2021-11-09 05:51:22.057] [error] execution failed: unreachable, Code: 0x89
[2021-11-09 05:51:22.057] [error] In instruction: unreachable (0x00) , Bytecode offset: 0x00018404
/usr/bin/crun: could not set krun executable
pod "client-demo" deleted
pod default/client-demo terminated (Error)
The error is referring to this line in the http_client source code
let res = request::get("http://127.0.0.1:1234/get", &mut writer).unwrap();
It may simply be due to the 127.0.0.1 IP address; I will need to find out what address the http_server example is being served, relative to the http_client
Hi @tpmccallum, Do you check the server is working before? I am also looking at the same issue. Looks like my server is just hang. I am not sure if the server is fine or not.
Hi @hydai Yes, I am the same, I am not 100% sure if the http_server code is properly executing in the first place. I might try another fresh install on another ec2 again. I have most of this scripted and also have docker images if you want to use this proceedure -> https://github.com/second-state/crunw/blob/main/docs/examples/http_socket_app.md#http-socket-app Thanks Chat soon Tim
Ok, just a quick update on this diagnosis ...
After following the documentation we can reach the following point; where both Rust/Wasm programs are pulled from Docker hub (as images) and then run in k8s as PODs. You can see that the http_server:latest is always running (which is great) and that http_client ran once and exited which makes sense

We have created 2 PODs (each single pod only has one container in it). We can check like this
crictl pods

The documentation has been updated to include 2 new k8s features:
- --expose
- --namespace https://github.com/second-state/crunw/blob/main/docs/examples/http_socket_app.md#run-the-http_server
IMHO, the current example may be a bit different from a so-called normal pod lifecycle. In the normal production scenario, the pod lifecycle should be controlled by the "service" and then deploy to the "deployment" instance. Since the pod may migrate from host to host, the port and network configuration should also be managed by the "service" or even more complicated "Network Policies" also proxy load balancer at the front. And the expose command could also apply to the pod at run time e.g. kubectl expose deployment/server-demo --port 1234 .
@AvengerMoJo Could you give it a try? Thanks.