vmware-tanzu / cluster-api-provider-bringyourownhost

Kubernetes Cluster API Provider BYOH for already-provisioned hosts running Linux.
Apache License 2.0
232 stars 76 forks source link

Auto-detect the default BYOH interface for hosts #466

Open sachinkumarsingh092 opened 2 years ago

sachinkumarsingh092 commented 2 years ago

Describe the solution you'd like We have upgraded kube-vip images to v0.4.1 (#462). This version has features to auto-detect the default interface for VIP (related PR) using --autoInterface option. Currently, we detect and update the host network interface manually (agent/host_registrar.go#L86-L131). Having upgraded to the given version, we can now leverage the auto-detection feature and refactor the agent to use this instead of manual detection and updates.

Environment:

VibhorChinda commented 2 years ago

Hii @sachinkumarsingh092 @anusha94 I would love to work on this issue.

Reading the description I understand as of now the codebase is used to detect and update the host network interface manually but with upgradation of kube-vip images to v0.4.1 we could use --autoInterface option.

Could anyone point where I should make changes to leverage the required things :)) Thanks.

anusha94 commented 2 years ago

/assign @VibhorChinda

sachinkumarsingh092 commented 2 years ago

Hey @VibhorChinda, thanks for your interest in this!

So the way we currently detect the interface for the BYOH host is shown in this function (it traverses all the interfaces and matches the default network IP for the default gateway and assigns the default Interface name). This is saved as DefaultNetworkInterfaceName and used in our templates with the vip_interface environment variable. All the places where we have updated the kube-vip image can be referenced in #462.

The --autoInterface option hasn't been updated in the docs but you can just remove the --interface flag or the vip_interface in our case to achieve similar results. (See this thread: https://kubernetes.slack.com/archives/C01RXPHDATB/p1638969848103800?thread_ts=1638965549.102100&cid=C01RXPHDATB)

So for now you can start by trying if you can still achieve this without the vip_interface variable.

@anusha94 please correct me if I missed anything.

VibhorChinda commented 2 years ago

So what I have understood is I have to remove the env variable (vip_interface) from the file [Line-82, 83]

And it will automatically detect right ?

sachinkumarsingh092 commented 2 years ago

Make similar changes for the other templates mentioned in PR #462. After that, we can refactor the section that finds and sets the network interface name in agent/registration/host_registrar.go.

anusha94 commented 2 years ago

/unassign @VibhorChinda /assign @anusha94