Skip to content

Commit c33498b

Browse files
committed
Network binding plugin: Address compute container resource overhead
Signed-off-by: Orel Misan <[email protected]>
1 parent 145661d commit c33498b

File tree

1 file changed

+115
-1
lines changed

1 file changed

+115
-1
lines changed

design-proposals/network-binding-plugin/network-binding-plugin.md

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,56 @@ pod.
224224
- Mount points
225225
- Downward API
226226

227+
##### Compute Container Resource Overhead
228+
229+
For some plugins, an additional resource consumption can be expected from the virt-launcher pod compute container.
230+
For example, there could be need to execute an additional binary in the compute container.
231+
Since this binary has its own CPU and memory limits, they should be somehow accounted for.
232+
Another example could be increased resource consumption of the virt-stack resulting from using the plugin.
233+
234+
Suggested solution:
235+
236+
Additional API for compute container resource overhead:
237+
238+
The network binding plugin API in the KubeVirt CR could receive an additional input field to specify the resource requirements overhead for the compute container:
239+
240+
```yaml
241+
apiVersion: kubevirt.io/v1
242+
kind: KubeVirt
243+
metadata:
244+
name: kubevirt
245+
namespace: kubevirt
246+
spec:
247+
configuration:
248+
network:
249+
binding:
250+
mynetbindingplugin:
251+
sidecarImage: quay.io/kubevirt/mynetbindingplugin
252+
computeResourceOverhead:
253+
requests:
254+
memory: 200Mi
255+
```
256+
257+
If specified, KubeVirt will add the resource overhead specified in `computeResourceOverhead` to the compute container of the virt-launcher pod.
258+
The specified resource overhead will be added to the compute container per unique usage of the plugin (not per NIC using the binding).
259+
260+
For example, assuming there is a plugin registered with a 200Mi memory overhead for the `compute` container, and
261+
there are two interfaces using it.
262+
`virt-controller` will only add 200Mi of memory to the `compute` container.
263+
264+
Pros:
265+
- Cluster-wide definition of compute resource overhead per plugin.
266+
- Additional resources could be requested other than CPU and memory.
267+
- The resource overhead specification is visible to cluster admins.
268+
269+
Cons:
270+
- Requires an API change.
271+
- When upgrading KubeVirt / network binding plugin versions, the compute resource overhea specification might require adjustments.
272+
273+
This solution was selected since it provides the cluster admin more control in regard to resource allocation.
274+
275+
For the alternative solutions please see [Appendix G](#appendix-g-alternatives-to-compute-container-resource-overhead-specification)
276+
227277
#### Configure Pod netns
228278

229279
The CNI plugin has privileged access to the pod network namespace and
@@ -1162,4 +1212,68 @@ Libvirt configuration snippet:
11621212
</interface>
11631213
```
11641214

1165-
- The domain itself is created by the `virt-launcher`.
1215+
- The domain itself is created by the `virt-launcher`.
1216+
1217+
# Appendix G: Alternatives to compute container resource overhead specification
1218+
1219+
1. Manually setting the VM's resources:
1220+
1221+
Users could manually provide the additional memory overhead for the network binding plugin, under `spec.domain.resources.requests.memory`:
1222+
1223+
```yaml
1224+
apiVersion: kubevirt.io/v1
1225+
kind: VirtualMachine
1226+
metadata:
1227+
name: vm-cirros
1228+
spec:
1229+
template:
1230+
spec:
1231+
domain:
1232+
memory:
1233+
guest: 128Mi
1234+
resources:
1235+
requests:
1236+
memory: 640Mi # 128Mi for the guest + 512Mi for the network binding plugin
1237+
```
1238+
1239+
KubeVirt will create a virt-launcher pod's compute container with a memory request containing the following:
1240+
- Guest's memory
1241+
- Memory overhead for KubeVirt's components (calculated by virt-controller)
1242+
- Memory overhead for the network binding plugin
1243+
1244+
Pros:
1245+
- Already implemented.
1246+
1247+
Cons:
1248+
- Error prune
1249+
- Defined per VM and not cluster-wide.
1250+
- Exposes the VM owner to unnecessary implementation details
1251+
1252+
2. Mutating webhook
1253+
1254+
For each unique network binding plugin used, the VMI controller will add a label on the virt-launcher pod with the following format:
1255+
1256+
`kubevirt.io/network-binding-plugin:<plugin-name>`
1257+
1258+
The binding plugin authors will provide a [mutating webhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook) that will intercept
1259+
virt-launcher pod creation that have the above label, and add the appropriate resources requests/limits
1260+
for the pod's `compute` container.
1261+
1262+
The mutating webhook will be able to identify the plugin's compute container by its name (`compute`) or using the value of
1263+
the `kubectl.kubernetes.io/default-container` annotation.
1264+
1265+
Pros:
1266+
- Plugin authors have full control over the compute resources
1267+
- Additional API is not added to KubeVirt.
1268+
- Opens the door for additional changes to the virt-launcher pod without changes to KubeVirt.
1269+
- Code changes in KubeVirt are very small.
1270+
1271+
Cons:
1272+
- Plugin authors should provide another component and integrate it.
1273+
- Additional point of failure.
1274+
- Requires maintaining certificates for the webhook.
1275+
- Additional latency when creating VMs with network binding plugins.
1276+
- The additional resource specification is less visible to cluster admins.
1277+
- Resource specification could collide with the support container resources specified on the KubeVirt CR or other webhooks.
1278+
1279+
The requirement to maintain certificates for the webhook could be mitigated using tools such as [cert-manager](https://cert-manager.io/).

0 commit comments

Comments
 (0)