k8s
HTTP Client
Make outgoing HTTP requests from WASM via the Kubernetes operator
This runs the HTTP client WASM module through the Propeller Kubernetes operator. The module makes GET and POST requests using wasi:http/outgoing-handler.
Prerequisites
The operator must be deployed and a Proplet registered. Follow the end-to-end example first.
Proplet Configuration
The HTTP client needs the WASI HTTP proxy enabled on the proplet. Patch your Proplet:
kubectl patch proplet k8s-proplet --type=merge -p '{"spec":{"k8s":{"env":{"httpEnabled":true}}}}'Wait for the proplet pod to roll:
kubectl get pods -n propeller-workloads -w | grep propletBuild the WASM Module
cd propeller
make http-clientApply the Task
WASM_B64=$(base64 -w0 propeller/build/http-client.wasm)
kubectl apply -n propeller-workloads -f - <<EOF
apiVersion: propeller.propeller.absmach.eu/v1
kind: Task
metadata:
name: http-client-example
spec:
name: http-client-example
functionName: _start
file: "${WASM_B64}"
propletSelector:
propletId: "k8s-proplet"
EOFWatch and Verify
kubectl get task http-client-example -n propeller-workloads -wExpected result shows HTTP response bodies from httpbin.org GET and POST requests.
Note:
http-client.wasmis ~298KB. If the task stays inrunningwithout completing, the inline base64 may exceed your MQTT broker's message size. UseimageUrlinstead (see Large Modules).
Reference
| Field | Value |
|---|---|
functionName | _start |
daemon | false |
| Proplet env | httpEnabled: true |