Skip to content

Commit

Permalink
net binding plugin: Add binding sidecars to virt-launcher
Browse files Browse the repository at this point in the history
Signed-off-by: Alona Paz <alkaplan@redhat.com>
  • Loading branch information
AlonaKaplan committed Aug 14, 2023
1 parent 968fcc0 commit e8cec21
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/virt-controller/services/net_binding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package services

import (
"fmt"
v1 "kubevirt.io/api/core/v1"
"kubevirt.io/kubevirt/pkg/hooks"
)

func BindingPluginSidecarList(vmi *v1.VirtualMachineInstance, config *v1.KubeVirtConfiguration) (hooks.HookSidecarList, error) {
var pluginSidecars hooks.HookSidecarList
for _, iface := range vmi.Spec.Domain.Devices.Interfaces {
if iface.Binding != nil {
pluginInfo, exist := config.NetworkConfiguration.Binding[iface.Binding.Name]
if !exist {
return nil, fmt.Errorf("couldn't find configuration for bindining: %s", iface.Binding.Name)
}
if pluginInfo.SidecarImage != "" {
pluginSidecars = append(pluginSidecars, hooks.HookSidecar{Image: pluginInfo.SidecarImage})
}
}
}
return pluginSidecars, nil
}
6 changes: 6 additions & 0 deletions pkg/virt-controller/services/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ func (t *templateService) renderLaunchManifest(vmi *v1.VirtualMachineInstance, i
return nil, err
}

bindingSidecars, err := BindingPluginSidecarList(vmi, t.clusterConfig.GetConfig())
requestedHookSidecarList = append(requestedHookSidecarList, bindingSidecars...)
if err != nil {
return nil, err
}

var command []string
if tempPod {
logger := log.DefaultLogger()
Expand Down

0 comments on commit e8cec21

Please sign in to comment.