Introduction to Modern Kubernetes Networking
Deploying serverless WebAssembly applications on Kubernetes has never been simpler. The Gateway API revolutionizes how we expose services, eliminating the need for vendor-specific annotations. This post demonstrates how to leverage SpinKube and the Gateway API to run Spin apps efficiently.
What is SpinKube?
SpinKube, a CNCF sandbox project, enables serverless WebAssembly applications on Kubernetes without containers. It uses a containerd-shim implementation to run Spin apps directly on worker nodes. For setup instructions, visit spinkube.dev.
Understanding Gateway API
The Gateway API replaces legacy Ingress with a structured approach using GatewayClass, Gateway, and route resources. This separation empowers developers to define routing rules while admins manage infrastructure. Key benefits include:
- Native support for canary rollouts
- Header-based routing
- Traffic mirroring capabilities
Explore the official documentation for technical details.
Setting Up Your Environment
Ensure you have these tools installed:
spinCLI (install from spinframework.dev)- Rust with
wasm32-wasip1target kubectlandhelmfor Kubernetes
Building and Deploying Spin Apps
Compile your Spin apps to WebAssembly:
# Build applications
pushd apps/greeter
spin build
popd
pushd apps/prime-numbers
spin build
popdPush artifacts to an OCI registry:
# Push to ephemeral registry
greeter_app_artifact=ttl.sh/spin-greeter:24h
spin registry push $greeter_app_artifact --buildDeploy to Kubernetes:
spin kube scaffold --from $greeter_app_artifact | kubectl apply -f -Exposing Apps with Gateway API
Install Gateway API resources and NGINX Gateway Fabric:
# Install Gateway API CRDs
kubectl kustomize "https://github.com/nginx/nginx-gateway-fabric/config/crd/gateway-api/standard?ref=v2.3.0" | kubectl apply -f -
# Install NGINX Gateway Fabric
helm install ngf oci://ghcr.io/nginx/charts/nginx-gateway-fabric --create-namespace -n nginx-gatewayCreate a Gateway resource to define entry points:
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: spinkube-gateway
spec:
gatewayClassName: ngf
listeners:
- protocol: HTTP
port: 80
hostname: "spin-apps.example.com"Conclusion and Next Steps
The Gateway API simplifies exposing SpinKube applications while maintaining vendor independence. For full setup instructions, explore the GitHub repository. Start testing your apps today!








