Description
I have been experimenting with the wasmcloud-operator
as described in the official documentation, and I have encountered unexpected behavior regarding the ports defined in the "Application" CR.
The wasmCloud documentation claims the operator provides Kubernetes services integration, specifically "automatically creating services for wasmCloud applications deployed with an HTTP Server capability (in the future, this will become configurable)." In reality, this functionality appears to be partially broken:
Issues Identified
-
Service Object Missing a Selector:
The operator creates the Service object but doesn’t assign a selector to thewasmcloud-host
pod. Even if you manually add the selector, the Service still doesn’t work. -
Immutable Pod Ports:
The issue seems to stem from the fact that the list of ports in a pod is immutable. This makes it impossible to update the ports on thewasmcloud-host
pod dynamically when new applications are deployed.
Current Limitations
Given the current behavior, I’ve been considering ways to make Kubernetes Services work properly for wasmCloud applications. Here are two potential solutions, though there are likely others:
-
Modify the Deployment During Application Requests:
- When a client requests a new application, the operator would need to:
- Edit the
wasmcloud-host
deployment to include the new port. - Create a Service with a selector pointing to the updated pod.
- Edit the
- Downside: This triggers a pod rollout, which may disrupt active connections.
- When a client requests a new application, the operator would need to:
-
Predefine a Range of Ports at Host Instantiation:
- At the time of creating the
wasmcloud-host
, predefine a range of ports that will be available for application workloads. - When a new application is deployed, the operator dynamically creates a Service with a selector pointing to the corresponding pod.
- To enforce this, a Validating Admission Webhook can be used to ensure that the application's port definition falls within the predefined range.
- At the time of creating the