Skip to content

Commit 397bb78

Browse files
committed
Network binding plugin: Address sidecar resource spec
Signed-off-by: Orel Misan <[email protected]>
1 parent 145661d commit 397bb78

File tree

1 file changed

+100
-1
lines changed

1 file changed

+100
-1
lines changed

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

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

227+
##### Sidecar Resource Requirements / Limits
228+
When registering a network binding plugin in the KubeVirt CR, it is possible to specify an optional sidecar container image.
229+
Currently, this sidecar container's CPU/Memory requests and/or limits are set in any of the following scenarios:
230+
1. The VMI was configured to have dedicated CPUs (by setting `Spec.Domain.CPU.DedicatedCPUPlacement`).
231+
2. The VMI was configured to have a virt-launcher pod with [Guaranteed QOS class](https://kubernetes.io/docs/concepts/workloads/pods/pod-qos/#guaranteed) (by setting `Spec.Domain.Resources`).
232+
3. The cluster-admin had configured sidecar pods requests and/or limits on the [KubeVirt CR](https://kubevirt.io/api-reference/main/definitions.html#_v1_supportcontainerresources).
233+
234+
> **Note**
235+
>
236+
> Setting CPU/memory requests and/or limits for sidecar pods on the KubeVirt CR will apply uniformly on all [hook sidecar containers](https://kubevirt.io/user-guide/user_workloads/hook-sidecar/) and network binding plugin sidecar containers.
237+
238+
In the common scenario of a regular VM and no spacial configuration on the KubeVirt CR,
239+
the network binding plugin sidecar containers do not have CPU/Memory requests and limits.
240+
The sidecar container can have a memory leak and may cause node's destabilization.
241+
242+
Suggested solution:
243+
244+
An additional API for network binding plugin sidecar resource specification will be added:
245+
246+
The network binding plugin API in the KubeVirt CR shall receive an additional input field to specify the sidecar resource requirements:
247+
248+
```yaml
249+
apiVersion: kubevirt.io/v1
250+
kind: KubeVirt
251+
metadata:
252+
name: kubevirt
253+
namespace: kubevirt
254+
spec:
255+
configuration:
256+
network:
257+
binding:
258+
mynetbindingplugin:
259+
sidecarImage: quay.io/kubevirt/mynetbindingplugin
260+
sidecarResources:
261+
requests:
262+
cpu: 200m
263+
memory: 20Mi
264+
```
265+
266+
In case a sidecar image was specified for the plugin in the KubeVirt CR, the VMI controller (part of virt-controller) will create a sidecar container spec with the resource specification provided in `sidecarResources`.
267+
Since the VMI controller creates a single sidecar container per unique plugin defined on the VMI spec, the plugin sidecar's resources will only be added once.
268+
269+
Pros:
270+
- Cluster-wide definition of network binding plugin sidecar resources per plugin.
271+
- Finer grained control over resources allocated to network binding plugin sidecars.
272+
- Decoupling from existing hook sidecars.
273+
- Additional resources could be requested other than CPU and memory.
274+
- The additional resource specification is visible to cluster admins.
275+
276+
Cons:
277+
- Requires an API change.
278+
- When upgrading KubeVirt / network binding plugin versions, the sidecar container's resource specification might require adjustments.
279+
280+
This solution was selected since it provides the cluster admin more control in regard to resource allocation.
281+
282+
For the alternative solutions please see [Appendix G](#appendix-g-alternatives-to-plugin-sidecar-container-resource-specification)
283+
227284
#### Configure Pod netns
228285

229286
The CNI plugin has privileged access to the pod network namespace and
@@ -1162,4 +1219,46 @@ Libvirt configuration snippet:
11621219
</interface>
11631220
```
11641221

1165-
- The domain itself is created by the `virt-launcher`.
1222+
- The domain itself is created by the `virt-launcher`.
1223+
1224+
# Appendix G: Alternatives to plugin sidecar container resource specification
1225+
1226+
1. The cluster admin could configure worst case CPU/Memory requests and/or limits on the KubeVirt CR:
1227+
1228+
Pros:
1229+
- Already implemented.
1230+
1231+
Cons:
1232+
- Applies uniformly on all hook sidecars and network binding plugins
1233+
- Worst case CPU/Memory requests/limits should be defined on the KubeVirt CR which maybe wasteful for a combination of hook sidecars and network binding plugins.
1234+
- Coarse level of control.
1235+
- Only supports CPU and memory requests and limits.
1236+
1237+
2. Mutating Webhook
1238+
1239+
For each unique network binding plugin used, the VMI controller will add a label on the virt-launcher pod with the following format:
1240+
1241+
`kubevirt.io/network-binding-plugin:<plugin-name>`
1242+
1243+
The binding plugin authors will provide a [mutating webhook](https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#mutatingadmissionwebhook) that will intercept
1244+
virt-launcher pod creation that have the above label, and add the appropriate resources requests/limits
1245+
for every relevant sidecar container.
1246+
1247+
The mutating webhook will be able to identify the plugin's sidecar container by its image URL.
1248+
1249+
Pros:
1250+
- Plugin authors have full control over the sidecar's resources
1251+
- Additional API is not added to KubeVirt.
1252+
- Opens the door for additional changes to the virt-launcher pod without changes to KubeVirt.
1253+
- Code changes in KubeVirt are very small.
1254+
1255+
Cons:
1256+
- Plugin authors should provide another component and integrate it.
1257+
- Additional point of failure.
1258+
- Requires maintaining certificates for the webhook.
1259+
- Additional latency when creating VMs with network binding plugins.
1260+
- The additional resource specification is less visible to cluster admins.
1261+
- Resource specification could collide with the support container resources specified on the KubeVirt CR or other webhooks.
1262+
1263+
This solution provides flexibility for plugin authors while keeping the network binding plugin API in KubeVirt small.
1264+
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)