gyptazy / ProxLB

ProxLB - (Re)Balance VM Workloads Across Nodes in Proxmox Clusters. A Load Balancer for Proxmox - and more!
https://proxlb.de
GNU General Public License v3.0
131 stars 6 forks source link

Feature: new VM suggestion #8

Closed daanbosch closed 2 weeks ago

daanbosch commented 2 months ago

General

I would love to know where I should place my next VM on the cluster. Would it be possible to calculate the best fit node as well?

Task

Add an endpoint for requesting the best node based on CPU/Memory/Disk/PCI device requirements

gyptazy commented 2 months ago

Hey @daanbosch,

I can see the reason and use it already for my BoxyBSD.com project in a modified way. However, I'm not sure what the best way for this would be and I guess it also depends on the operator's use case - also if you want to recall the executable and just want to get a string returned with the hypervisor/node name or if this should be integrated into the daemon. I think I would prefer having this as a daemon where it also provides an API which can simply be called by external tools like Ansible which then returns a simple json.

Happy to head some more ideas.

Cheers, gyptazy

daanbosch commented 2 months ago

Hi gyptazy,

Yes an API endpoint would be ideal in my opinion. I use Terraform to spin up vm's If we could get an HTTP API that would return the best fit for one or more virtual machines, that would be ideal.

Best, Daan

gyptazy commented 2 months ago

Sounds good and an API interface would be my preferred way. But currently this is not my personal priority right, now. I also want to keep the dependencies and code small, so I guess it would be only a returned json via http.server without any further user authentication (could probably be done by a reverse proxy).

I think this might be a goal for 1.1 - maybe even earlier.

gyptazy commented 1 month ago

An example usage for this is already given with request #8 in PR #21 which returns the best available node for placing new VMs.

This feature is planned for release 1.1.0 and is currently only a possible approach. I will work on that after releasing 1.0.0.

baggar11 commented 1 month ago

Doesn't the "rebalance on start" option effectively make this moot? With the option enabled, you can create a vm on any cluster node. Once the new vm is started, Proxmox will already move it over to another node based on current resources?

gyptazy commented 1 month ago

Hey @baggar11,

Doesn't the "rebalance on start" option effectively make this moot? With the option enabled, you can create a vm on any cluster node. Once the new vm is started, Proxmox will already move it over to another node based on current resources?

Thanks for mentioning this. Afaik, this option only works when:

The option is already present in 7.0 but there's a bug which might be annoying: https://forum.proxmox.com/threads/enabling-ha-rebalance-on-start-reboots-running-vm-after-adding-it-to-ha-manager.125597/

So, I think it's still ok to have it here present.

Cheers, gyptazy

daanbosch commented 1 month ago

Doesn't the "rebalance on start" option effectively make this moot? With the option enabled, you can create a vm on any cluster node. Once the new vm is started, Proxmox will already move it over to another node based on current resources?

This function requires you to enable HA, which is not always a possibility. It also balances based on the current load. This tool has advanced features to choose the way you balance (Based on reserved or actual usage).

Best, Daan

gyptazy commented 3 weeks ago

This feature will already be present this evening or tomorrow by pushing the new base for upcoming features. You can then simply call it with ./proxlb -b (-b for best node) which simply returns on the cli the best next node. This way, you can easily and directly safe this into a var and use it with further toolings like Terraform or Ansible.

I’ll provide the updated docs with the feature.

cheers, gyptazy

gyptazy commented 2 weeks ago

Hey everyone!

This feature is now available and can simply be used by running proxlb with the cli arg -b (or --best-node) which returns the best next node for a VM or CT placement based on the defined options on the config.

Example:

devbox04:~# /bin/proxlb -b
virt02

Of course, you can also use different config to get the best next node for specific balancing methods. This could look like:

devbox04:~# /bin/proxlb -b -c /etc/proxlb/cluster01_memory.cfg
virt03

devbox04:~# /bin/proxlb -b -c /etc/proxlb/cluster01_cpu.cfg
virt12

This feature will also be available in the ProxLB API. See also https://github.com/gyptazy/ProxLB?tab=readme-ov-file#parameters.

Hope it helps!

Cheers, gyptazy