Skip to content

Commit

Permalink
poc, kubevirt: Use vm name as dhcp hostname
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Llorente <ellorent@redhat.com>
  • Loading branch information
qinqon committed Feb 16, 2023
1 parent 2f9b294 commit 73959aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion go-controller/pkg/dhcp/dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
clientset "k8s.io/client-go/kubernetes"
)

func ComposeOptionsWithKubeDNS(k8scli clientset.Interface, cidr string, router string) (*nbdb.DHCPOptions, error) {
func ComposeOptionsWithKubeDNS(k8scli clientset.Interface, hostname string, cidr string, router string) (*nbdb.DHCPOptions, error) {
dnsServer, err := kubeDNSNameServer(k8scli)
if err != nil {
return nil, err
Expand All @@ -24,6 +24,7 @@ func ComposeOptionsWithKubeDNS(k8scli clientset.Interface, cidr string, router s
"dns_server": dnsServer,
"server_id": router,
"server_mac": "c0:ff:ee:00:00:01", /*TODO: Generate it*/
"hostname": hostname,
},
}

Expand Down
3 changes: 2 additions & 1 deletion go-controller/pkg/ovn/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ func (oc *DefaultNetworkController) addDHCPOptions(pod *kapi.Pod, lsp *nbdb.Logi
// Fake router to delegate on proxy arp mechanism
router := arpProxyAddress
cidr := switchSubnets[0].String()
dhcpOptions, err := dhcp.ComposeOptionsWithKubeDNS(oc.client, cidr, router)
hostname := pod.Labels[kubevirt.VMLabel]
dhcpOptions, err := dhcp.ComposeOptionsWithKubeDNS(oc.client, hostname, cidr, router)
if err != nil {
return fmt.Errorf("failed composing DHCP options: %v", err)
}
Expand Down

0 comments on commit 73959aa

Please sign in to comment.