mirror of
https://github.com/gyptazy/ProxLB.git
synced 2026-04-06 04:41:58 +02:00
Compare commits
156 Commits
feature/gi
...
docs/209-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc663c0518 | ||
|
|
40de31bc3b | ||
|
|
5884d76ff4 | ||
|
|
7cc59eb6fc | ||
|
|
24b3b35640 | ||
|
|
f2b8829299 | ||
|
|
4b64a041cc | ||
|
|
bd1157127a | ||
|
|
be6e4bbfa0 | ||
|
|
25b631099c | ||
|
|
1d698c5688 | ||
|
|
40f848ad7f | ||
|
|
fd2725c878 | ||
|
|
34b1d72e40 | ||
|
|
ca7db26976 | ||
|
|
94552f9c9e | ||
|
|
32c67b9c96 | ||
|
|
89f337d8c3 | ||
|
|
8a724400b8 | ||
|
|
f96f1d0f64 | ||
|
|
15398712ee | ||
|
|
ddb9963062 | ||
|
|
f18a9f3d4c | ||
|
|
1402ba9732 | ||
|
|
af51f53221 | ||
|
|
bce2d640ef | ||
|
|
1bb1847e45 | ||
|
|
e9543db138 | ||
|
|
a8e8229787 | ||
|
|
d1c91c6f2a | ||
|
|
843691f8b4 | ||
|
|
c9f14946d1 | ||
|
|
77cd7b5388 | ||
|
|
55502f9bed | ||
|
|
f08b823cc4 | ||
|
|
f831d4044f | ||
|
|
e8d8d160a7 | ||
|
|
dbbd4c0ec8 | ||
|
|
fc9a0e2858 | ||
|
|
17eb43db94 | ||
|
|
06610e9b9d | ||
|
|
889b88fd6c | ||
|
|
c5ca3e13e0 | ||
|
|
c1c524f092 | ||
|
|
7ea7defa1f | ||
|
|
6147c0085b | ||
|
|
0b70a9c767 | ||
|
|
d6d22c4096 | ||
|
|
6da54c1255 | ||
|
|
b55b4ea7a0 | ||
|
|
51625fe09e | ||
|
|
f3b9d33c87 | ||
|
|
8e4326f77a | ||
|
|
3d642a7404 | ||
|
|
552364471d | ||
|
|
cf15866270 | ||
|
|
7d4def14b1 | ||
|
|
20ad9389d4 | ||
|
|
d73073a187 | ||
|
|
b307d556e5 | ||
|
|
17c4dc445e | ||
|
|
03ea29ae81 | ||
|
|
e22a27652c | ||
|
|
c3ae3e1f8c | ||
|
|
094a9b2ebb | ||
|
|
d8b1c74155 | ||
|
|
c8fad9605c | ||
|
|
e8d0c13f16 | ||
|
|
f781e74d3a | ||
|
|
3cbdb12741 | ||
|
|
a714ea8d64 | ||
|
|
d81d4380de | ||
|
|
31498da25a | ||
|
|
7f59f69eab | ||
|
|
200b7cd170 | ||
|
|
94df2fd1a6 | ||
|
|
8d8fd518fe | ||
|
|
37bb226cf0 | ||
|
|
48b8a07135 | ||
|
|
222beb360c | ||
|
|
f9b30d0af4 | ||
|
|
28f87e2907 | ||
|
|
7587e1beaf | ||
|
|
5542b9bc6c | ||
|
|
16c5ee4d74 | ||
|
|
21a73b71df | ||
|
|
d3c055cbad | ||
|
|
24b7d2c860 | ||
|
|
6e87e2d478 | ||
|
|
2593b87d3f | ||
|
|
6310262e97 | ||
|
|
38712e90a3 | ||
|
|
c2b2f62462 | ||
|
|
adde04639e | ||
|
|
a4b1f4af24 | ||
|
|
55c714a888 | ||
|
|
3cd631db20 | ||
|
|
d44da076cc | ||
|
|
95e8fc5737 | ||
|
|
50a9e91633 | ||
|
|
cca4c454dd | ||
|
|
17c9c98bbc | ||
|
|
486acad44f | ||
|
|
f73261e68c | ||
|
|
464644def8 | ||
|
|
93b7894a6f | ||
|
|
d53a6f695f | ||
|
|
029ec31ad9 | ||
|
|
045159eb8d | ||
|
|
3415e0ccec | ||
|
|
ab44d97c7c | ||
|
|
139bcf04f1 | ||
|
|
1420183be7 | ||
|
|
31572830e7 | ||
|
|
5c96fc49eb | ||
|
|
7ddb7ca205 | ||
|
|
8cc2d7188a | ||
|
|
4620bde999 | ||
|
|
45b35d88c4 | ||
|
|
200244bce1 | ||
|
|
fe715f203e | ||
|
|
959c3b5f8d | ||
|
|
ef8b97efc2 | ||
|
|
e4d40b460b | ||
|
|
39142780d5 | ||
|
|
143135f1d8 | ||
|
|
c865829a2e | ||
|
|
101855b404 | ||
|
|
37e7a601be | ||
|
|
8791007e77 | ||
|
|
3a2c16b137 | ||
|
|
adc476e848 | ||
|
|
28be8b8146 | ||
|
|
cbaeba2046 | ||
|
|
61de9cb01d | ||
|
|
2e36d59f84 | ||
|
|
3f1444a19f | ||
|
|
86fe2487b5 | ||
|
|
46832ba6b2 | ||
|
|
4671b414b8 | ||
|
|
4efa9df965 | ||
|
|
5c6cf04ed2 | ||
|
|
62f82e389a | ||
|
|
1c7a630e39 | ||
|
|
f2209ce1b0 | ||
|
|
1908c2e8d8 | ||
|
|
0e1774ee84 | ||
|
|
8bf4b1f107 | ||
|
|
86009ff3c2 | ||
|
|
3d634ef824 | ||
|
|
e204bba54f | ||
|
|
0cd5bb0b3f | ||
|
|
2278a91cb9 | ||
|
|
d26efea831 | ||
|
|
bf5ba5f8a6 | ||
|
|
5b40b2ffdb |
@@ -1,2 +1,2 @@
|
||||
added:
|
||||
- Add container (e.g., Docker, Podman) support. [#10 by @daanbosch]
|
||||
- Add Docker/Podman support. [#10 by @daanbosch]
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add option to rebalance by assigned VM resources to avoid overprovisioning. [#16]
|
||||
4
.changelogs/1.0.0/17-add-configurable-log-verbosity.yml
Normal file
4
.changelogs/1.0.0/17-add-configurable-log-verbosity.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
added:
|
||||
- Add feature to make log verbosity configurable [#17].
|
||||
changed:
|
||||
- Adjusted general logging and log more details.
|
||||
2
.changelogs/1.0.0/27_add_container_lxc_support.yml
Normal file
2
.changelogs/1.0.0/27_add_container_lxc_support.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add LXC/Container integration. [#27]
|
||||
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add option_mode to rebalance by node's free resources in percent (instead of bytes). [#29]
|
||||
2
.changelogs/1.0.0/6_add_dry_run_support.yml
Normal file
2
.changelogs/1.0.0/6_add_dry_run_support.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add dry-run support to see what kind of rebalancing would be done. [#6]
|
||||
@@ -1 +1 @@
|
||||
date: TBD
|
||||
date: 2024-08-01
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add option to run ProxLB only on the Proxmox's master node in the cluster (reg. HA feature). [#40]
|
||||
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add option to run migrations in parallel or sequentially. [#41]
|
||||
2
.changelogs/1.0.2/45_fix_daemon_timer.yml
Normal file
2
.changelogs/1.0.2/45_fix_daemon_timer.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
changed:
|
||||
- Fix daemon timer to use hours instead of minutes. [#45]
|
||||
2
.changelogs/1.0.2/49_fix_cmake_debian_packaging.yml
Normal file
2
.changelogs/1.0.2/49_fix_cmake_debian_packaging.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix CMake packaging for Debian package to avoid overwriting the config file. [#49]
|
||||
1
.changelogs/1.0.2/release_meta.yml
Normal file
1
.changelogs/1.0.2/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: 2024-08-13
|
||||
2
.changelogs/1.0.3/51_add_storage_balancing.yml
Normal file
2
.changelogs/1.0.3/51_add_storage_balancing.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add storage balancing function. [#51]
|
||||
6
.changelogs/1.0.3/53_code_improvements.yml
Normal file
6
.changelogs/1.0.3/53_code_improvements.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
added:
|
||||
- Add a convert function to cast all bool alike options from configparser to bools. [#53]
|
||||
- Add a config parser options for future features. [#53]
|
||||
- Add a config versio schema that must be supported by ProxLB. [#53]
|
||||
changed:
|
||||
- Improve the underlying code base for future implementations. [#53]
|
||||
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add feature to allow the API hosts being provided as a comma separated list. [#60]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Improved the overall validation and error handling. [#64]
|
||||
2
.changelogs/1.0.3/67_fix_anti_affinity_rules.yml
Normal file
2
.changelogs/1.0.3/67_fix_anti_affinity_rules.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix anti-affinity rules not evaluating a new and different node. [#67]
|
||||
2
.changelogs/1.0.3/68_adjust_logging_ha_services.yml
Normal file
2
.changelogs/1.0.3/68_adjust_logging_ha_services.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
changed:
|
||||
- Provide a more reasonable output when HA services are not active in a Proxmox cluster. [#68]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix handling of unset `ignore_nodes` and `ignore_vms` resulted in an attribute error. [#71]
|
||||
2
.changelogs/1.0.3/74_fix_documentation_master_only.yml
Normal file
2
.changelogs/1.0.3/74_fix_documentation_master_only.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix documentation for the master_only parameter placed in the wrong config section. [#74]
|
||||
2
.changelogs/1.0.3/8_add_best_next_node_for_placement.yml
Normal file
2
.changelogs/1.0.3/8_add_best_next_node_for_placement.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add cli arg `-b` to return the next best node for next VM/CT placement. [#8]
|
||||
2
.changelogs/1.0.3/bug_fix_cluster_master_only.yml
Normal file
2
.changelogs/1.0.3/bug_fix_cluster_master_only.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fixed `master_only` function by inverting the condition.
|
||||
@@ -0,0 +1,4 @@
|
||||
fixed:
|
||||
- Fix bug in the `proxlb.conf` in the vm_balancing section.
|
||||
added:
|
||||
- Add doc how to add dedicated user for authentication. (by @Dulux-Oz)
|
||||
1
.changelogs/1.0.3/release_meta.yml
Normal file
1
.changelogs/1.0.3/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: 2024-09-12
|
||||
2
.changelogs/1.0.4/58_add_maintenance_mode.yml
Normal file
2
.changelogs/1.0.4/58_add_maintenance_mode.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add maintenance mode to evacuate a node and move workloads for other nodes in the cluster. [#58]
|
||||
2
.changelogs/1.0.4/75_fix_cpu_balancing.yml
Normal file
2
.changelogs/1.0.4/75_fix_cpu_balancing.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix CPU balancing where calculations are done in float instead of int. (by @glitchvern) [#75]
|
||||
3
.changelogs/1.0.4/79_storage_balancing_whitelist.yml
Normal file
3
.changelogs/1.0.4/79_storage_balancing_whitelist.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
changed:
|
||||
- Run storage balancing only on supported shared storages. [#79]
|
||||
- Run storage balancing only when needed to save time. [#79]
|
||||
2
.changelogs/1.0.4/81_documentation_infrastrucutre.yml
Normal file
2
.changelogs/1.0.4/81_documentation_infrastrucutre.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix documentation for the underlying infrastructure. [#81]
|
||||
2
.changelogs/1.0.4/89_add_version_output.yml
Normal file
2
.changelogs/1.0.4/89_add_version_output.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add version output cli arg. [#89]
|
||||
2
.changelogs/1.0.4/91_make_api_timeout_configureable.yml
Normal file
2
.changelogs/1.0.4/91_make_api_timeout_configureable.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Add feature to make API timeout configureable. [#91]
|
||||
1
.changelogs/1.0.4/release_meta.yml
Normal file
1
.changelogs/1.0.4/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: 2024-10-11
|
||||
2
.changelogs/1.0.5/104_docs_bool_adjustment.yml
Normal file
2
.changelogs/1.0.5/104_docs_bool_adjustment.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
changed:
|
||||
- Change docs to make bool usage in configs more clear (by @gyptazy). [#104]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix evaluation of maintenance mode where comparing list & string resulted in a crash (by @glitchvern). [#106]
|
||||
2
.changelogs/1.0.5/107_fix_offline_node_eval.yml
Normal file
2
.changelogs/1.0.5/107_fix_offline_node_eval.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix node (and its objects) evaluation when not reachable, e.g., maintenance (by @gyptazy). [#107]
|
||||
2
.changelogs/1.0.5/113_fix_migration_from_local_disk.yml
Normal file
2
.changelogs/1.0.5/113_fix_migration_from_local_disk.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix migration from local disks (by @greenlogles). [#113]
|
||||
2
.changelogs/1.0.5/98_fix_log_verbosity_opts.yml
Normal file
2
.changelogs/1.0.5/98_fix_log_verbosity_opts.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix allowed values (add DEBUG, WARNING) for log verbosity (by @gyptazy). [#98]
|
||||
1
.changelogs/1.0.5/release_meta.yml
Normal file
1
.changelogs/1.0.5/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: 2024-10-30
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix that a scheduler time definition of 1 (int) gets wrongly interpreted as a bool (by @gyptazy). [#115]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix maintenance mode when using cli arg and config mode by using the merged list (by @CartCaved). [#119]
|
||||
1
.changelogs/1.0.6/release_meta.yml
Normal file
1
.changelogs/1.0.6/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: 2024-12-24
|
||||
11
.changelogs/1.1.0/114_refactor_code_base.yml
Normal file
11
.changelogs/1.1.0/114_refactor_code_base.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
fixed:
|
||||
- Refactored code base for ProxLB [#114]
|
||||
- Switched to `pycodestyle` for linting [#114]
|
||||
- Package building will be done within GitHub actions pipeline [#114]
|
||||
- ProxLB now only returns a warning when no guests for further balancing are not present (instead of quitting) [132#]
|
||||
- All nodes (according to the free resources) will be used now [#130]
|
||||
- Fixed logging outputs where highest/lowest were mixed-up [#129]
|
||||
- Stop balancing when movement would get worste (new force param to enfoce for affinity rules) [#128]
|
||||
- Added requested documentation regarding Proxmox HA groups [#127]
|
||||
- Rewrite of the whole affinity/anti-affinity rules evaluation and placement [#123]
|
||||
- Fixed the `ignore` parameter for nodes where the node and guests on the node will be untouched [#102]
|
||||
@@ -0,0 +1,2 @@
|
||||
feature:
|
||||
- Add Proxmox API authentication support. [#125]
|
||||
2
.changelogs/1.1.0/137_fix_systemd_unit_file.yml
Normal file
2
.changelogs/1.1.0/137_fix_systemd_unit_file.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix the systemd unit file to start ProxLB after pveproxy (by @robertdahlem). [#137]
|
||||
1
.changelogs/1.1.0/release_meta.yml
Normal file
1
.changelogs/1.1.0/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: 2025-04-01
|
||||
2
.changelogs/1.1.1/163_fix_ignore_vm_tag.yml
Normal file
2
.changelogs/1.1.1/163_fix_ignore_vm_tag.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix tag evluation for VMs for being ignored for further balancing [#163]
|
||||
2
.changelogs/1.1.1/165_improve_logging_servity.yml
Normal file
2
.changelogs/1.1.1/165_improve_logging_servity.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Improve logging verbosity of messages that had a wrong servity [#165]
|
||||
2
.changelogs/1.1.1/168_add_more_flexible_schedules.yml
Normal file
2
.changelogs/1.1.1/168_add_more_flexible_schedules.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
feature:
|
||||
- Add a more flexible way to define schedules in minutes or hours (by @gyptazy) [#168]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix Python path for Docker entrypoint (by @crandler) [#170]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Honor the value when balancing should not be performed and stop balancing [#174]
|
||||
@@ -0,0 +1,2 @@
|
||||
changed:
|
||||
- Change the default behaviour of the daemon mode to active [#176]
|
||||
@@ -0,0 +1,2 @@
|
||||
changed:
|
||||
- Change the default banalcing mode to used instead of assigned [#180]
|
||||
@@ -0,0 +1,2 @@
|
||||
feature:
|
||||
- Add validation for the minimum required permissions of a user in Proxmox [#184]
|
||||
@@ -0,0 +1,2 @@
|
||||
fix:
|
||||
- add handler to log messages with severity less than info to the screen when there is no systemd integration, for instance, inside a docker container (by @glitchvern) [#185]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- allow the use of minutes instead of hours and only accept hours or minutes in the format (by @glitchvern) [#187]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Set cpu_used to the cpu usage, which is a percent, times the total number of cores to get a number where guest cpu_used can be added to nodes cpu_used and be meaningful (by @glitchvern) [#195]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Remove hard coded memory usage from lowest usage node and use method and mode specified in configuration instead (by @glitchvern) [#197]
|
||||
2
.changelogs/1.1.1/200_requery_zero_guest_cpu_used.yml
Normal file
2
.changelogs/1.1.1/200_requery_zero_guest_cpu_used.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Requery a guest if that running guest reports 0 cpu usage (by @glitchvern) [#200]
|
||||
@@ -0,0 +1,2 @@
|
||||
fixed:
|
||||
- Fix the guest type relationship in the logs when a migration job failed (by @gyptazy) [#204]
|
||||
@@ -0,0 +1,2 @@
|
||||
added:
|
||||
- Providing the API upstream error message when migration fails in debug mode (by @gyptazy) [#205]
|
||||
1
.changelogs/1.1.1/release_meta.yml
Normal file
1
.changelogs/1.1.1/release_meta.yml
Normal file
@@ -0,0 +1 @@
|
||||
date: TBD
|
||||
3
.flake8
3
.flake8
@@ -1,3 +0,0 @@
|
||||
[flake8]
|
||||
per-file-ignores =
|
||||
proxlb: E501,E221,E266,E231,E127,E222,E128
|
||||
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a bug report
|
||||
title: "`Bug`:"
|
||||
labels: bug, needs-analysis
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## General
|
||||
<-- Describe the bug from a high level perspective. -->
|
||||
|
||||
## Weighting
|
||||
Score: <-- Define a scoring from 0-10 (10 highest, most urgent) -->
|
||||
|
||||
## Config
|
||||
<-- Attach the ProxLB configuration for further analysis. Please take car to NOT publish your API credentials! -->
|
||||
|
||||
## Log
|
||||
<-- Attach the ProxLB debug log for further analysis. Please take car to NOT publish your API credentials! -->
|
||||
|
||||
## Meta
|
||||
Please provide some more information about your setup. This includes where you obtained ProxLB (e.g., as a `.deb` file, from the repository or container image) and also which version you're running in which mode. You can obtain the used version from you image version, your local repository information or by running `proxlb -v`.
|
||||
|
||||
Version: <-- DEFINE_VERSION -->
|
||||
Installed from: <-- DEFINE_INSTALL_SOURCE -->
|
||||
Running as: <-- Container, local on Proxmox, local on all Proxmox, dedicated -->
|
||||
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Create a new request for a missing feature
|
||||
title: "`Feature`: "
|
||||
labels: feature, needs-analysis
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## General
|
||||
<-- Describe the feature idea from a high level perspective. -->
|
||||
|
||||
## Details
|
||||
<-- Provide some more details about the new feature request and provide examples. -->
|
||||
26
.github/workflows/02-create-package.yml
vendored
26
.github/workflows/02-create-package.yml
vendored
@@ -1,26 +0,0 @@
|
||||
name: Run basic pipeline on push
|
||||
on: [push]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.8"]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python for ProxLB
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies for ProxLB
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pytest proxmoxer flake8
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
- name: Run Python linting
|
||||
run: |
|
||||
python3 -m flake8 proxlb
|
||||
- name: Create distro packages
|
||||
run: |
|
||||
cd packaging
|
||||
./01_package.sh
|
||||
21
.github/workflows/10-code-liniting.yml
vendored
Normal file
21
.github/workflows/10-code-liniting.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Code linting
|
||||
on: [push]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.8"]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dependencies for code linting
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install additional dependencies for code linting
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install python3-pycodestyle pycodestyle
|
||||
- name: Run code linting on ProxLB Python code
|
||||
run: |
|
||||
pycodestyle proxlb/*
|
||||
78
.github/workflows/20-pipeline-build-deb-package.yml
vendored
Normal file
78
.github/workflows/20-pipeline-build-deb-package.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
name: "Build package: .deb"
|
||||
on: [push]
|
||||
jobs:
|
||||
lint-code-proxlb:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.8"]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dependencies for code linting
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install additional dependencies for code linting
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install python3-pycodestyle pycodestyle
|
||||
- name: Run code linting on ProxLB Python code
|
||||
run: |
|
||||
pycodestyle proxlb/* && \
|
||||
echo "OK: Code linting successfully performed on ProxLB code."
|
||||
|
||||
build-package-debian:
|
||||
needs: lint-code-proxlb
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- name: Set up Docker with Debian image
|
||||
run: |
|
||||
docker pull debian:latest
|
||||
|
||||
- name: Build DEB package in Docker container
|
||||
run: |
|
||||
docker run --rm -v $(pwd):/workspace -w /workspace debian:latest bash -c "
|
||||
# Install dependencies
|
||||
apt-get update && \
|
||||
apt-get install -y python3 python3-setuptools debhelper dh-python python3-pip python3-stdeb python3-proxmoxer python3-requests python3-urllib3 devscripts python3-all && \
|
||||
# Build package using stdeb / setuptools
|
||||
# python3 setup.py --command-packages=stdeb.command bdist_deb && \
|
||||
# Build native package
|
||||
dpkg-buildpackage -us -uc && \
|
||||
mkdir package && \
|
||||
mv ../*.deb package/ && \
|
||||
echo 'OK: Debian package successfully created.'
|
||||
"
|
||||
|
||||
- name: Upload Debian package python3-proxlb as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: debian-package
|
||||
path: package/*.deb
|
||||
|
||||
integration-test-debian:
|
||||
needs: build-package-debian
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Debian package artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: debian-package
|
||||
path: package/
|
||||
|
||||
- name: Set up Docker with Debian image
|
||||
run: docker pull debian:latest
|
||||
|
||||
- name: Install and test Debian package in Docker container
|
||||
run: |
|
||||
docker run --rm -v $(pwd)/package:/package -w /package debian:latest bash -c "
|
||||
apt-get update && \
|
||||
apt-get install -y systemd && \
|
||||
apt-get install -y ./proxlb*.deb && \
|
||||
python3 -c 'import proxlb; print(\"OK: Debian package successfully installed.\")'
|
||||
"
|
||||
96
.github/workflows/20-pipeline-build-rpm-package.yml
vendored
Normal file
96
.github/workflows/20-pipeline-build-rpm-package.yml
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
name: "Build package: .rpm"
|
||||
on: [push]
|
||||
jobs:
|
||||
lint-code-proxlb:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.8"]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup dependencies for code linting
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install additional dependencies for code linting
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install python3-pycodestyle pycodestyle
|
||||
- name: Run code linting on ProxLB Python code
|
||||
run: |
|
||||
pycodestyle proxlb/* && \
|
||||
echo "OK: Code linting successfully performed on ProxLB code."
|
||||
|
||||
build-package-rpm:
|
||||
needs: lint-code-proxlb
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: 'development'
|
||||
|
||||
- name: Set up Docker with Debian image
|
||||
run: |
|
||||
docker pull debian:latest
|
||||
|
||||
- name: Build DEB package in Docker container
|
||||
run: |
|
||||
docker run --rm -v $(pwd):/workspace -w /workspace debian:latest bash -c "
|
||||
# Install dependencies
|
||||
apt-get update && \
|
||||
apt-get install -y python3 python3-setuptools rpm debhelper dh-python python3-pip python3-stdeb python3-proxmoxer python3-requests python3-urllib3 && \
|
||||
# Build package
|
||||
python3 setup.py --command-packages=stdeb.command bdist_rpm && \
|
||||
echo 'OK: RPM package successfully created.'
|
||||
"
|
||||
|
||||
- name: Upload RPM package python3-proxlb as artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rpm-package
|
||||
path: dist/*.rpm
|
||||
|
||||
# integration-test-rpm-rockylinux-9:
|
||||
# needs: build-package-rpm
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Download RPM package artifact
|
||||
# uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: rpm-package
|
||||
# path: dist/
|
||||
|
||||
# - name: Set up Docker with RockyLinux 9 image
|
||||
# run: docker pull rockylinux:9
|
||||
|
||||
# - name: Install and test RPM package in Rocky Linux Docker container
|
||||
# run: |
|
||||
# docker run --rm -v $(pwd)/dist:/dist -w /dist rockylinux:9 bash -c "
|
||||
# # DNF does not handle wildcards well
|
||||
# rpm_file=\$(ls proxlb*.noarch.rpm) && \
|
||||
# dnf install -y \$rpm_file && \
|
||||
# python3 -c 'import proxlb; print(\"OK: RPM package successfully installed.\")'
|
||||
# "
|
||||
|
||||
# integration-test-rpm-rockylinux-8:
|
||||
# needs: build-package-rpm
|
||||
# runs-on: ubuntu-latest
|
||||
# steps:
|
||||
# - name: Download RPM package artifact
|
||||
# uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: rpm-package
|
||||
# path: dist/
|
||||
|
||||
# - name: Set up Docker with RockyLinux 8 image
|
||||
# run: docker pull rockylinux:8
|
||||
|
||||
# - name: Install and test RPM package in Rocky Linux Docker container
|
||||
# run: |
|
||||
# docker run --rm -v $(pwd)/dist:/dist -w /dist rockylinux:8 bash -c "
|
||||
# # DNF does not handle wildcards well
|
||||
# rpm_file=\$(ls proxlb*.noarch.rpm) && \
|
||||
# dnf install -y \$rpm_file && \
|
||||
# python3 -c 'import proxlb; print(\"OK: RPM package successfully installed.\")'
|
||||
# "
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,2 +1,7 @@
|
||||
packaging/changelog-fragments-creator/
|
||||
dev/
|
||||
__pycache__
|
||||
*.pyc
|
||||
.DS_Store
|
||||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
proxlb_dev.yaml
|
||||
|
||||
120
CHANGELOG.md
120
CHANGELOG.md
@@ -6,6 +6,126 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [1.1.0] - 2025-04-01
|
||||
|
||||
### Fixed
|
||||
|
||||
- Refactored code base for ProxLB [#114]
|
||||
- Switched to `pycodestyle` for linting [#114]
|
||||
- Package building will be done within GitHub actions pipeline [#114]
|
||||
- ProxLB now only returns a warning when no guests for further balancing are not present (instead of quitting) [132#]
|
||||
- All nodes (according to the free resources) will be used now [#130]
|
||||
- Fixed logging outputs where highest/lowest were mixed-up [#129]
|
||||
- Stop balancing when movement would get worste (new force param to enfoce for affinity rules) [#128]
|
||||
- Added requested documentation regarding Proxmox HA groups [#127]
|
||||
- Rewrite of the whole affinity/anti-affinity rules evaluation and placement [#123]
|
||||
- Fixed the `ignore` parameter for nodes where the node and guests on the node will be untouched [#102]
|
||||
|
||||
|
||||
## [1.0.6] - 2024-12-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix maintenance mode when using cli arg and config mode by using the merged list (by @CartCaved). [#119]
|
||||
- Fix that a scheduler time definition of 1 (int) gets wrongly interpreted as a bool (by @gyptazy). [#115]
|
||||
|
||||
|
||||
## [1.0.5] - 2024-10-30
|
||||
|
||||
### Changed
|
||||
|
||||
- Change docs to make bool usage in configs more clear (by @gyptazy). [#104]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix node (and its objects) evaluation when not reachable, e.g., maintenance (by @gyptazy). [#107]
|
||||
- Fix migration from local disks (by @greenlogles). [#113]
|
||||
- Fix evaluation of maintenance mode where comparing list & string resulted in a crash (by @glitchvern). [#106]
|
||||
- Fix allowed values (add DEBUG, WARNING) for log verbosity (by @gyptazy). [#98]
|
||||
|
||||
|
||||
## [1.0.4] - 2024-10-11
|
||||
|
||||
### Added
|
||||
|
||||
- Add maintenance mode to evacuate a node and move workloads for other nodes in the cluster. [#58]
|
||||
- Add feature to make API timeout configureable. [#91]
|
||||
- Add version output cli arg. [#89]
|
||||
|
||||
### Changed
|
||||
|
||||
- Run storage balancing only on supported shared storages. [#79]
|
||||
- Run storage balancing only when needed to save time. [#79]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix CPU balancing where calculations are done in float instead of int. (by @glitchvern) [#75]
|
||||
- Fix documentation for the underlying infrastructure. [#81]
|
||||
|
||||
|
||||
## [1.0.3] - 2024-09-12
|
||||
|
||||
### Added
|
||||
|
||||
- Add cli arg `-b` to return the next best node for next VM/CT placement. [#8]
|
||||
- Add a convert function to cast all bool alike options from configparser to bools. [#53]
|
||||
- Add a config parser options for future features. [#53]
|
||||
- Add a config versio schema that must be supported by ProxLB. [#53]
|
||||
- Add feature to allow the API hosts being provided as a comma separated list. [#60]
|
||||
- Add doc how to add dedicated user for authentication. (by @Dulux-Oz)
|
||||
- Add storage balancing function. [#51]
|
||||
|
||||
### Changed
|
||||
|
||||
- Provide a more reasonable output when HA services are not active in a Proxmox cluster. [#68]
|
||||
- Improve the underlying code base for future implementations. [#53]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix anti-affinity rules not evaluating a new and different node. [#67]
|
||||
- Fixed `master_only` function by inverting the condition.
|
||||
- Fix documentation for the master_only parameter placed in the wrong config section. [#74]
|
||||
- Fix bug in the `proxlb.conf` in the vm_balancing section.
|
||||
- Fix handling of unset `ignore_nodes` and `ignore_vms` resulted in an attribute error. [#71]
|
||||
- Improved the overall validation and error handling. [#64]
|
||||
|
||||
|
||||
## [1.0.2] - 2024-08-13
|
||||
|
||||
### Added
|
||||
|
||||
- Add option to run ProxLB only on the Proxmox's master node in the cluster (reg. HA feature). [#40]
|
||||
- Add option to run migrations in parallel or sequentially. [#41]
|
||||
|
||||
### Changed
|
||||
|
||||
- Fix daemon timer to use hours instead of minutes. [#45]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix CMake packaging for Debian package to avoid overwriting the config file. [#49]
|
||||
|
||||
|
||||
## [1.0.0] - 2024-08-01
|
||||
|
||||
### Added
|
||||
|
||||
- Add feature to prevent VMs from being relocated by defining the 'plb_ignore_vm' tag. [#7]
|
||||
- Add feature to prevent VMs from being relocated by defining a wildcard pattern. [#7]
|
||||
- Add Docker/Podman support. [#10 by @daanbosch]
|
||||
- Add option to rebalance by assigned VM resources to avoid overprovisioning. [#16]
|
||||
- Add feature to make log verbosity configurable [#17].
|
||||
- Add dry-run support to see what kind of rebalancing would be done. [#6]
|
||||
- Add LXC/Container integration. [#27]
|
||||
- Add exclude grouping feature to rebalance VMs from being located together to new nodes. [#4]
|
||||
- Add include grouping feature to rebalance VMs bundled to new nodes. [#3]
|
||||
- Add option_mode to rebalance by node's free resources in percent (instead of bytes). [#29]
|
||||
|
||||
### Changed
|
||||
|
||||
- Adjusted general logging and log more details.
|
||||
|
||||
|
||||
## [0.9.9] - 2024-07-06
|
||||
|
||||
### Added
|
||||
|
||||
121
CONTRIBUTING.md
Normal file
121
CONTRIBUTING.md
Normal file
@@ -0,0 +1,121 @@
|
||||
# Contributing to ProxLB (PLB)
|
||||
|
||||
Thank you for considering contributing to ProxLB! We appreciate your help in improving the efficiency and performance of Proxmox clusters. Below are guidelines for contributing to the project.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Contributing to ProxLB (PLB)](#contributing-to-proxlb-plb)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Creating an Issue](#creating-an-issue)
|
||||
- [Running Linting](#running-linting)
|
||||
- [Running Tests](#running-tests)
|
||||
- [Add Changelogs](#add-changelogs)
|
||||
- [Submitting a Pull Request](#submitting-a-pull-request)
|
||||
- [Code of Conduct](#code-of-conduct)
|
||||
- [Getting Help](#getting-help)
|
||||
|
||||
## Creating an Issue
|
||||
|
||||
If you encounter a bug, have a feature request, or have any suggestions, please create an issue in our GitHub repository. To create an issue:
|
||||
|
||||
1. **Go to the [Issues](https://github.com/gyptazy/proxlb/issues) section of the repository.**
|
||||
2. **Click on the "New issue" button.**
|
||||
3. **Select the appropriate issue template (Bug Report, Feature Request, or Custom Issue).**
|
||||
4. **Provide a clear and descriptive title.**
|
||||
5. **Fill out the necessary details in the issue template.** Provide as much detail as possible to help us understand and reproduce the issue or evaluate the feature request.
|
||||
|
||||
## Running Linting
|
||||
Before submitting a pull request, ensure that your changes sucessfully perform the lintin. ProxLB uses [flake8] for running tests. Follow these steps to run tests locally:
|
||||
|
||||
1. **Install pytest if you haven't already:**
|
||||
```sh
|
||||
pip install flake8
|
||||
```
|
||||
|
||||
2. **Run the lintin:**
|
||||
```sh
|
||||
python3 -m flake8 proxlb
|
||||
```
|
||||
|
||||
Linting will also be performed for each PR. Therefore, it might make sense to test this before pushing locally.
|
||||
|
||||
## Running Tests
|
||||
|
||||
Before submitting a pull request, ensure that your changes do not break existing functionality. ProxLB uses [pytest](https://docs.pytest.org/en/stable/) for running tests. Follow these steps to run tests locally:
|
||||
|
||||
1. **Install pytest if you haven't already:**
|
||||
```sh
|
||||
pip install pytest
|
||||
```
|
||||
|
||||
2. **Run the tests:**
|
||||
```sh
|
||||
pytest
|
||||
```
|
||||
|
||||
Ensure all tests pass before submitting your changes.
|
||||
|
||||
## Add Changelogs
|
||||
ProxLB uses the [Changelog Fragments Creator](https://github.com/gyptazy/changelog-fragments-creator) for creating the overall `CHANGELOG.md` file. This changelog file is being generated from the files placed in the https://github.com/gyptazy/ProxLB/tree/main/.changelogs/ directory. Each release is represented by its version number where additional yaml files are being placed and parsed by the CFC tool. Such files look like:
|
||||
|
||||
```
|
||||
added:
|
||||
- Add option to rebalance by assigned VM resources to avoid overprovisioning. [#16]
|
||||
```
|
||||
|
||||
Every PR should contain such a file describing the change to ensure this is also stated in the changelog file.
|
||||
|
||||
## Submitting a Pull Request
|
||||
|
||||
We welcome your contributions! Follow these steps to submit a pull request:
|
||||
|
||||
1. **Fork the repository to your GitHub account.**
|
||||
2. **Clone your forked repository to your local machine:**
|
||||
```sh
|
||||
git clone https://github.com/gyptazy/proxlb.git
|
||||
cd proxlb
|
||||
```
|
||||
|
||||
Please prefix your PR regarding its type. It might be:
|
||||
* doc
|
||||
* feature
|
||||
* fix
|
||||
|
||||
It should also provide the issue id to which it is related.
|
||||
|
||||
1. **Create a new branch for your changes:**
|
||||
```sh
|
||||
git checkout -b feature/10-add-new-cool-stuff
|
||||
```
|
||||
|
||||
2. **Make your changes and commit them with a descriptive commit message:**
|
||||
```sh
|
||||
git add .
|
||||
git commit -m "feature: Adding new cool stuff"
|
||||
```
|
||||
|
||||
3. **Push your changes to your forked repository:**
|
||||
```sh
|
||||
git push origin feature/10-add-new-cool-stuff
|
||||
```
|
||||
|
||||
4. **Create a pull request from your forked repository:**
|
||||
- Go to the original repository on GitHub.
|
||||
- Click on the "New pull request" button.
|
||||
- Select the branch you pushed your changes to and create the pull request.
|
||||
|
||||
Please ensure that your pull request:
|
||||
|
||||
- Follows the project's coding style and guidelines.
|
||||
- Includes tests for any new functionality.
|
||||
- Updates the documentation as necessary.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md). Please read it to understand the expected behavior and responsibilities when interacting with the community.
|
||||
|
||||
## Getting Help
|
||||
|
||||
If you need help or have any questions, feel free to reach out by creating an issue or by joining our [discussion forum](https://github.com/gyptazy/proxlb/discussions). You can also refer to our [documentation](https://github.com/gyptazy/ProxLB/tree/main/docs) for more information about the project or join our [chat room](https://matrix.to/#/#proxlb:gyptazy.com) in Matrix.
|
||||
|
||||
Thank you for contributing to ProxLB! Together, we can enhance the efficiency and performance of Proxmox clusters.
|
||||
31
Dockerfile
31
Dockerfile
@@ -1,20 +1,16 @@
|
||||
# Use the official Debian 12 base image
|
||||
FROM debian:12
|
||||
# Use the latest Alpine image
|
||||
FROM alpine:latest
|
||||
|
||||
# Labels
|
||||
LABEL maintainer="gyptazy@gyptazy.ch"
|
||||
LABEL org.label-schema.schema-version="0.9"
|
||||
LABEL org.label-schema.description="ProxLB - Rebalance VM workloads across nodes in a Proxmox cluster."
|
||||
LABEL org.label-schema.url="https://github.com/gyptazy/ProxLB"
|
||||
LABEL maintainer="gyptazy@gyptazy.com"
|
||||
LABEL org.label-schema.name="ProxLB"
|
||||
LABEL org.label-schema.description="ProxLB - An advanced load balancer for Proxmox clusters."
|
||||
LABEL org.label-schema.vendor="gyptazy"
|
||||
LABEL org.label-schema.url="https://proxlb.de"
|
||||
LABEL org.label-schema.vcs-url="https://github.com/gyptazy/ProxLB"
|
||||
|
||||
# Set environment variables
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install python3 and python3-venv
|
||||
RUN apt-get update && \
|
||||
apt-get install -y python3 python3-pip python3-venv && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
# Install Python3
|
||||
RUN apk add --no-cache python3 py3-pip
|
||||
|
||||
# Create a directory for the app
|
||||
WORKDIR /app
|
||||
@@ -22,14 +18,11 @@ WORKDIR /app
|
||||
# Copy the python program from the current directory to /app
|
||||
COPY proxlb /app/proxlb
|
||||
|
||||
# Create a virtual environment
|
||||
RUN python3 -m venv venv
|
||||
|
||||
# Copy requirements to the container
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
|
||||
# Install dependencies in the virtual environment
|
||||
RUN . venv/bin/activate && pip install -r /app/requirements.txt
|
||||
RUN pip install --break-system-packages -r /app/requirements.txt
|
||||
|
||||
# Set the entry point to use the virtual environment's python
|
||||
ENTRYPOINT ["/app/venv/bin/python3", "/app/proxlb"]
|
||||
ENTRYPOINT ["/usr/bin/python3", "/app/proxlb/main.py"]
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
489
README.md
489
README.md
@@ -1,96 +1,304 @@
|
||||
# ProxLB - (Re)Balance VM Workloads in Proxmox Clusters
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/Prox-LB-logo.jpg"/>
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/Prox-LB-logo.jpg"/>
|
||||
<br>
|
||||
|
||||
<p float="center"><img src="https://img.shields.io/github/license/gyptazy/ProxLB"/><img src="https://img.shields.io/github/contributors/gyptazy/ProxLB"/><img src="https://img.shields.io/github/last-commit/gyptazy/ProxLB/main"/><img src="https://img.shields.io/github/issues-raw/gyptazy/ProxLB"/><img src="https://img.shields.io/github/issues-pr/gyptazy/ProxLB"/></p>
|
||||
|
||||
## Table of Contents
|
||||
1. [Introduction](#introduction)
|
||||
2. [Features](#features)
|
||||
3. [How does it work?](#how-does-it-work)
|
||||
4. [Installation](#installation)
|
||||
1. [Requirements / Dependencies](#requirements--dependencies)
|
||||
2. [Debian Package](#debian-package)
|
||||
4. [Container / Docker](#container--docker)
|
||||
5. [Source](#source)
|
||||
5. [Usage / Configuration](#usage--configuration)
|
||||
1. [GUI Integration](#gui-integration)
|
||||
2. [Proxmox HA Integration](#proxmox-ha-integration)
|
||||
3. [Options](#options)
|
||||
6. [Affinity & Anti-Affinity Rules](#affinity--anti-affinity-rules)
|
||||
1. [Affinity Rules](#affinity-rules)
|
||||
2. [Anti-Affinity Rules](#anti-affinity-rules)
|
||||
3. [Ignore VMs](#ignore-vms)
|
||||
7. [Maintenance](#maintenance)
|
||||
8. [Misc](#misc)
|
||||
1. [Bugs](#bugs)
|
||||
2. [Contributing](#contributing)
|
||||
3. [Documentation](#documentation)
|
||||
4. [Support](#support)
|
||||
9. [Author(s)](#authors)
|
||||
|
||||
## Table of Content
|
||||
* Introduction
|
||||
* Video of Migration
|
||||
* Features
|
||||
* Usage
|
||||
* Dependencies
|
||||
* Options
|
||||
* Parameters
|
||||
* Systemd
|
||||
* Manuel
|
||||
* Proxmox GUI Integration
|
||||
* Quick Start
|
||||
* Container Quick Start (Docker/Podman)
|
||||
* Motivation
|
||||
* References
|
||||
* Packages / Container Images
|
||||
* Misc
|
||||
* Bugs
|
||||
* Contributing
|
||||
* Author(s)
|
||||
|
||||
## Introduction
|
||||
`ProxLB` (PLB) is an advanced tool designed to enhance the efficiency and performance of Proxmox clusters by optimizing the distribution of virtual machines (VMs) across the cluster nodes by using the Proxmox API. ProxLB meticulously gathers and analyzes a comprehensive set of resource metrics from both the cluster nodes and the running VMs. These metrics include CPU usage, memory consumption, and disk utilization, specifically focusing on local disk resources.
|
||||
ProxLB is an advanced load balancing solution specifically designed for Proxmox clusters, addressing the absence of a Dynamic Resource Scheduler (DRS) that is familiar to VMware users. As a third-party solution, ProxLB enhances the management and efficiency of Proxmox clusters by intelligently distributing workloads across available nodes. Workloads can be balanced by different times like the guest's memory, CPU or disk usage or their assignment to avoid overprovisioning and ensuring resources.
|
||||
|
||||
PLB collects resource usage data from each node in the Proxmox cluster, including CPU, (local) disk and memory utilization. Additionally, it gathers resource usage statistics from all running VMs, ensuring a granular understanding of the cluster's workload distribution.
|
||||
One of the key advantages of ProxLB is that it is fully open-source and free, making it accessible for anyone to use, modify, and contribute to. This ensures transparency and fosters community-driven improvements. ProxLB supports filtering and ignoring specific nodes and guests through configuration files and API calls, providing administrators with the flexibility to tailor the load balancing behavior to their specific needs.
|
||||
|
||||
Intelligent rebalancing is a key feature of ProxLB where it re-balances VMs based on their memory, disk or cpu usage, ensuring that no node is overburdened while others remain underutilized. The rebalancing capabilities of PLB significantly enhance cluster performance and reliability. By ensuring that resources are evenly distributed, PLB helps prevent any single node from becoming a performance bottleneck, improving the reliability and stability of the cluster. Efficient rebalancing leads to better utilization of available resources, potentially reducing the need for additional hardware investments and lowering operational costs.
|
||||
A standout feature of ProxLB is its maintenance mode. When enabled, all guest workloads are automatically moved to other nodes within the cluster, ensuring that a node can be safely updated, rebooted, or undergo hardware maintenance without disrupting the overall cluster operation. Additionally, ProxLB supports both affinity and anti-affinity rules, allowing operators to group multiple guests to run together on the same node or ensure that certain guests do not run on the same node, depending on the cluster's node count. This feature is crucial for optimizing performance and maintaining high availability.
|
||||
|
||||
Automated rebalancing reduces the need for manual actions, allowing operators to focus on other critical tasks, thereby increasing operational efficiency.
|
||||
ProxLB can also return the best next node for guest placement, which can be integrated into CI/CD pipelines using tools like Ansible or Terraform. This capability streamlines the deployment process and ensures efficient resource utilization. Furthermore, ProxLB leverages the Proxmox API, including the entire ACL (Access Control List) system, for secure and efficient operation. Unlike some solutions, it does not require SSH access, enhancing security and simplifying configuration.
|
||||
|
||||
Overall, ProxLB significantly enhances resource management by intelligently distributing workloads, reducing downtime through its maintenance mode, and providing improved flexibility with affinity and anti-affinity rules. Its seamless integration with CI/CD tools and reliance on the Proxmox API make it a robust and secure solution for optimizing Proxmox cluster performance.
|
||||
|
||||
### Video of Migration
|
||||
<img src="https://cdn.gyptazy.ch/images/proxlb-rebalancing-demo.gif"/>
|
||||
<img src="https://cdn.gyptazy.com/images/proxlb-rebalancing-demo.gif"/>
|
||||
|
||||
## Features
|
||||
* Rebalance the cluster by:
|
||||
ProxLB's key features are by enabling automatic rebalancing of VMs and CTs across a Proxmox cluster based on memory, CPU, and local disk usage while identifying optimal nodes for automation. It supports maintenance mode, affinity rules, and seamless Proxmox API integration with ACL support, offering flexible usage as a one-time operation, a daemon, or through the Proxmox Web GUI.
|
||||
|
||||
**Features**
|
||||
* Rebalance VMs/CTs in the cluster by:
|
||||
* Memory
|
||||
* Disk (only local storage)
|
||||
* CPU
|
||||
* Performing
|
||||
* Periodically
|
||||
* One-shot solution
|
||||
* Filter
|
||||
* Exclude nodes
|
||||
* Exclude virtual machines
|
||||
* Migrate VM workloads away (e.g. maintenance preparation)
|
||||
* Get best nodes for further automation
|
||||
* Supported Guest Types
|
||||
* VMs
|
||||
* CTs
|
||||
* Maintenance Mode
|
||||
* Set node(s) into maintenance
|
||||
* Move all workloads to different nodes
|
||||
* Affinity / Anti-Affinity Rules
|
||||
* Fully based on Proxmox API
|
||||
* Fully integrated into the Proxmox ACL
|
||||
* No SSH required
|
||||
* Usage
|
||||
* One-Shot (one-shot)
|
||||
* Periodically (daemon)
|
||||
* Proxmox Web GUI Integration (optional)
|
||||
* One-Time
|
||||
* Daemon
|
||||
* Proxmox Web GUI Integration
|
||||
|
||||
## Usage
|
||||
Running PLB is easy and it runs almost everywhere since it just depends on `Python3` and the `proxmoxer` library. Therefore, it can directly run on a Proxmox node, dedicated systems like Debian, RedHat, or even FreeBSD, as long as the API is reachable by the client running PLB.
|
||||
## How does it work?
|
||||
ProxLB is a load-balancing system designed to optimize the distribution of virtual machines (VMs) and containers (CTs) across a cluster. It works by first gathering resource usage metrics from all nodes in the cluster through the Proxmox API. This includes detailed resource metrics for each VM and CT on every node. ProxLB then evaluates the difference between the maximum and minimum resource usage of the nodes, referred to as "Balanciness." If this difference exceeds a predefined threshold (which is configurable), the system initiates the rebalancing process.
|
||||
|
||||
### Dependencies
|
||||
* Python3
|
||||
* proxmoxer (Python module)
|
||||
Before starting any migrations, ProxLB validates that rebalancing actions are necessary and beneficial. Depending on the selected balancing mode — such as CPU, memory, or disk — it creates a balancing matrix. This matrix sorts the VMs by their maximum used or assigned resources, identifying the VM with the highest usage. ProxLB then places this VM on the node with the most free resources in the selected balancing type. This process runs recursively until the operator-defined Balanciness is achieved. Balancing can be defined for the used or max. assigned resources of VMs/CTs.
|
||||
|
||||
## Installation
|
||||
|
||||
### Requirements / Dependencies
|
||||
* Python3.x
|
||||
* proxmoxer
|
||||
* requests
|
||||
* urllib3
|
||||
* pyyaml
|
||||
|
||||
The dependencies can simply be installed with `pip` by running the following command:
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
*Note: Distribution packages, such like the provided `.deb` package will automatically resolve and install all required dependencies by using already packaged version from the distribution's repository. By using the Docker (container) image or Debian packages, you do not need to take any care of the requirements listed here.*
|
||||
|
||||
### Debian Package
|
||||
ProxLB is a powerful and flexible load balancer designed to work across various architectures, including `amd64`, `arm64`, `rv64` and many other ones that support Python. It runs independently of the underlying hardware, making it a versatile choice for different environments. This chapter covers the step-by-step process to install ProxLB on Debian-based systems, including Debian clones like Ubuntu.
|
||||
|
||||
#### Quick-Start
|
||||
You can simply use this snippet to install the repository and to install ProxLB on your system.
|
||||
|
||||
```bash
|
||||
echo "deb https://repo.gyptazy.com/stable /" > /etc/apt/sources.list.d/proxlb.list
|
||||
wget -O /etc/apt/trusted.gpg.d/proxlb.asc https://repo.gyptazy.com/repository.gpg
|
||||
apt-get update && apt-get -y install proxlb
|
||||
cp /etc/proxlb/proxlb_example.yaml /etc/proxlb/proxlb.yaml
|
||||
# Adjust the config to your needs
|
||||
vi /etc/proxlb/proxlb.yaml
|
||||
systemctl start proxlb
|
||||
```
|
||||
|
||||
Afterwards, ProxLB is running in the background and balances your cluster by your defined balancing method (default: memory).
|
||||
|
||||
#### Details
|
||||
ProxLB provides two different repositories:
|
||||
* https://repo.gyptazy.com/stable (only stable release)
|
||||
* https://repo.gyptazy.com/testing (bleeding edge - not recommended)
|
||||
|
||||
The repository is signed and the GPG key can be found at:
|
||||
* https://repo.gyptazy.com/repository.gpg
|
||||
|
||||
You can also simply import it by running:
|
||||
|
||||
```
|
||||
# KeyID: 17169F23F9F71A14AD49EDADDB51D3EB01824F4C
|
||||
# UID: gyptazy Solutions Repository <contact@gyptazy.com>
|
||||
# SHA256: 52c267e6f4ec799d40cdbdb29fa518533ac7942dab557fa4c217a76f90d6b0f3 repository.gpg
|
||||
|
||||
wget -O /etc/apt/trusted.gpg.d/proxlb.asc https://repo.gyptazy.com/repository.gpg
|
||||
```
|
||||
|
||||
*Note: The defined repositories `repo.gyptazy.com` and `repo.proxlb.de` are the same!*
|
||||
|
||||
#### Debian Packages (.deb files)
|
||||
If you do not want to use the repository you can also find the debian packages as a .deb file on gyptazy's CDN at:
|
||||
* https://cdn.gyptazy.com/files/os/debian/proxlb/
|
||||
|
||||
Afterwards, you can simply install the package by running:
|
||||
```bash
|
||||
dpkg -i proxlb_*.deb
|
||||
cp /etc/proxlb/proxlb_example.yaml /etc/proxlb/proxlb.yaml
|
||||
# Adjust the config to your needs
|
||||
vi /etc/proxlb/proxlb.yaml
|
||||
systemctl start proxlb
|
||||
```
|
||||
|
||||
### Container Images / Docker
|
||||
Using the ProxLB container images is straight forward and only requires you to mount the config file.
|
||||
|
||||
```bash
|
||||
# Pull the image
|
||||
docker pull cr.gyptazy.com/proxlb/proxlb:latest
|
||||
# Download the config
|
||||
wget -O proxlb.yaml https://raw.githubusercontent.com/gyptazy/ProxLB/refs/heads/main/config/proxlb_example.yaml
|
||||
# Adjust the config to your needs
|
||||
vi proxlb.yaml
|
||||
# Start the ProxLB container image with the ProxLB config
|
||||
docker run -it --rm -v $(pwd)/proxlb.yaml:/etc/proxlb/proxlb.yaml proxlb
|
||||
```
|
||||
|
||||
*Note: ProxLB container images are officially only available at cr.proxlb.de and cr.gyptazy.com.*
|
||||
|
||||
#### Overview of Images
|
||||
| Version | Image |
|
||||
|------|:------:|
|
||||
| latest | cr.gyptazy.com/proxlb/proxlb:latest |
|
||||
| v1.1.0 | cr.gyptazy.com/proxlb/proxlb:v1.1.0 |
|
||||
| v1.0.6 | cr.gyptazy.com/proxlb/proxlb:v1.0.6 |
|
||||
| v1.0.5 | cr.gyptazy.com/proxlb/proxlb:v1.0.5 |
|
||||
| v1.0.4 | cr.gyptazy.com/proxlb/proxlb:v1.0.4 |
|
||||
| v1.0.3 | cr.gyptazy.com/proxlb/proxlb:v1.0.3 |
|
||||
| v1.0.2 | cr.gyptazy.com/proxlb/proxlb:v1.0.2 |
|
||||
| v1.0.0 | cr.gyptazy.com/proxlb/proxlb:v1.0.0 |
|
||||
| v0.9.9 | cr.gyptazy.com/proxlb/proxlb:v0.9.9 |
|
||||
|
||||
### Source
|
||||
ProxLB can also easily be used from the provided sources - for traditional systems but also as a Docker/Podman container image.
|
||||
|
||||
#### Traditional System
|
||||
Setting up and running ProxLB from the sources is simple and requires just a few commands. Ensure Python 3 and the Python dependencies are installed on your system, then run ProxLB using the following command:
|
||||
```bash
|
||||
git clone https://github.com/gyptazy/ProxLB.git
|
||||
cd ProxLB
|
||||
```
|
||||
|
||||
Afterwards simply adjust the config file to your needs:
|
||||
```bash
|
||||
vi config/proxlb.yaml
|
||||
```
|
||||
|
||||
Start ProxLB by Python3 on the system:
|
||||
```bash
|
||||
python3 proxlb/main.py -c config/proxlb.yaml
|
||||
```
|
||||
|
||||
#### Container Image
|
||||
Creating a container image of ProxLB is straightforward using the provided Dockerfile. The Dockerfile simplifies the process by automating the setup and configuration required to get ProxLB running in an Alpine container. Simply follow the steps in the Dockerfile to build the image, ensuring all dependencies and configurations are correctly applied. For those looking for an even quicker setup, a ready-to-use ProxLB container image is also available, eliminating the need for manual building and allowing for immediate deployment.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/gyptazy/ProxLB.git
|
||||
cd ProxLB
|
||||
docker build -t proxlb .
|
||||
```
|
||||
|
||||
Afterwards simply adjust the config file to your needs:
|
||||
```bash
|
||||
vi config/proxlb.yaml
|
||||
```
|
||||
|
||||
Finally, start the created container.
|
||||
```bash
|
||||
docker run -it --rm -v $(pwd)/proxlb.yaml:/etc/proxlb/proxlb.yaml proxlb
|
||||
```
|
||||
|
||||
## Usage / Configuration
|
||||
Running ProxLB is straightforward and versatile, as it only requires `Python3` and the `proxmoxer` library. This means ProxLB can be executed directly on a Proxmox node or on dedicated systems such as Debian, RedHat, or even FreeBSD, provided that the Proxmox API is accessible from the client running ProxLB. ProxLB can also run inside a Container - Docker or LXC - and is simply up to you.
|
||||
|
||||
### GUI Integration
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-GUI-integration.jpg"/> ProxLB can also be accessed through the Proxmox Web UI by installing the optional `pve-proxmoxlb-service-ui` package, which depends on the proxlb package. For full Web UI integration, this package must be installed on all nodes within the cluster. Once installed, a new menu item - `Rebalancing`, appears in the cluster level under the HA section. Once installed, it offers two key functionalities:
|
||||
* Rebalancing VM workloads
|
||||
* Migrate VM workloads away from a defined node (e.g. maintenance preparation)
|
||||
|
||||
**Note:** This package is currently discontinued and will be readded at a later time. See also: [#44: How to install pve-proxmoxlb-service-ui package](https://github.com/gyptazy/ProxLB/issues/44).
|
||||
|
||||
### Proxmox HA Integration
|
||||
Proxmox HA (High Availability) groups are designed to ensure that virtual machines (VMs) remain running within a Proxmox cluster. HA groups define specific rules for where VMs should be started or migrated in case of node failures, ensuring minimal downtime and automatic recovery.
|
||||
|
||||
However, when used in conjunction with ProxLB, the built-in load balancer for Proxmox, conflicts can arise. ProxLB operates with its own logic for workload distribution, taking into account affinity and anti-affinity rules. While it effectively balances guest workloads, it may re-shift and redistribute VMs in a way that does not align with HA group constraints, potentially leading to unsuitable placements.
|
||||
|
||||
Due to these conflicts, it is currently not recommended to use both HA groups and ProxLB simultaneously. The interaction between the two mechanisms can lead to unexpected behavior, where VMs might not adhere to HA group rules after being moved by ProxLB.
|
||||
|
||||
A solution to improve compatibility between HA groups and ProxLB is under evaluation, aiming to ensure that both features can work together without disrupting VM placement strategies.
|
||||
|
||||
See also: [#65: Host groups: Honour HA groups](https://github.com/gyptazy/ProxLB/issues/65).
|
||||
|
||||
### Options
|
||||
The following options can be set in the `proxlb.conf` file:
|
||||
The following options can be set in the configuration file `proxlb.yaml`:
|
||||
|
||||
| Section | Option | Sub Option | Example | Type | Description |
|
||||
|---------|:------:|:----------:|:-------:|:----:|:-----------:|
|
||||
| `proxmox_api` | | | | | |
|
||||
| | hosts | | ['virt01.example.com', '10.10.10.10', 'fe01::bad:code::cafe'] | `List` | List of Proxmox nodes. Can be IPv4, IPv6 or mixed. |
|
||||
| | user | | root@pam | `Str` | Username for the API. |
|
||||
| | pass | | FooBar | `Str` | Password for the API. (Recommended: Use API token authorization!) |
|
||||
| | token_id | | proxlb | `Str` | Token ID of the user for the API. |
|
||||
| | token_secret | | 430e308f-1337-1337-beef-1337beefcafe | `Str` | Secret of the token ID for the API. |
|
||||
| | ssl_verification | | True | `Bool` | Validate SSL certificates (1) or ignore (0). [values: `1` (default), `0`] |
|
||||
| | timeout | | 10 | `Int` | Timeout for the Proxmox API in sec. |
|
||||
| `proxmox_cluster` | | | | | |
|
||||
| | maintenance_nodes | | ['virt66.example.com'] | `List` | A list of Proxmox nodes that are defined to be in a maintenance. |
|
||||
| | ignore_nodes | | [] | `List` | A list of Proxmox nodes that are defined to be ignored. |
|
||||
| | overprovisioning | | False | `Bool` | Avoids balancing when nodes would become overprovisioned. |
|
||||
| `balancing` | | | | | |
|
||||
| | enable | | True | `Bool` | Enables the guest balancing.|
|
||||
| | enforce_affinity | | True | `Bool` | Enforcing affinity/anti-affinity rules but balancing might become worse. |
|
||||
| | parallel | | False | `Bool` | If guests should be moved in parallel or sequentially.|
|
||||
| | live | | True | `Bool` | If guests should be moved live or shutdown.|
|
||||
| | with_local_disks | | True | `Bool` | If balancing of guests should include local disks.|
|
||||
| | balance_types | | ['vm', 'ct'] | `List` | Defined the types of guests that should be honored. [values: `vm`, `ct`]|
|
||||
| | max_job_validation | | 1800 | `Int` | How long a job validation may take in seconds. (default: 1800) |
|
||||
| | balanciness | | 10 | `Int` | The maximum delta of resource usage between node with highest and lowest usage. |
|
||||
| | method | | memory | `Str` | The balancing method that should be used. [values: `memory` (default), `cpu`, `disk`]|
|
||||
| | mode | | used | `Str` | The balancing mode that should be used. [values: `used` (default), `assigned`] |
|
||||
| `service` | | | | | |
|
||||
| | daemon | | True | `Bool` | If daemon mode should be activated. |
|
||||
| | `schedule` | | | `Dict` | Schedule config block for rebalancing. |
|
||||
| | | interval | 12 | `Int` | How often rebalancing should occur in daemon mode.|
|
||||
| | | format | hours | `Str` | Sets the time format. [values: `hours` (default), `minutes`]|
|
||||
| | log_level | | INFO | `Str` | Defines the default log level that should be logged. [values: `INFO` (default), `WARNING`, `CRITICAL`, `DEBUG`] |
|
||||
|
||||
| Option | Example | Description |
|
||||
|------|:------:|:------:|
|
||||
| api_host | hypervisor01.gyptazy.ch | Host or IP address of the remote Proxmox API. |
|
||||
| api_user | root@pam | Username for the API. |
|
||||
| api_pass | FooBar | Password for the API. |
|
||||
| verify_ssl | 1 | Validate SSL certificates (1) or ignore (0). (default: 1) |
|
||||
| method | memory | Defines the balancing method (default: memory) where you can use `memory`, `disk` or `cpu`. |
|
||||
| ignore_nodes | dummynode01,dummynode02,test* | Defines a comma separated list of nodes to exclude. |
|
||||
| ignore_vms | testvm01,testvm02 | Defines a comma separated list of VMs to exclude. (`*` as suffix wildcard or tags are also supported) |
|
||||
| daemon | 1 | Run as a daemon (1) or one-shot (0). (default: 1) |
|
||||
| schedule | 24 | Hours to rebalance in hours. (default: 24) |
|
||||
|
||||
An example of the configuration file looks like:
|
||||
```
|
||||
[proxmox]
|
||||
api_host: hypervisor01.gyptazy.ch
|
||||
api_user: root@pam
|
||||
api_pass: FooBar
|
||||
verify_ssl: 1
|
||||
[balancing]
|
||||
method: memory
|
||||
ignore_nodes: dummynode01,dummynode02
|
||||
ignore_vms: testvm01,testvm02
|
||||
[service]
|
||||
daemon: 1
|
||||
proxmox_api:
|
||||
hosts: ['virt01.example.com', '10.10.10.10', 'fe01::bad:code::cafe']
|
||||
user: root@pam
|
||||
#pass: crazyPassw0rd!
|
||||
token_id: proxlb
|
||||
token_secret: 430e308f-1337-1337-beef-1337beefcafe
|
||||
ssl_verification: True
|
||||
timeout: 10
|
||||
|
||||
proxmox_cluster:
|
||||
maintenance_nodes: ['virt66.example.com']
|
||||
ignore_nodes: []
|
||||
overprovisioning: True
|
||||
|
||||
balancing:
|
||||
enable: True
|
||||
enforce_affinity: False
|
||||
parallel: False
|
||||
live: True
|
||||
with_local_disks: True
|
||||
balance_types: ['vm', 'ct']
|
||||
max_job_validation: 1800
|
||||
balanciness: 5
|
||||
method: memory
|
||||
mode: used
|
||||
|
||||
service:
|
||||
daemon: True
|
||||
schedule:
|
||||
interval: 12
|
||||
format: hours
|
||||
log_level: INFO
|
||||
```
|
||||
|
||||
### Parameters
|
||||
@@ -98,110 +306,93 @@ The following options and parameters are currently supported:
|
||||
|
||||
| Option | Long Option | Description | Default |
|
||||
|------|:------:|------:|------:|
|
||||
| -c | --config | Path to a config file. | /etc/proxlb/proxlb.conf (default) |
|
||||
| -c | --config | Path to a config file. | /etc/proxlb/proxlb.yaml (default) |
|
||||
| -d | --dry-run | Performs a dry-run without doing any actions. | False |
|
||||
| -j | --json | Returns a JSON of the VM movement. | False |
|
||||
| -b | --best-node | Returns the best next node for a VM/CT placement (useful for further usage with Terraform/Ansible). | False |
|
||||
| -v | --version | Returns the ProxLB version on stdout. | False |
|
||||
|
||||
## Affinity & Anti-Affinity Rules
|
||||
ProxLB provides an advanced mechanism to define affinity and anti-affinity rules, enabling precise control over virtual machine (VM) placement. These rules help manage resource distribution, improve high availability configurations, and optimize performance within a Proxmox Virtual Environment (PVE) cluster. By leveraging Proxmox’s integrated access management, ProxLB ensures that users can only define and manage rules for guests they have permission to access.
|
||||
|
||||
### Grouping
|
||||
#### Include (Stay Together)
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/plb-rebalancing-include-balance-group.jpg"/> Access the Proxmox Web UI by opening your web browser and navigating to your Proxmox VE web interface, then log in with your credentials. Navigate to the VM you want to tag by selecting it from the left-hand navigation panel. Click on the "Options" tab to view the VM's options, then select "Edit" or "Add" (depending on whether you are editing an existing tag or adding a new one). In the tag field, enter plb_include_ followed by your unique identifier, for example, plb_include_group1. Save the changes to apply the tag to the VM. Repeat these steps for each VM that should be included in the group.
|
||||
ProxLB implements affinity and anti-affinity rules through a tag-based system within the Proxmox web interface. Each guest (virtual machine or container) can be assigned specific tags, which then dictate its placement behavior. This method maintains a streamlined and secure approach to managing VM relationships while preserving Proxmox’s inherent permission model.
|
||||
|
||||
#### Exclude (Stay Separate)
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/plb-rebalancing-exclude-balance-group.jpg"/> Access the Proxmox Web UI by opening your web browser and navigating to your Proxmox VE web interface, then log in with your credentials. Navigate to the VM you want to tag by selecting it from the left-hand navigation panel. Click on the "Options" tab to view the VM's options, then select "Edit" or "Add" (depending on whether you are editing an existing tag or adding a new one). In the tag field, enter plb_exclude_ followed by your unique identifier, for example, plb_exclude_critical. Save the changes to apply the tag to the VM. Repeat these steps for each VM that should be excluded from being on the same node.
|
||||
### Affinity Rules
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-affinity-rules.jpg"/> Affinity rules are used to group certain VMs together, ensuring that they run on the same host whenever possible. This can be beneficial for workloads requiring low-latency communication, such as clustered databases or application servers that frequently exchange data.
|
||||
|
||||
#### Ignore VMs (tag style)
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/plb-rebalancing-ignore-vm.jpg"/> In Proxmox, you can ensure that certain VMs are ignored during the rebalancing process by setting a specific tag within the Proxmox Web UI, rather than solely relying on configurations in the ProxLB config file. This can be achieved by adding the tag 'plb_ignore_vm' to the VM. Once this tag is applied, the VM will be excluded from any further rebalancing operations, simplifying the management process.
|
||||
|
||||
### Systemd
|
||||
When installing a Linux distribution (such as .deb or .rpm) file, this will be shipped with a systemd unit file. The default configuration file will be sourced from `/etc/proxlb/proxlb.conf`.
|
||||
|
||||
| Unit Name | Options |
|
||||
|------|:------:|
|
||||
| proxlb | start, stop, status, restart |
|
||||
|
||||
### Manual
|
||||
A manual installation is possible and also supports BSD based systems. Proxmox Rebalancing Service relies on mainly two important files:
|
||||
* proxlb (Python Executable)
|
||||
* proxlb.conf (Config file)
|
||||
|
||||
The executable must be able to read the config file, if no dedicated config file is given by the `-c` argument, PLB tries to read it from `/etc/proxlb/proxlb.conf`.
|
||||
|
||||
### Proxmox GUI Integration
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/proxlb-GUI-integration.jpg"/> PLB can also be directly be used from the Proxmox Web UI by installing the optional package `pve-proxmoxlb-service-ui` package which has a dependency on the `proxlb` package. For the Web UI integration, it requires to be installed (in addition) on the nodes on the cluster. Afterwards, a new menu item is present in the HA chapter called `Rebalancing`. This chapter provides two possibilities:
|
||||
* Rebalancing VM workloads
|
||||
* Migrate VM workloads away from a defined node (e.g. maintenance preparation)
|
||||
|
||||
### Quick Start
|
||||
The easiest way to get started is by using the ready-to-use packages that I provide on my CDN and to run it on a Linux Debian based system. This can also be one of the Proxmox nodes itself.
|
||||
To define an affinity rule which keeps all guests assigned to this tag together on a node, users assign a tag with the prefix `plb_affinity_$TAG`:
|
||||
|
||||
#### Example for Screenshot
|
||||
```
|
||||
wget https://cdn.gyptazy.ch/files/amd64/debian/proxlb/proxlb_0.9.9_amd64.deb
|
||||
dpkg -i proxlb_0.9.9_amd64.deb
|
||||
# Adjust your config
|
||||
vi /etc/proxlb/proxlb.conf
|
||||
systemctl restart proxlb
|
||||
systemctl status proxlb
|
||||
plb_affinity_talos
|
||||
```
|
||||
|
||||
### Container Quick Start (Docker/Podman)
|
||||
Creating a container image of ProxLB is straightforward using the provided Dockerfile. The Dockerfile simplifies the process by automating the setup and configuration required to get ProxLB running in a container. Simply follow the steps in the Dockerfile to build the image, ensuring all dependencies and configurations are correctly applied. For those looking for an even quicker setup, a ready-to-use ProxLB container image is also available, eliminating the need for manual building and allowing for immediate deployment.
|
||||
As a result, ProxLB will attempt to place all VMs with the `plb_affinity_web` tag on the same host (see also the attached screenshot with the same node).
|
||||
|
||||
```bash
|
||||
git clone https://github.com/gyptazy/ProxLB.git
|
||||
cd ProxLB
|
||||
build -t proxlb .
|
||||
### Anti-Affinity Rules
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-anti-affinity-rules.jpg"/> Conversely, anti-affinity rules ensure that designated VMs do not run on the same physical host. This is particularly useful for high-availability setups, where redundancy is crucial. Ensuring that critical services are distributed across multiple hosts reduces the risk of a single point of failure.
|
||||
|
||||
To define an anti-affinity rule that ensures to not move systems within this group to the same node, users assign a tag with the prefix:
|
||||
|
||||
#### Example for Screenshot
|
||||
```
|
||||
plb_anti_affinity_ntp
|
||||
```
|
||||
|
||||
Afterwards simply adjust the config file to your needs:
|
||||
As a result, ProxLB will try to place the VMs with the `plb_anti_affinity_ntp` tag on different hosts (see also the attached screenshot with the different nodes).
|
||||
|
||||
**Note:** While this ensures that ProxLB tries distribute these VMs across different physical hosts within the Proxmox cluster this may not always work. If you have more guests attached to the group than nodes in the cluster, we still need to run them anywhere. If this case occurs, the next one with the most free resources will be selected.
|
||||
|
||||
### Ignore VMs / CTs
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-ignore-vm-movement.jpg"/> Guests, such as VMs or CTs, can also be completely ignored. This means, they won't be affected by any migration (even when (anti-)affinity rules are enforced). To ensure a proper resource evaluation, these guests are still collected and evaluated but simply skipped for balancing actions. Another thing is the implementation. While ProxLB might have a very restricted configuration file including the file permissions, this file is only read- and writeable by the Proxmox administrators. However, we might have user and groups who want to define on their own that their systems shouldn't be moved. Therefore, these users can simpy set a specific tag to the guest object - just like the (anti)affinity rules.
|
||||
|
||||
To define a guest to be ignored from the balancing, users assign a tag with the prefix `plb_ignore_$TAG`:
|
||||
|
||||
#### Example for Screenshot
|
||||
```
|
||||
vi /etc/proxlb/proxlb.conf
|
||||
plb_ignore_dev
|
||||
```
|
||||
|
||||
Finally, start the created container.
|
||||
```bash
|
||||
docker run -it --rm -v $(pwd)/proxlb.conf:/etc/proxlb/proxlb.conf proxlb
|
||||
As a result, ProxLB will not migrate this guest with the `plb_ignore_dev` tag to any other node.
|
||||
|
||||
**Note:** Ignored guests are really ignored. Even by enforcing affinity rules this guest will be ignored.
|
||||
|
||||
## Maintenance
|
||||
<img src="https://cdn.gyptazy.com/images/proxlb-rebalancing-demo.gif"/>
|
||||
|
||||
The `maintenance_nodes` option allows operators to designate one or more Proxmox nodes for maintenance mode. When a node is set to maintenance, no new guest workloads will be assigned to it, and all existing workloads will be migrated to other available nodes within the cluster. This process ensures that (anti)-affinity rules and resource availability are respected, preventing disruptions while maintaining optimal performance across the infrastructure.
|
||||
|
||||
### Adding / Removing Nodes from Maintenance
|
||||
Within the section `proxmox_cluster` you can define the key `maintenance_nodes` as a list object. Simply add/remove one or more nodes with their equal name in the cluster and restart the daemon.
|
||||
```
|
||||
|
||||
### Logging
|
||||
ProxLB uses the `SystemdHandler` for logging. You can find all your logs in your systemd unit log or in the journalctl.
|
||||
|
||||
## Motivation
|
||||
As a developer managing a cluster of virtual machines for my projects, I often encountered the challenge of resource imbalance. Nodes within the cluster would become unevenly loaded, with some nodes being overburdened while others remained underutilized. This imbalance led to inefficiencies, performance bottlenecks, and increased operational costs. Frustrated by the lack of an adequate solution to address this issue, I decided to develop the ProxLB (PLB) to ensure better resource distribution across my clusters.
|
||||
|
||||
My primary motivation for creating PLB stemmed from my work on my BoxyBSD project, where I consistently faced the difficulty of maintaining balanced nodes while running various VM workloads but also on my personal clusters. The absence of an efficient rebalancing mechanism made it challenging to achieve optimal performance and stability. Recognizing the necessity for a tool that could gather and analyze resource metrics from both the cluster nodes and the running VMs, I embarked on developing ProxLB.
|
||||
|
||||
PLB meticulously collects detailed resource usage data from each node in a Proxmox cluster, including CPU load, memory usage, and local disk space utilization. It also gathers comprehensive statistics from all running VMs, providing a granular understanding of the workload distribution. With this data, PLB intelligently redistributes VMs based on memory usage, local disk usage, and CPU usage. This ensures that no single node is overburdened, storage resources are evenly distributed, and the computational load is balanced, enhancing overall cluster performance.
|
||||
|
||||
As an advocate of the open-source philosophy, I believe in the power of community and collaboration. By sharing solutions like PLB, I aim to contribute to the collective knowledge and tools available to developers facing similar challenges. Open source fosters innovation, transparency, and mutual support, enabling developers to build on each other's work and create better solutions together.
|
||||
|
||||
Developing PLB was driven by a desire to solve a real problem I faced in my projects. However, the spirit behind this effort was to provide a valuable resource to the community. By open-sourcing PLB, I hope to help other developers manage their clusters more efficiently, optimize their resource usage, and reduce operational costs. Sharing this solution aligns with the core principles of open source, where the goal is not only to solve individual problems but also to contribute to the broader ecosystem.
|
||||
|
||||
## References
|
||||
Here you can find some overviews of references for and about the ProxLB (PLB):
|
||||
|
||||
| Description | Link |
|
||||
|------|:------:|
|
||||
| General introduction into ProxLB | https://gyptazy.ch/blog/proxlb-rebalancing-vm-workloads-across-nodes-in-proxmox-clusters/ |
|
||||
| Howto install and use ProxLB on Debian to rebalance vm workloads in a Proxmox cluster | https://gyptazy.ch/howtos/howto-install-and-use-proxlb-to-rebalance-vm-workloads-across-nodes-in-proxmox-clusters/ |
|
||||
|
||||
## Packages / Container Images
|
||||
Ready to use packages can be found at:
|
||||
* https://cdn.gyptazy.ch/files/amd64/debian/proxlb/
|
||||
* https://cdn.gyptazy.ch/files/amd64/ubuntu/proxlb/
|
||||
* https://cdn.gyptazy.ch/files/amd64/redhat/proxlb/
|
||||
* https://cdn.gyptazy.ch/files/amd64/freebsd/proxlb/
|
||||
|
||||
Container Images for Podman, Docker etc., can be found at:
|
||||
| Version | Image |
|
||||
|------|:------:|
|
||||
| latest | cr.gyptazy.ch/proxlb/proxlb:latest |
|
||||
| v0.0.9 | cr.gyptazy.ch/proxlb/proxlb:v0.0.9 |
|
||||
proxmox_cluster:
|
||||
maintenance_nodes: ['virt66.example.com']
|
||||
```
|
||||
Afterwards, all guest objects will be moved to other nodes in the cluster by ensuring the best balancing.
|
||||
|
||||
## Misc
|
||||
### Bugs
|
||||
Bugs can be reported via the GitHub issue tracker [here](https://github.com/gyptazy/ProxLB/issues). You may also report bugs via email or deliver PRs to fix them on your own. Therefore, you might also see the contributing chapter.
|
||||
|
||||
### Contributing
|
||||
Feel free to add further documentation, to adjust already existing one or to contribute with code. Please take care about the style guide and naming conventions.
|
||||
Feel free to add further documentation, to adjust already existing one or to contribute with code. Please take care about the style guide and naming conventions. You can find more in our [CONTRIBUTING.md](https://github.com/gyptazy/ProxLB/blob/main/CONTRIBUTING.md) file.
|
||||
|
||||
### Documentation
|
||||
You can also find additional and more detailed documentation within the [docs/](https://github.com/gyptazy/ProxLB/tree/main/docs) directory.
|
||||
|
||||
### Support
|
||||
If you need assistance or have any questions, we offer support through our dedicated [chat room](https://matrix.to/#/#proxlb:gyptazy.com) in Matrix or [Discord](https://discord.gg/JemGu7WbfQ). Join our community for real-time help, advice, and discussions. The Matrix and Discord room are bridged to ensure that the communication is not splitted - so simply feel free to join which fits most to you!
|
||||
|
||||
Connect with us in our dedicated chat room for immediate support and live interaction with other users and developers. You can also visit our [GitHub Community](https://github.com/gyptazy/ProxLB/discussions/) to post your queries, share your experiences, and get support from fellow community members and moderators. You may also just open directly an issue [here](https://github.com/gyptazy/ProxLB/issues) on GitHub.
|
||||
|
||||
| Support Channel | Link |
|
||||
|------|:------:|
|
||||
| Matrix | [#proxlb:gyptazy.com](https://matrix.to/#/#proxlb:gyptazy.com) |
|
||||
| Discord | [Discord](https://discord.gg/JemGu7WbfQ) |
|
||||
| GitHub Community | [GitHub Community](https://github.com/gyptazy/ProxLB/discussions/)
|
||||
| GitHub | [ProxLB GitHub](https://github.com/gyptazy/ProxLB/issues) |
|
||||
|
||||
**Note:** Please always keep in mind that this is a one-man show project without any further help. This includes coding, testing, packaging and all the infrastructure around it to keep this project up and running.
|
||||
|
||||
### Author(s)
|
||||
* Florian Paul Azim Hoberg @gyptazy (https://gyptazy.ch)
|
||||
* Florian Paul Azim Hoberg @gyptazy (https://gyptazy.com)
|
||||
|
||||
33
config/proxlb_example.yaml
Normal file
33
config/proxlb_example.yaml
Normal file
@@ -0,0 +1,33 @@
|
||||
proxmox_api:
|
||||
hosts: ['virt01.example.com', '10.10.10.10', 'fe01::bad:code::cafe']
|
||||
user: root@pam
|
||||
pass: crazyPassw0rd!
|
||||
# API Token method
|
||||
# token_id: proxlb
|
||||
# token_secret: 430e308f-1337-1337-beef-1337beefcafe
|
||||
ssl_verification: True
|
||||
timeout: 10
|
||||
|
||||
proxmox_cluster:
|
||||
maintenance_nodes: ['virt66.example.com']
|
||||
ignore_nodes: []
|
||||
overprovisioning: True
|
||||
|
||||
balancing:
|
||||
enable: True
|
||||
enforce_affinity: False
|
||||
parallel: False
|
||||
live: True
|
||||
with_local_disks: True
|
||||
balance_types: ['vm', 'ct']
|
||||
max_job_validation: 1800
|
||||
balanciness: 5
|
||||
method: memory
|
||||
mode: used
|
||||
|
||||
service:
|
||||
daemon: True
|
||||
schedule:
|
||||
interval: 12
|
||||
format: hours
|
||||
log_level: INFO
|
||||
12
debian/changelog
vendored
Normal file
12
debian/changelog
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
proxlb (1.1.1) stable; urgency=medium
|
||||
|
||||
* Fix tag evluation for VMs for being ignored for further balancing. (Closes: #163)
|
||||
* Improve logging verbosity of messages that had a wrong servity. (Closes: #165)
|
||||
|
||||
-- Florian Paul Azim Hoberg <gyptazy@gyptazy.com> Tue, 1 Apr 2025 18:55:02 +0000
|
||||
|
||||
proxlb (1.1.0) stable; urgency=medium
|
||||
|
||||
* Refactored code base of ProxLB. (Closes: #114)
|
||||
|
||||
-- Florian Paul Azim Hoberg <gyptazy@gyptazy.com> Mon, 17 Mar 2025 18:55:02 +0000
|
||||
12
debian/control
vendored
Normal file
12
debian/control
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
Source: proxlb
|
||||
Maintainer: Florian Paul Azim Hoberg <gyptazy@gyptazy.com>
|
||||
Section: admin
|
||||
Priority: optional
|
||||
Standards-Version: 4.5.0
|
||||
Build-Depends: debhelper-compat (= 13), dh-python, python3-all, python3-setuptools
|
||||
|
||||
Package: proxlb
|
||||
Architecture: all
|
||||
Depends: ${python3:Depends}, ${misc:Depends}, python3-requests, python3-urllib3, python3-proxmoxer, python3-yaml
|
||||
Description: A DRS alike Load Balancer for Proxmox Clusters
|
||||
An advanced DRS alike loadbalancer for Proxmox clusters that also supports maintenance modes and affinity/anti-affinity rules.
|
||||
2
debian/install
vendored
Normal file
2
debian/install
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
proxlb /usr/lib/python3/dist-packages/
|
||||
service/proxlb.service /lib/systemd/system/
|
||||
16
debian/postinst
vendored
Executable file
16
debian/postinst
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#DEBHELPER#
|
||||
if [ "$1" = "configure" ]; then
|
||||
systemctl enable proxlb.service
|
||||
systemctl restart proxlb.service || true
|
||||
|
||||
# Create the 'plb' user if it does not exist
|
||||
if ! id "plb" &>/dev/null; then
|
||||
useradd --system --home /var/lib/proxlb --create-home --shell /usr/sbin/nologin --group nogroup plb
|
||||
echo "User 'plb' created."
|
||||
else
|
||||
echo "User 'plb' already exists, skipping creation."
|
||||
fi
|
||||
fi
|
||||
16
debian/prerm
vendored
Executable file
16
debian/prerm
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
#DEBHELPER#
|
||||
if [ "$1" = "remove" ]; then
|
||||
systemctl stop proxlb.service || true
|
||||
systemctl disable proxlb.service || true
|
||||
|
||||
# Remove the 'plb' user if it exists
|
||||
if id "plb" &>/dev/null; then
|
||||
userdel --remove plb
|
||||
echo "User 'plb' removed."
|
||||
else
|
||||
echo "User 'plb' does not exist, skipping removal."
|
||||
fi
|
||||
fi
|
||||
4
debian/rules
vendored
Normal file
4
debian/rules
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/make -f
|
||||
%:
|
||||
dh $@ --with python3 --buildsystem=pybuild
|
||||
|
||||
1
debian/source/format
vendored
Normal file
1
debian/source/format
vendored
Normal file
@@ -0,0 +1 @@
|
||||
3.0 (native)
|
||||
@@ -1,32 +0,0 @@
|
||||
# Installation
|
||||
|
||||
## Packages
|
||||
The easiest way to get started is by using the ready-to-use packages that I provide on my CDN and to run it on a Linux Debian based system. This can also be one of the Proxmox nodes itself.
|
||||
|
||||
```
|
||||
wget https://cdn.gyptazy.ch/files/amd64/debian/proxlb/proxlb_0.9.9_amd64.deb
|
||||
dpkg -i proxlb_0.9.9_amd64.deb
|
||||
# Adjust your config
|
||||
vi /etc/proxlb/proxlb.conf
|
||||
systemctl restart proxlb
|
||||
systemctl status proxlb
|
||||
```
|
||||
|
||||
## Container (Docker/Podman)
|
||||
Creating a container image of ProxLB is straightforward using the provided Dockerfile. The Dockerfile simplifies the process by automating the setup and configuration required to get ProxLB running in a container. Simply follow the steps in the Dockerfile to build the image, ensuring all dependencies and configurations are correctly applied. For those looking for an even quicker setup, a ready-to-use ProxLB container image is also available, eliminating the need for manual building and allowing for immediate deployment.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/gyptazy/ProxLB.git
|
||||
cd ProxLB
|
||||
build -t proxlb .
|
||||
```
|
||||
|
||||
Afterwards simply adjust the config file to your needs:
|
||||
```
|
||||
vi /etc/proxlb/proxlb.conf
|
||||
```
|
||||
|
||||
Finally, start the created container.
|
||||
```bash
|
||||
docker run -it --rm -v $(pwd)/proxlb.conf:/etc/proxlb/proxlb.conf proxlb
|
||||
```
|
||||
65
docs/01_requirements.md
Normal file
65
docs/01_requirements.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# Table of Contents
|
||||
|
||||
- [Requirements](#requirements)
|
||||
- [Where To Run?](#where-to-run)
|
||||
|
||||
## Requirements
|
||||
ProxLB is a sophisticated load balancer designed to enhance the management and distribution of workloads within a Proxmox cluster. By fully utilizing the Proxmox API, ProxLB eliminates the need for additional SSH access, streamlining cluster management while maintaining robust security. This chapter outlines the general requirements necessary to deploy and operate ProxLB effectively.
|
||||
|
||||
### Proxmox Cluster Requirements
|
||||
To use ProxLB, you must have an existing Proxmox cluster consisting of at least two nodes. While traditional load balancers often struggle to manage minimal node configurations, ProxLB is optimized to provide efficient load distribution even in a two-node environment. The more nodes present in the cluster, the better ProxLB can optimize resource usage and manage workloads.
|
||||
|
||||
### ProxLB Package Requirements
|
||||
Next to the previously mentioned requirements, ProxLB also requires you to fit the following ones:
|
||||
* Python3.x
|
||||
* proxmoxer
|
||||
* requests
|
||||
* urllib3
|
||||
* pyyaml
|
||||
|
||||
### Seamless API Integration
|
||||
ProxLB relies exclusively on the Proxmox API for all management tasks. This eliminates the need for direct SSH access, ensuring a cleaner and more secure interaction with the cluster. The API integration allows ProxLB to:
|
||||
|
||||
- Monitor cluster health and node resource utilization
|
||||
- Migrate virtual machines (VMs) and containers as needed
|
||||
- Manage storage utilization and distribution
|
||||
- Implement load balancing policies
|
||||
|
||||
### Authentication and Security Standards
|
||||
ProxLB fully supports Proxmox’s integrated user management system, providing robust authentication and access control. Key features include:
|
||||
|
||||
- **Multi-Factor Authentication (MFA):** Enhances security by requiring multiple verification methods.
|
||||
- **API Key Support:** ProxLB can utilize API keys for authentication instead of traditional username/password combinations, minimizing exposure to credentials.
|
||||
- **Role-Based Access Control (RBAC):** Ensures administrators have fine-grained control over user permissions.
|
||||
|
||||
### Flexible Storage Support
|
||||
ProxLB offers versatile storage management options, supporting both local and shared storage types. It efficiently balances storage workloads across the cluster using the following storage systems:
|
||||
|
||||
- **Local Storage:** Direct-attached storage on each node.
|
||||
- **Shared Storage:** Includes options like iSCSI, NVMeOF, and NFS for centralized storage solutions.
|
||||
- **Ceph:** Integrated support for Ceph distributed storage, providing high availability and fault tolerance.
|
||||
|
||||
### Network Infrastructure Requirements
|
||||
For optimal performance, ProxLB requires a reliable and high-speed network connection between the nodes in the cluster. Ensure that the network infrastructure meets the following criteria:
|
||||
|
||||
- **Low Latency:** Essential for real-time load balancing and VM migration.
|
||||
- **Sufficient Bandwidth:** Adequate to handle storage access, data replication, and migration traffic.
|
||||
- **Redundant Network Paths:** Recommended for increased fault tolerance and uptime.
|
||||
|
||||
### System Resource Allocation
|
||||
ProxLB itself requires minimal system resources to operate. However, for managing larger clusters or high workloads, ensure the node running ProxLB has adequate resources available:
|
||||
|
||||
- **CPU:** A modern multi-core processor.
|
||||
- **Memory:** At least 2 GB of RAM.
|
||||
- **Storage:** Minimal disk space for configuration files and logs.
|
||||
|
||||
|
||||
## Where To Run?
|
||||
ProxLB can run on pretty anthing and only requires you to have a network connectivity to any of the Proxmox host's API (usually on tcp/8006).
|
||||
|
||||
Therefore, you can simply run ProxLB on:
|
||||
* Bare-metal Systems
|
||||
* VMs (even inside the Proxmox cluster)
|
||||
* Docker/Podman Container
|
||||
* LXC Container
|
||||
* On a Proxmox node
|
||||
@@ -1,10 +0,0 @@
|
||||
# Configuration
|
||||
## Grouping
|
||||
### Include (Stay Together)
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/plb-rebalancing-include-balance-group.jpg"/> Access the Proxmox Web UI by opening your web browser and navigating to your Proxmox VE web interface, then log in with your credentials. Navigate to the VM you want to tag by selecting it from the left-hand navigation panel. Click on the "Options" tab to view the VM's options, then select "Edit" or "Add" (depending on whether you are editing an existing tag or adding a new one). In the tag field, enter plb_include_ followed by your unique identifier, for example, plb_include_group1. Save the changes to apply the tag to the VM. Repeat these steps for each VM that should be included in the group.
|
||||
|
||||
### Exclude (Stay Separate)
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/plb-rebalancing-exclude-balance-group.jpg"/> Access the Proxmox Web UI by opening your web browser and navigating to your Proxmox VE web interface, then log in with your credentials. Navigate to the VM you want to tag by selecting it from the left-hand navigation panel. Click on the "Options" tab to view the VM's options, then select "Edit" or "Add" (depending on whether you are editing an existing tag or adding a new one). In the tag field, enter plb_exclude_ followed by your unique identifier, for example, plb_exclude_critical. Save the changes to apply the tag to the VM. Repeat these steps for each VM that should be excluded from being on the same node.
|
||||
|
||||
### Ignore VMs (tag style)
|
||||
<img align="left" src="https://cdn.gyptazy.ch/images/plb-rebalancing-ignore-vm.jpg"/> In Proxmox, you can ensure that certain VMs are ignored during the rebalancing process by setting a specific tag within the Proxmox Web UI, rather than solely relying on configurations in the ProxLB config file. This can be achieved by adding the tag 'plb_ignore_vm' to the VM. Once this tag is applied, the VM will be excluded from any further rebalancing operations, simplifying the management process.
|
||||
164
docs/02_installation.md
Normal file
164
docs/02_installation.md
Normal file
@@ -0,0 +1,164 @@
|
||||
# Table of Contents
|
||||
|
||||
- [Installation](#installation)
|
||||
- [Requirements / Dependencies](#requirements--dependencies)
|
||||
- [Debian Package](#debian-package)
|
||||
- [Quick-Start](#quick-start)
|
||||
- [Details](#details)
|
||||
- [Debian Packages (.deb files)](#debian-packages-deb-files)
|
||||
- [RedHat Package](#redhat-package)
|
||||
- [Container Images / Docker](#container-images--docker)
|
||||
- [Overview of Images](#overview-of-images)
|
||||
- [Source](#source)
|
||||
- [Traditional System](#traditional-system)
|
||||
- [Container Image](#container-image)
|
||||
- [Upgrading](#upgrading)
|
||||
- [Upgrading from < 1.1.0](#upgrading-from--110)
|
||||
- [Upgrading from >= 1.1.0](#upgrading-from--110)
|
||||
|
||||
|
||||
## Installation
|
||||
### Requirements / Dependencies
|
||||
* Python3.x
|
||||
* proxmoxer
|
||||
* requests
|
||||
* urllib3
|
||||
* pyyaml
|
||||
|
||||
The dependencies can simply be installed with `pip` by running the following command:
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
*Note: Distribution packages, such like the provided `.deb` package will automatically resolve and install all required dependencies by using already packaged version from the distribution's repository. By using the Docker (container) image or Debian packages, you do not need to take any care of the requirements listed here.*
|
||||
|
||||
### Debian Package
|
||||
ProxLB is a powerful and flexible load balancer designed to work across various architectures, including `amd64`, `arm64`, `rv64` and many other ones that support Python. It runs independently of the underlying hardware, making it a versatile choice for different environments. This chapter covers the step-by-step process to install ProxLB on Debian-based systems, including Debian clones like Ubuntu.
|
||||
|
||||
#### Quick-Start
|
||||
You can simply use this snippet to install the repository and to install ProxLB on your system.
|
||||
|
||||
```bash
|
||||
echo "deb https://repo.gyptazy.com/stable /" > /etc/apt/sources.list.d/proxlb.list
|
||||
wget -O /etc/apt/trusted.gpg.d/proxlb.asc https://repo.gyptazy.com/repository.gpg
|
||||
apt-get update && apt-get -y install proxlb
|
||||
cp /etc/proxlb/proxlb_example.yaml /etc/proxlb/proxlb.yaml
|
||||
# Adjust the config to your needs
|
||||
vi /etc/proxlb/proxlb.yaml
|
||||
systemctl start proxlb
|
||||
```
|
||||
|
||||
Afterwards, ProxLB is running in the background and balances your cluster by your defined balancing method (default: memory).
|
||||
|
||||
#### Details
|
||||
ProxLB provides two different repositories:
|
||||
* https://repo.gyptazy.com/stable (only stable release)
|
||||
* https://repo.gyptazy.com/testing (bleeding edge - not recommended)
|
||||
|
||||
The repository is signed and the GPG key can be found at:
|
||||
* https://repo.gyptazy.com/repository.gpg
|
||||
|
||||
You can also simply import it by running:
|
||||
|
||||
```
|
||||
# KeyID: 17169F23F9F71A14AD49EDADDB51D3EB01824F4C
|
||||
# UID: gyptazy Solutions Repository <contact@gyptazy.com>
|
||||
# SHA256: 52c267e6f4ec799d40cdbdb29fa518533ac7942dab557fa4c217a76f90d6b0f3 repository.gpg
|
||||
|
||||
wget -O /etc/apt/trusted.gpg.d/proxlb.asc https://repo.gyptazy.com/repository.gpg
|
||||
```
|
||||
|
||||
*Note: The defined repositories `repo.gyptazy.com` and `repo.proxlb.de` are the same!*
|
||||
|
||||
#### Debian Packages (.deb files)
|
||||
If you do not want to use the repository you can also find the debian packages as a .deb file on gyptazy's CDN at:
|
||||
* https://cdn.gyptazy.com/files/os/debian/proxlb/
|
||||
|
||||
Afterwards, you can simply install the package by running:
|
||||
```bash
|
||||
dpkg -i proxlb_*.deb
|
||||
cp /etc/proxlb/proxlb_example.yaml /etc/proxlb/proxlb.yaml
|
||||
# Adjust the config to your needs
|
||||
vi /etc/proxlb/proxlb.yaml
|
||||
systemctl start proxlb
|
||||
```
|
||||
|
||||
### RedHat Package
|
||||
There's currently no official support for RedHat based systems. However, there's a dummy .rpm package for such systems in the pipeline which can be found here:
|
||||
* https://github.com/gyptazy/ProxLB/actions/workflows/20-pipeline-build-rpm-package.yml
|
||||
|
||||
|
||||
### Container Images / Docker
|
||||
Using the ProxLB container images is straight forward and only requires you to mount the config file.
|
||||
|
||||
```bash
|
||||
# Pull the image
|
||||
docker pull cr.gyptazy.com/proxlb/proxlb:latest
|
||||
# Download the config
|
||||
wget -O proxlb.yaml https://raw.githubusercontent.com/gyptazy/ProxLB/refs/heads/main/config/proxlb_example.yaml
|
||||
# Adjust the config to your needs
|
||||
vi proxlb.yaml
|
||||
# Start the ProxLB container image with the ProxLB config
|
||||
docker run -it --rm -v $(pwd)/proxlb.yaml:/etc/proxlb/proxlb.yaml proxlb
|
||||
```
|
||||
|
||||
*Note: ProxLB container images are officially only available at cr.proxlb.de and cr.gyptazy.com.*
|
||||
|
||||
#### Overview of Images
|
||||
| Version | Image |
|
||||
|------|:------:|
|
||||
| latest | cr.gyptazy.com/proxlb/proxlb:latest |
|
||||
| v1.1.0 | cr.gyptazy.com/proxlb/proxlb:v1.1.0 |
|
||||
| v1.0.6 | cr.gyptazy.com/proxlb/proxlb:v1.0.6 |
|
||||
| v1.0.5 | cr.gyptazy.com/proxlb/proxlb:v1.0.5 |
|
||||
| v1.0.4 | cr.gyptazy.com/proxlb/proxlb:v1.0.4 |
|
||||
| v1.0.3 | cr.gyptazy.com/proxlb/proxlb:v1.0.3 |
|
||||
| v1.0.2 | cr.gyptazy.com/proxlb/proxlb:v1.0.2 |
|
||||
| v1.0.0 | cr.gyptazy.com/proxlb/proxlb:v1.0.0 |
|
||||
| v0.9.9 | cr.gyptazy.com/proxlb/proxlb:v0.9.9 |
|
||||
|
||||
### Source
|
||||
ProxLB can also easily be used from the provided sources - for traditional systems but also as a Docker/Podman container image.
|
||||
|
||||
#### Traditional System
|
||||
Setting up and running ProxLB from the sources is simple and requires just a few commands. Ensure Python 3 and the Python dependencies are installed on your system, then run ProxLB using the following command:
|
||||
```bash
|
||||
git clone https://github.com/gyptazy/ProxLB.git
|
||||
cd ProxLB
|
||||
```
|
||||
|
||||
Afterwards simply adjust the config file to your needs:
|
||||
```bash
|
||||
vi config/proxlb.yaml
|
||||
```
|
||||
|
||||
Start ProxLB by Python3 on the system:
|
||||
```bash
|
||||
python3 proxlb/main.py -c config/proxlb.yaml
|
||||
```
|
||||
|
||||
#### Container Image
|
||||
Creating a container image of ProxLB is straightforward using the provided Dockerfile. The Dockerfile simplifies the process by automating the setup and configuration required to get ProxLB running in an Alpine container. Simply follow the steps in the Dockerfile to build the image, ensuring all dependencies and configurations are correctly applied. For those looking for an even quicker setup, a ready-to-use ProxLB container image is also available, eliminating the need for manual building and allowing for immediate deployment.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/gyptazy/ProxLB.git
|
||||
cd ProxLB
|
||||
docker build -t proxlb .
|
||||
```
|
||||
|
||||
Afterwards simply adjust the config file to your needs:
|
||||
```bash
|
||||
vi config/proxlb.yaml
|
||||
```
|
||||
|
||||
Finally, start the created container.
|
||||
```bash
|
||||
docker run -it --rm -v $(pwd)/proxlb.yaml:/etc/proxlb/proxlb.yaml proxlb
|
||||
```
|
||||
|
||||
## Upgrading
|
||||
### Upgrading from < 1.1.0
|
||||
Upgrading ProxLB is not supported due to a fundamental redesign introduced in version 1.1.x. With this update, ProxLB transitioned from a monolithic application to a pure Python-style project, embracing a more modular and flexible architecture. This shift aimed to improve maintainability and extensibility while keeping up with modern development practices. Additionally, ProxLB moved away from traditional ini-style configuration files and adopted YAML for configuration management. This change simplifies configuration handling, reduces the need for extensive validation, and ensures better type casting, ultimately providing a more streamlined and user-friendly experience.
|
||||
|
||||
### Upgrading from >= 1.1.0
|
||||
Uprading within the current stable versions, starting from 1.1.0, will be possible in all supported ways.
|
||||
@@ -1,23 +0,0 @@
|
||||
## FAQ
|
||||
|
||||
### Could not import all dependencies
|
||||
ProxLB requires the Python library `proxmoxer`. This can simply be installed by the most
|
||||
system repositories. If you encounter this error message you simply need to install it.
|
||||
|
||||
|
||||
```
|
||||
# systemctl status proxlb
|
||||
x proxlb.service - Proxmox Rebalancing Service
|
||||
Loaded: loaded (/etc/systemd/system/proxlb.service; static)
|
||||
Active: failed (Result: exit-code) since Sat 2024-07-06 10:25:16 UTC; 1s ago
|
||||
Duration: 239ms
|
||||
Process: 7285 ExecStart=/usr/bin/proxlb -c /etc/proxlb/proxlb.conf (code=exited, status=2)
|
||||
Main PID: 7285 (code=exited, status=2)
|
||||
CPU: 129ms
|
||||
|
||||
Jul 06 10:25:16 build01 systemd[1]: Started proxlb.service - ProxLB.
|
||||
Jul 06 10:25:16 build01 proxlb[7285]: proxlb: Error: [python-imports]: Could not import all dependencies. Please install "proxmoxer".
|
||||
```
|
||||
|
||||
Debian/Ubuntu: apt-get install python3-proxmoxer
|
||||
If the package is not provided by your systems repository, you can also install it by running `pip3 install proxmoxer`.
|
||||
195
docs/03_configuration.md
Normal file
195
docs/03_configuration.md
Normal file
@@ -0,0 +1,195 @@
|
||||
# Table of Contents
|
||||
|
||||
1. [Authentication / User Accounts / Permissions](#authentication--user-accounts--permissions)
|
||||
1. [Authentication](#authentication)
|
||||
2. [Creating a Dedicated User](#creating-a-dedicated-user)
|
||||
3. [Creating an API Token for a User](#creating-an-api-token-for-a-user)
|
||||
4. [Required Permissions for a User](#required-permissions-for-a-user)
|
||||
2. [Configuration](#configuration)
|
||||
1. [Affinity & Anti-Affinity Rules](#affinity--anti-affinity-rules)
|
||||
1. [Affinity Rules](#affinity-rules)
|
||||
2. [Anti-Affinity Rules](#anti-affinity-rules)
|
||||
3. [Affinity / Anti-Affinity Enforcing](#affinity--anti-affinity-enforcing)
|
||||
4. [Ignore VMs](#ignore-vms)
|
||||
2. [API Loadbalancing](#api-loadbalancing)
|
||||
3. [Ignore Host-Nodes or Guests](#ignore-host-nodes-or-guests)
|
||||
4. [IPv6 Support](#ipv6-support)
|
||||
5. [Logging / Log-Level](#logging--log-level)
|
||||
6. [Parallel Migrations](#parallel-migrations)
|
||||
7. [Run as a Systemd-Service](#run-as-a-systemd-service)
|
||||
8. [SSL Self-Signed Certificates](#ssl-self-signed-certificates)
|
||||
|
||||
## Authentication / User Accounts / Permissions
|
||||
### Authentication
|
||||
ProxLB supports the traditional username and password authentication method, which is familiar to many users. This method requires users to provide their credentials (username and password) to gain access to the Proxmox system. While this method is straightforward and easy to implement, it has several security limitations. Username and password combinations can be vulnerable to brute force attacks, where an attacker systematically attempts various combinations until the correct one is found. If a user's credentials are compromised through phishing, malware, or other means, the attacker can gain unauthorized access to the system. Additionally, traditional authentication does not provide granular control over permissions and access levels, potentially exposing sensitive operations to unauthorized users.
|
||||
|
||||
To enhance security, ProxLB supports API token authentication. API tokens are unique identifiers that are used to authenticate API requests. They offer several advantages over traditional username and password authentication. API tokens are more secure as they are typically long, random strings that are difficult to guess. They can be revoked and regenerated as needed, reducing the risk of unauthorized access. API tokens can be associated with specific user accounts that have only the required permissions, ensuring that users only have access to the resources and operations they need. Furthermore, API tokens can be used for automated scripts and applications, facilitating seamless integration with other systems and services.
|
||||
|
||||
When Multi-Factor Authentication (MFA) or Two-Factor Authentication (2FA) is enabled in the Proxmox cluster, the system enforces the use of API tokens for authentication. This is because traditional username and password authentication is not considered secure enough in conjunction with MFA/2FA. To ensure the highest level of security when using API tokens, follow these best practices: Use dedicated user accounts for API tokens, each with only the necessary permissions. This limits the potential impact of a compromised token. Ensure that API tokens are long, random, and unique. Avoid using easily guessable patterns or sequences. Periodically regenerate and replace API tokens to minimize the risk of long-term exposure. Store API tokens securely, using environment variables or secure vaults. Avoid hardcoding tokens in source code or configuration files. Regularly monitor and audit the usage of API tokens to detect any suspicious activity or unauthorized access.
|
||||
|
||||
### Creating a Dedicated User
|
||||
It is advisable to avoid using the default root@pam user for balancing tasks in ProxLB. Instead, creating a dedicated user account is recommended and can be done easily. You can create a new user through the GUI, API, or CLI. While the detailed roles required for balancing are outlined in the next chapter, you can also use the following CLI commands to create a user with the necessary roles to manage Virtual Machines (VMs) and Containers (CTs):
|
||||
|
||||
```
|
||||
pveum role add proxlb --privs Datastore.Audit,Sys.Audit,VM.Audit,VM.Migrate
|
||||
pveum user add proxlb@pve --password <password>
|
||||
pveum acl modify / --roles proxlb --users proxlb@pve
|
||||
```
|
||||
|
||||
*Note: The user management can also be done on the WebUI without invoking the CLI.*
|
||||
|
||||
### Creating an API Token for a User
|
||||
Create an API token for user proxlb@pve with token ID proxlb and deactivated privilege separation:
|
||||
```
|
||||
pveum user token add proxlb@pve proxlb --privsep 0
|
||||
```
|
||||
|
||||
Afterwards, you get the token secret returned. You can now add those entries to your ProxLB config. Make sure, that you also keep the `user` parameter, next to the new token parameters.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The parameter `pass` then needs to be **absent**! You should also take care about the privilege and authentication mechanism behind Proxmox. You might want or even might not want to use privilege separation and this is up to your personal needs and use case.
|
||||
|
||||
| Proxmox API | ProxLB Config | Example |
|
||||
|---|---|---|
|
||||
| User | [user](https://github.com/gyptazy/ProxLB/blob/main/config/proxlb_example.yaml#L3) | proxlb@pve |
|
||||
| Token ID | [token_id](https://github.com/gyptazy/ProxLB/blob/main/config/proxlb_example.yaml#L6) | proxlb |
|
||||
| Token Secret | [token_secret](https://github.com/gyptazy/ProxLB/blob/main/config/proxlb_example.yaml#L7) | 430e308f-1337-1337-beef-1337beefcafe |
|
||||
|
||||
*Note: The API token configuration can also be done on the WebUI without invoking the CLI.*
|
||||
|
||||
### Required Permissions for a User
|
||||
To ensure that ProxLB operates effectively and securely, it is essential to assign the appropriate permissions to the user accounts responsible for managing the load balancing tasks. The following permissions are the minimum required for a user to perform essential ProxLB operations:
|
||||
|
||||
* `Datastore.Audit`: Grants the ability to audit and view datastore information.
|
||||
* `Sys.Audit`: Allows the user to audit and view system information.
|
||||
* `VM.Audit`: Enables the user to audit and view virtual machine details.
|
||||
* `VM.Migrate`: Provides the permission to migrate virtual machines.
|
||||
|
||||
Assigning these permissions ensures that the user can access necessary information and perform critical operations related to load balancing without granting excessive privileges. This practice helps maintain a secure and efficient ProxLB environment.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Affinity & Anti-Affinity Rules
|
||||
ProxLB provides an advanced mechanism to define affinity and anti-affinity rules, enabling precise control over virtual machine (VM) placement. These rules help manage resource distribution, improve high availability configurations, and optimize performance within a Proxmox Virtual Environment (PVE) cluster. By leveraging Proxmox’s integrated access management, ProxLB ensures that users can only define and manage rules for guests they have permission to access.
|
||||
|
||||
ProxLB implements affinity and anti-affinity rules through a tag-based system within the Proxmox web interface. Each guest (virtual machine or container) can be assigned specific tags, which then dictate its placement behavior. This method maintains a streamlined and secure approach to managing VM relationships while preserving Proxmox’s inherent permission model.
|
||||
|
||||
#### Affinity Rules
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-affinity-rules.jpg"/> Affinity rules are used to group certain VMs together, ensuring that they run on the same host whenever possible. This can be beneficial for workloads requiring low-latency communication, such as clustered databases or application servers that frequently exchange data.
|
||||
|
||||
To define an affinity rule which keeps all guests assigned to this tag together on a node, users assign a tag with the prefix `plb_affinity_$TAG`:
|
||||
|
||||
##### Example for Screenshot
|
||||
```
|
||||
plb_affinity_talos
|
||||
```
|
||||
|
||||
As a result, ProxLB will attempt to place all VMs with the `plb_affinity_web` tag on the same host (see also the attached screenshot with the same node).
|
||||
|
||||
#### Anti-Affinity Rules
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-anti-affinity-rules.jpg"/> Conversely, anti-affinity rules ensure that designated VMs do not run on the same physical host. This is particularly useful for high-availability setups, where redundancy is crucial. Ensuring that critical services are distributed across multiple hosts reduces the risk of a single point of failure.
|
||||
|
||||
To define an anti-affinity rule that ensures to not move systems within this group to the same node, users assign a tag with the prefix:
|
||||
|
||||
##### Example for Screenshot
|
||||
```
|
||||
plb_anti_affinity_ntp
|
||||
```
|
||||
|
||||
As a result, ProxLB will try to place the VMs with the `plb_anti_affinity_ntp` tag on different hosts (see also the attached screenshot with the different nodes).
|
||||
|
||||
**Note:** While this ensures that ProxLB tries distribute these VMs across different physical hosts within the Proxmox cluster this may not always work. If you have more guests attached to the group than nodes in the cluster, we still need to run them anywhere. If this case occurs, the next one with the most free resources will be selected.
|
||||
|
||||
### Affinity / Anti-Affinity Enforcing
|
||||
When a cluster is already balanced and does not require further adjustments, enabling the enforce_affinity parameter ensures that affinity and anti-affinity rules are still respected. This parameter prioritizes the placement of guest objects according to these rules, even if it leads to slight resource imbalances or increased migration overhead. Regularly reviewing and updating these rules, along with monitoring cluster performance, helps maintain optimal performance and reliability. By carefully managing these aspects, you can create a cluster environment that meets your specific needs and maintains a good balance of resources.
|
||||
|
||||
```
|
||||
balancing:
|
||||
enforce_affinity: True
|
||||
```
|
||||
|
||||
*Note: This may have impacts to the cluster. Depending on the created group matrix, the result may also be an unbalanced cluster.*
|
||||
|
||||
### Ignore VMs / CTs
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-ignore-vm-movement.jpg"/> Guests, such as VMs or CTs, can also be completely ignored. This means, they won't be affected by any migration (even when (anti-)affinity rules are enforced). To ensure a proper resource evaluation, these guests are still collected and evaluated but simply skipped for balancing actions. Another thing is the implementation. While ProxLB might have a very restricted configuration file including the file permissions, this file is only read- and writeable by the Proxmox administrators. However, we might have user and groups who want to define on their own that their systems shouldn't be moved. Therefore, these users can simpy set a specific tag to the guest object - just like the (anti)affinity rules.
|
||||
|
||||
To define a guest to be ignored from the balancing, users assign a tag with the prefix `plb_ignore_$TAG`:
|
||||
|
||||
#### Example for Screenshot
|
||||
```
|
||||
plb_ignore_dev
|
||||
```
|
||||
|
||||
As a result, ProxLB will not migrate this guest with the `plb_ignore_dev` tag to any other node.
|
||||
|
||||
**Note:** Ignored guests are really ignored. Even by enforcing affinity rules this guest will be ignored.
|
||||
|
||||
### API Loadbalancing
|
||||
ProxLB supports API loadbalancing, where one or more host objects can be defined as a list. This ensures, that you can even operator ProxLB without further changes when one or more nodes are offline or in a maintenance. When defining multiple hosts, the first reachable one will be picked.
|
||||
|
||||
```
|
||||
proxmox_api:
|
||||
hosts: ['virt01.example.com', '10.10.10.10', 'fe01::bad:code::cafe']
|
||||
```
|
||||
|
||||
### Ignore Host-Nodes or Guests
|
||||
In managing a Proxmox environment, it's often necessary to exclude certain host nodes and guests from various operations. For host nodes, this exclusion can be achieved by specifying them in the ignore_nodes parameter within the proxmox_api chapter, effectively preventing any automated processes from interacting with these nodes. Guests, on the other hand, can be ignored by assigning them a specific tag that starts with or is equal to plb_ignore, ensuring they are omitted from any automated tasks or monitoring. By implementing these configurations, administrators can fine-tune their Proxmox management to focus only on relevant nodes and guests, optimizing operational efficiency and resource allocation.
|
||||
|
||||
```
|
||||
proxmox_cluster:
|
||||
ignore_nodes: ['node01', 'node02']
|
||||
```
|
||||
|
||||
### IPv6 Support
|
||||
Yes, ProxLB fully supports IPv6.
|
||||
|
||||
### Logging / Log-Level
|
||||
ProxLB supports systemd for seamless service management on Linux distributions. To enable this, create a proxLB.service file in /etc/systemd/system/ from `service/proxlb.service` within this repository.
|
||||
|
||||
On systems without systemd, such as FreeBSD and macOS, ProxLB runs with similar configurations but logs to stdout and stderr. The logging level and verbosity can be set in the `service` section of the configuration file:
|
||||
|
||||
```
|
||||
service:
|
||||
log_level: DEBUG
|
||||
```
|
||||
|
||||
ProxLB only support the following log levels:
|
||||
* INFO
|
||||
* WARNING
|
||||
* CRITICAL
|
||||
* DEBUG
|
||||
|
||||
### Parallel Migrations
|
||||
By default, parallel migrations are deactivated. This means, that a guest object gets migrated and the migration job is being watched until the VM or CT got moved to a new node. However, this may take a lot of time and many environments are fast enough to handle the IO load for multiple guest objects. However, there are always corner cases and this depends on your setup. Parallel migrations can be enabled by setting `parallel` to `True` within the `balancing` chapter:
|
||||
|
||||
```
|
||||
balancing:
|
||||
parallel: False
|
||||
```
|
||||
|
||||
### Run as a Systemd-Service
|
||||
The proxlb systemd unit orchestrates the ProxLB application. ProxLB can be used either as a one-shot solution or run periodically, depending on the configuration specified in the daemon chapter of its configuration file.
|
||||
|
||||
```
|
||||
service:
|
||||
daemon: False
|
||||
schedule:
|
||||
interval: 12
|
||||
format: hours
|
||||
```
|
||||
|
||||
In this configuration:
|
||||
* `daemon`: False indicates that the ProxLB application is not running as a daemon and will execute as a one-shot solution.
|
||||
* `schedule`: 12 defines the interval for the schedule, specifying how often rebalancing should be done if running as a daemon.
|
||||
* `format`: Defines the given format of schedule where you can choose between `hours` or `minutes`.
|
||||
|
||||
### SSL Self-Signed Certificates
|
||||
If you are using SSL self-signed certificates or non-valid certificated in general and do not want to deal with additional trust levels, you may also disable the SSL validation. This may mostly be helpful for dev- & test labs.
|
||||
|
||||
SSL certificate validation can be disabled in the `proxmox_api` section in the config file by setting:
|
||||
```
|
||||
proxmox_api:
|
||||
ssl_verification: False
|
||||
```
|
||||
|
||||
*Note: Disabling SSL certificate validation is not recommended.*
|
||||
24
docs/99-faq.md
Normal file
24
docs/99-faq.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## Table of Contents
|
||||
|
||||
1. [GUI Integration](#gui-integration)
|
||||
- [How to install pve-proxmoxlb-service-ui package](https://github.com/gyptazy/ProxLB/issues/44)
|
||||
2. [Proxmox HA Integration](#proxmox-ha-integration)
|
||||
- [Host groups: Honour HA groups](https://github.com/gyptazy/ProxLB/issues/65)
|
||||
|
||||
### GUI Integration
|
||||
<img align="left" src="https://cdn.gyptazy.com/images/proxlb-GUI-integration.jpg"/> ProxLB can also be accessed through the Proxmox Web UI by installing the optional `pve-proxmoxlb-service-ui` package, which depends on the proxlb package. For full Web UI integration, this package must be installed on all nodes within the cluster. Once installed, a new menu item - `Rebalancing`, appears in the cluster level under the HA section. Once installed, it offers two key functionalities:
|
||||
* Rebalancing VM workloads
|
||||
* Migrate VM workloads away from a defined node (e.g. maintenance preparation)
|
||||
|
||||
**Note:** This package is currently discontinued and will be readded at a later time. See also: [#44: How to install pve-proxmoxlb-service-ui package](https://github.com/gyptazy/ProxLB/issues/44).
|
||||
|
||||
### Proxmox HA Integration
|
||||
Proxmox HA (High Availability) groups are designed to ensure that virtual machines (VMs) remain running within a Proxmox cluster. HA groups define specific rules for where VMs should be started or migrated in case of node failures, ensuring minimal downtime and automatic recovery.
|
||||
|
||||
However, when used in conjunction with ProxLB, the built-in load balancer for Proxmox, conflicts can arise. ProxLB operates with its own logic for workload distribution, taking into account affinity and anti-affinity rules. While it effectively balances guest workloads, it may re-shift and redistribute VMs in a way that does not align with HA group constraints, potentially leading to unsuitable placements.
|
||||
|
||||
Due to these conflicts, it is currently not recommended to use both HA groups and ProxLB simultaneously. The interaction between the two mechanisms can lead to unexpected behavior, where VMs might not adhere to HA group rules after being moved by ProxLB.
|
||||
|
||||
A solution to improve compatibility between HA groups and ProxLB is under evaluation, aiming to ensure that both features can work together without disrupting VM placement strategies.
|
||||
|
||||
See also: [#65: Host groups: Honour HA groups](https://github.com/gyptazy/ProxLB/issues/65).
|
||||
6
misc/01-replace-version.sh
Normal file
6
misc/01-replace-version.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
VERSION="1.1.1"
|
||||
|
||||
sed -i "s/^__version__ = .*/__version__ = \"$VERSION\"/" "proxlb/utils/version.py"
|
||||
sed -i "s/version=\"[0-9]*\.[0-9]*\.[0-9]*\"/version=\"$VERSION\"/" setup.py
|
||||
echo "OK: Versions have been sucessfully set to $VERSION"
|
||||
4
misc/02-create-changelog.sh
Normal file
4
misc/02-create-changelog.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
git clone https://github.com/gyptazy/changelog-fragments-creator.git
|
||||
./changelog-fragments-creator/changelog-creator -f .changelogs/ -o CHANGELOG.md
|
||||
echo "Created changelog file"
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
sudo apt-get install rpm cmake git make python3-yaml
|
||||
|
||||
git clone https://github.com/gyptazy/changelog-fragments-creator.git
|
||||
./changelog-fragments-creator/changelog-creator -f ../.changelogs/ -o ../CHANGELOG.md
|
||||
mkdir packages
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cpack -G DEB .
|
||||
cpack -G RPM .
|
||||
cp *.deb ../packages
|
||||
cp *.rpm ../packages
|
||||
cd ..
|
||||
rm -rf build
|
||||
echo "Packages created. Packages can be found in directory: packages"
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
git clone https://github.com/gyptazy/changelog-fragments-creator.git
|
||||
./changelog-fragments-creator/changelog-creator -f ../.changelogs/ -o ../CHANGELOG.md
|
||||
echo "Created changelog file"
|
||||
@@ -1,41 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(proxmox-rebalancing-service VERSION 0.9.9)
|
||||
|
||||
install(PROGRAMS ../proxlb DESTINATION /bin)
|
||||
install(FILES ../proxlb.conf DESTINATION /etc/proxlb)
|
||||
install(FILES proxlb.service DESTINATION /etc/systemd/system)
|
||||
|
||||
# General
|
||||
set(CPACK_PACKAGE_NAME "proxlb")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/../README.md")
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Florian Paul Azim <gyptazy> Hoberg <gyptazy@gyptazy.ch>")
|
||||
set(CPACK_PACKAGE_CONTACT "Florian Paul Azim Hoberg <gyptazy@gyptazy.ch>")
|
||||
set(CPACK_PACKAGE_VENDOR "gyptazy")
|
||||
|
||||
# RPM packaging
|
||||
set(CPACK_PACKAGE_VERSION ${CMAKE_PROJECT_VERSION})
|
||||
set(CPACK_GENERATOR "RPM")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "amd64")
|
||||
set(CPACK_RPM_PACKAGE_SUMMARY "ProxLB Rebalancing VM workloads within Proxmox clusters.")
|
||||
set(CPACK_RPM_PACKAGE_DESCRIPTION "ProxLB Rebalancing VM workloads within Proxmox clusters.")
|
||||
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/changelog_redhat")
|
||||
set(CPACK_PACKAGE_RELEASE 1)
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "GPL 3.0")
|
||||
set(CPACK_RPM_PACKAGE_REQUIRES "python >= 3.2.0")
|
||||
|
||||
# DEB packaging
|
||||
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
|
||||
set(CPACK_DEBIAN_PACKAGE_SUMMARY "ProxLB Rebalancing VM workloads within Proxmox clusters.")
|
||||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "ProxLB Rebalancing VM workloads within Proxmox clusters.")
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/changelog_debian")
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3")
|
||||
set(CPACK_DEBIAN_PACKAGE_LICENSE "GPL 3.0")
|
||||
|
||||
|
||||
# Install
|
||||
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst")
|
||||
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/postinst")
|
||||
include(CPack)
|
||||
@@ -1,14 +0,0 @@
|
||||
## Build packages
|
||||
Building the packages requires cmake, deb and rpm.
|
||||
For building packages, simly run the following commands:
|
||||
|
||||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cpack -G RPM .
|
||||
cpack -G DEB .
|
||||
```
|
||||
|
||||
When running on Debian/Ubuntu you can directly call `01_package.sh`
|
||||
to create your own packages.
|
||||
@@ -1,5 +0,0 @@
|
||||
proxlb (0.9.0) unstable; urgency=low
|
||||
|
||||
* Initial release of ProxLB.
|
||||
|
||||
-- Florian Paul Azim Hoberg <gyptazy@gyptazy.ch> Sun, 07 Jul 2024 05:38:41 -0200
|
||||
@@ -1,2 +0,0 @@
|
||||
* Sun Jul 07 2024 Florian Paul Azim Hoberg <gyptazy@gyptazy.ch>
|
||||
- Initial release of ProxLB.
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
useradd -m plb
|
||||
chown plb:plb /etc/proxlb/proxlb.conf
|
||||
chmod 600 /etc/proxlb/proxlb.conf
|
||||
systemctl daemon-reload
|
||||
@@ -1,6 +0,0 @@
|
||||
[Unit]
|
||||
Description=ProxLB - Rebalance VM workloads
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/proxlb -c /etc/proxlb/proxlb.conf
|
||||
User=plb
|
||||
599
proxlb
599
proxlb
@@ -1,599 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ProxLB
|
||||
# ProxLB (re)balances VM workloads across nodes in Proxmox clusters.
|
||||
# ProxLB obtains current metrics from all nodes within the cluster for
|
||||
# further auto balancing by memory, disk or cpu and rebalances the VMs
|
||||
# over all available nodes in a cluster by having an equal resource usage.
|
||||
# Copyright (C) 2024 Florian Paul Azim Hoberg @gyptazy <gyptazy@gyptazy.ch>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import argparse
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
try:
|
||||
import proxmoxer
|
||||
_imports = True
|
||||
except ImportError as error:
|
||||
_imports = False
|
||||
import random
|
||||
import re
|
||||
import requests
|
||||
import sys
|
||||
import time
|
||||
import urllib3
|
||||
|
||||
|
||||
# Constants
|
||||
__appname__ = "ProxLB"
|
||||
__version__ = "0.9.9"
|
||||
__author__ = "Florian Paul Azim Hoberg <gyptazy@gyptazy.ch> @gyptazy"
|
||||
__errors__ = False
|
||||
|
||||
|
||||
# Classes
|
||||
## Logging class
|
||||
class SystemdHandler(logging.Handler):
|
||||
""" Class to handle logging options. """
|
||||
PREFIX = {
|
||||
logging.CRITICAL: "<2> " + __appname__ + ": ",
|
||||
logging.ERROR: "<3> " + __appname__ + ": ",
|
||||
logging.WARNING: "<4> " + __appname__ + ": ",
|
||||
logging.INFO: "<6> " + __appname__ + ": ",
|
||||
logging.DEBUG: "<7> " + __appname__ + ": ",
|
||||
logging.NOTSET: "<7 " + __appname__ + ": ",
|
||||
}
|
||||
|
||||
def __init__(self, stream=sys.stdout):
|
||||
self.stream = stream
|
||||
logging.Handler.__init__(self)
|
||||
|
||||
def emit(self, record):
|
||||
try:
|
||||
msg = self.PREFIX[record.levelno] + self.format(record) + "\n"
|
||||
self.stream.write(msg)
|
||||
self.stream.flush()
|
||||
except Exception:
|
||||
self.handleError(record)
|
||||
|
||||
|
||||
# Functions
|
||||
def initialize_logger(log_level, log_handler):
|
||||
""" Initialize ProxLB logging handler. """
|
||||
info_prefix = 'Info: [logger]:'
|
||||
|
||||
root_logger = logging.getLogger()
|
||||
root_logger.setLevel(log_level)
|
||||
root_logger.addHandler(SystemdHandler())
|
||||
logging.info(f'{info_prefix} Logger got initialized.')
|
||||
|
||||
|
||||
def pre_validations(config_path):
|
||||
""" Run pre-validations as sanity checks. """
|
||||
info_prefix = 'Info: [pre-validations]:'
|
||||
|
||||
__validate_imports()
|
||||
__validate_config_file(config_path)
|
||||
logging.info(f'{info_prefix} All pre-validations done.')
|
||||
|
||||
|
||||
def post_validations():
|
||||
""" Run post-validations as sanity checks. """
|
||||
error_prefix = 'Error: [post-validations]:'
|
||||
info_prefix = 'Info: [post-validations]:'
|
||||
|
||||
if __errors__:
|
||||
logging.critical(f'{error_prefix} Not all post-validations succeeded. Please validate!')
|
||||
else:
|
||||
logging.info(f'{info_prefix} All post-validations succeeded.')
|
||||
|
||||
|
||||
def validate_daemon(daemon, schedule):
|
||||
""" Validate if ProxLB runs as a daemon. """
|
||||
info_prefix = 'Info: [daemon]:'
|
||||
|
||||
if bool(int(daemon)):
|
||||
logging.info(f'{info_prefix} Running in daemon mode. Next run in {schedule} hours.')
|
||||
time.sleep(int(schedule) * 60)
|
||||
else:
|
||||
logging.info(f'{info_prefix} Not running in daemon mode. Quitting.')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def __validate_imports():
|
||||
""" Validate if all Python imports succeeded. """
|
||||
error_prefix = 'Error: [python-imports]:'
|
||||
info_prefix = 'Info: [python-imports]:'
|
||||
|
||||
if not _imports:
|
||||
logging.critical(f'{error_prefix} Could not import all dependencies. Please install "proxmoxer".')
|
||||
sys.exit(2)
|
||||
else:
|
||||
logging.info(f'{info_prefix} All required dependencies were imported.')
|
||||
|
||||
|
||||
def __validate_config_file(config_path):
|
||||
""" Validate if all Python imports succeeded. """
|
||||
error_prefix = 'Error: [config]:'
|
||||
info_prefix = 'Info: [config]:'
|
||||
|
||||
if not os.path.isfile(config_path):
|
||||
logging.critical(f'{error_prefix} Could not find config file in: {config_path}.')
|
||||
sys.exit(2)
|
||||
else:
|
||||
logging.info(f'{info_prefix} Configuration file loaded from: {config_path}.')
|
||||
|
||||
|
||||
def initialize_args():
|
||||
""" Initialize given arguments for ProxLB. """
|
||||
argparser = argparse.ArgumentParser(description='ProxLB')
|
||||
argparser.add_argument('-c', '--config', type=str, help='Path to config file.')
|
||||
return argparser.parse_args()
|
||||
|
||||
|
||||
def initialize_config_path(app_args):
|
||||
""" Initialize path to ProxLB config file. """
|
||||
info_prefix = 'Info: [config]:'
|
||||
|
||||
config_path = app_args.config
|
||||
if app_args.config is None:
|
||||
config_path = '/etc/proxlb/proxlb.conf'
|
||||
logging.info(f'{info_prefix} No config file provided. Falling back to: {config_path}.')
|
||||
else:
|
||||
logging.info(f'{info_prefix} Using config file: {config_path}.')
|
||||
return config_path
|
||||
|
||||
|
||||
def initialize_config_options(config_path):
|
||||
""" Read configuration from given config file for ProxLB. """
|
||||
error_prefix = 'Error: [config]:'
|
||||
info_prefix = 'Info: [config]:'
|
||||
|
||||
try:
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_path)
|
||||
# Proxmox config
|
||||
proxmox_api_host = config['proxmox']['api_host']
|
||||
proxmox_api_user = config['proxmox']['api_user']
|
||||
proxmox_api_pass = config['proxmox']['api_pass']
|
||||
proxmox_api_ssl_v = config['proxmox']['verify_ssl']
|
||||
# Balancing
|
||||
balancing_method = config['balancing'].get('method', 'memory')
|
||||
ignore_nodes = config['balancing'].get('ignore_nodes', None)
|
||||
ignore_vms = config['balancing'].get('ignore_vms', None)
|
||||
# Service
|
||||
daemon = config['service'].get('daemon', 1)
|
||||
schedule = config['service'].get('schedule', 24)
|
||||
except configparser.NoSectionError:
|
||||
logging.critical(f'{error_prefix} Could not find the required section.')
|
||||
sys.exit(2)
|
||||
except configparser.ParsingError:
|
||||
logging.critical(f'{error_prefix} Unable to parse the config file.')
|
||||
sys.exit(2)
|
||||
except KeyError:
|
||||
logging.critical(f'{error_prefix} Could not find the required options in config file.')
|
||||
sys.exit(2)
|
||||
|
||||
logging.info(f'{info_prefix} Configuration file loaded.')
|
||||
return proxmox_api_host, proxmox_api_user, proxmox_api_pass, proxmox_api_ssl_v, balancing_method, \
|
||||
ignore_nodes, ignore_vms, daemon, schedule
|
||||
|
||||
|
||||
def api_connect(proxmox_api_host, proxmox_api_user, proxmox_api_pass, proxmox_api_ssl_v):
|
||||
""" Connect and authenticate to the Proxmox remote API. """
|
||||
error_prefix = 'Error: [api-connection]:'
|
||||
warn_prefix = 'Warning: [api-connection]:'
|
||||
info_prefix = 'Info: [api-connection]:'
|
||||
proxmox_api_ssl_v = bool(int(proxmox_api_ssl_v))
|
||||
|
||||
if not proxmox_api_ssl_v:
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
logging.warning(f'{warn_prefix} API connection does not verify SSL certificate.')
|
||||
|
||||
try:
|
||||
api_object = proxmoxer.ProxmoxAPI(proxmox_api_host, user=proxmox_api_user, password=proxmox_api_pass, verify_ssl=proxmox_api_ssl_v)
|
||||
except urllib3.exceptions.NameResolutionError:
|
||||
logging.critical(f'{error_prefix} Could not resolve the given host: {proxmox_api_host}.')
|
||||
sys.exit(2)
|
||||
except requests.exceptions.ConnectTimeout:
|
||||
logging.critical(f'{error_prefix} Connection time out to host: {proxmox_api_host}.')
|
||||
sys.exit(2)
|
||||
except requests.exceptions.SSLError:
|
||||
logging.critical(f'{error_prefix} SSL certificate verification failed for host: {proxmox_api_host}.')
|
||||
sys.exit(2)
|
||||
|
||||
logging.info(f'{info_prefix} API connection succeeded to host: {proxmox_api_host}.')
|
||||
return api_object
|
||||
|
||||
|
||||
def get_node_statistics(api_object, ignore_nodes):
|
||||
""" Get statistics of cpu, memory and disk for each node in the cluster. """
|
||||
info_prefix = 'Info: [node-statistics]:'
|
||||
node_statistics = {}
|
||||
ignore_nodes_list = ignore_nodes.split(',')
|
||||
|
||||
for node in api_object.nodes.get():
|
||||
if node['status'] == 'online' and node['node'] not in ignore_nodes_list:
|
||||
node_statistics[node['node']] = {}
|
||||
node_statistics[node['node']]['cpu_total'] = node['maxcpu']
|
||||
node_statistics[node['node']]['cpu_used'] = node['cpu']
|
||||
node_statistics[node['node']]['cpu_free'] = int(node['maxcpu']) - int(node['cpu'])
|
||||
node_statistics[node['node']]['cpu_free_percent'] = int((node_statistics[node['node']]['cpu_free']) / int(node['maxcpu']) * 100)
|
||||
node_statistics[node['node']]['memory_total'] = node['maxmem']
|
||||
node_statistics[node['node']]['memory_used'] = node['mem']
|
||||
node_statistics[node['node']]['memory_free'] = int(node['maxmem']) - int(node['mem'])
|
||||
node_statistics[node['node']]['memory_free_percent'] = int((node_statistics[node['node']]['memory_free']) / int(node['maxmem']) * 100)
|
||||
node_statistics[node['node']]['disk_total'] = node['maxdisk']
|
||||
node_statistics[node['node']]['disk_used'] = node['disk']
|
||||
node_statistics[node['node']]['disk_free'] = int(node['maxdisk']) - int(node['disk'])
|
||||
node_statistics[node['node']]['disk_free_percent'] = int((node_statistics[node['node']]['disk_free']) / int(node['maxdisk']) * 100)
|
||||
logging.info(f'{info_prefix} Added node {node["node"]}.')
|
||||
|
||||
logging.info(f'{info_prefix} Created node statistics.')
|
||||
return node_statistics
|
||||
|
||||
|
||||
def get_vm_statistics(api_object, ignore_vms):
|
||||
""" Get statistics of cpu, memory and disk for each vm in the cluster. """
|
||||
info_prefix = 'Info: [vm-statistics]:'
|
||||
vm_statistics = {}
|
||||
ignore_vms_list = ignore_vms.split(',')
|
||||
group_include = None
|
||||
group_exclude = None
|
||||
vm_ignore = None
|
||||
vm_ignore_wildcard = False
|
||||
|
||||
# Wildcard support: Initially validate if we need to honour
|
||||
# any wildcards within the vm_ignore list.
|
||||
vm_ignore_wildcard = __validate_ignore_vm_wildcard(ignore_vms)
|
||||
|
||||
for node in api_object.nodes.get():
|
||||
for vm in api_object.nodes(node['node']).qemu.get():
|
||||
|
||||
# Get the VM tags from API.
|
||||
vm_tags = __get_vm_tags(api_object, node, vm['vmid'])
|
||||
if vm_tags is not None:
|
||||
group_include, group_exclude, vm_ignore = __get_proxlb_groups(vm_tags)
|
||||
|
||||
# Get wildcard match for VMs to ignore if a wildcard pattern was
|
||||
# previously found. Wildcards may slow down the task when using
|
||||
# many patterns in the ignore list. Therefore, run this only if
|
||||
# a wildcard pattern was found. We also do not need to validate
|
||||
# this if the VM is already being ignored by a defined tag.
|
||||
if vm_ignore_wildcard and not vm_ignore:
|
||||
vm_ignore = __check_vm_name_wildcard_pattern(vm['name'], ignore_vms_list)
|
||||
|
||||
if vm['status'] == 'running' and vm['name'] not in ignore_vms_list and not vm_ignore:
|
||||
vm_statistics[vm['name']] = {}
|
||||
vm_statistics[vm['name']]['group_include'] = group_include
|
||||
vm_statistics[vm['name']]['group_exclude'] = group_exclude
|
||||
vm_statistics[vm['name']]['cpu_total'] = vm['cpus']
|
||||
vm_statistics[vm['name']]['cpu_used'] = vm['cpu']
|
||||
vm_statistics[vm['name']]['memory_total'] = vm['maxmem']
|
||||
vm_statistics[vm['name']]['memory_used'] = vm['mem']
|
||||
vm_statistics[vm['name']]['disk_total'] = vm['maxdisk']
|
||||
vm_statistics[vm['name']]['disk_used'] = vm['disk']
|
||||
vm_statistics[vm['name']]['vmid'] = vm['vmid']
|
||||
vm_statistics[vm['name']]['node_parent'] = node['node']
|
||||
# Rebalancing node will be overwritten after calculations.
|
||||
# If the vm stays on the node, it will be removed at a
|
||||
# later time.
|
||||
vm_statistics[vm['name']]['node_rebalance'] = node['node']
|
||||
logging.info(f'{info_prefix} Added vm {vm["name"]}.')
|
||||
|
||||
logging.info(f'{info_prefix} Created VM statistics.')
|
||||
return vm_statistics
|
||||
|
||||
|
||||
def __validate_ignore_vm_wildcard(ignore_vms):
|
||||
""" Validate if a wildcard is used for ignored VMs. """
|
||||
if '*' in ignore_vms:
|
||||
return True
|
||||
|
||||
|
||||
def __check_vm_name_wildcard_pattern(vm_name, ignore_vms_list):
|
||||
""" Validate if the VM name is in the ignore list pattern included. """
|
||||
for ignore_vm in ignore_vms_list:
|
||||
if '*' in ignore_vm:
|
||||
if ignore_vm[:-1] in vm_name:
|
||||
return True
|
||||
|
||||
|
||||
def __get_vm_tags(api_object, node, vmid):
|
||||
""" Get a comment for a VM from a given VMID. """
|
||||
info_prefix = 'Info: [api-get-vm-tags]:'
|
||||
|
||||
vm_config = api_object.nodes(node['node']).qemu(vmid).config.get()
|
||||
logging.info(f'{info_prefix} Got VM comment from API.')
|
||||
return vm_config.get('tags', None)
|
||||
|
||||
|
||||
def __get_proxlb_groups(vm_tags):
|
||||
""" Get ProxLB related include and exclude groups. """
|
||||
info_prefix = 'Info: [api-get-vm-include-exclude-tags]:'
|
||||
group_include = None
|
||||
group_exclude = None
|
||||
vm_ignore = None
|
||||
|
||||
group_list = re.split(";", vm_tags)
|
||||
for group in group_list:
|
||||
|
||||
if group.startswith('plb_include_'):
|
||||
logging.info(f'{info_prefix} Got PLB include group.')
|
||||
group_include = group
|
||||
|
||||
if group.startswith('plb_exclude_'):
|
||||
logging.info(f'{info_prefix} Got PLB include group.')
|
||||
group_exclude = group
|
||||
|
||||
if group.startswith('plb_ignore_vm'):
|
||||
logging.info(f'{info_prefix} Got PLB ignore group.')
|
||||
vm_ignore = True
|
||||
|
||||
return group_include, group_exclude, vm_ignore
|
||||
|
||||
|
||||
def balancing_calculations(balancing_method, node_statistics, vm_statistics):
|
||||
""" Calculate re-balancing of VMs on present nodes across the cluster. """
|
||||
info_prefix = 'Info: [rebalancing-calculator]:'
|
||||
balanciness = 10
|
||||
rebalance = False
|
||||
processed_vms = []
|
||||
rebalance = True
|
||||
emergency_counter = 0
|
||||
|
||||
# Validate for a supported balancing method.
|
||||
__validate_balancing_method(balancing_method)
|
||||
|
||||
# Rebalance VMs with the highest resource usage to a new
|
||||
# node until reaching the desired balanciness.
|
||||
while rebalance and emergency_counter < 10000:
|
||||
emergency_counter = emergency_counter + 1
|
||||
rebalance = __validate_balanciness(balanciness, balancing_method, node_statistics)
|
||||
|
||||
if rebalance:
|
||||
resource_highest_used_resources_vm, processed_vms = __get_most_used_resources_vm(balancing_method, vm_statistics, processed_vms)
|
||||
resource_highest_free_resources_node = __get_most_free_resources_node(balancing_method, node_statistics)
|
||||
node_statistics, vm_statistics = __update_resource_statistics(resource_highest_used_resources_vm, resource_highest_free_resources_node,
|
||||
vm_statistics, node_statistics, balancing_method)
|
||||
|
||||
# Honour groupings for include and exclude groups for rebalancing VMs.
|
||||
node_statistics, vm_statistics = __get_vm_tags_include_groups(vm_statistics, node_statistics, balancing_method)
|
||||
node_statistics, vm_statistics = __get_vm_tags_exclude_groups(vm_statistics, node_statistics, balancing_method)
|
||||
|
||||
# Remove VMs that are not being relocated.
|
||||
vms_to_remove = [vm_name for vm_name, vm_info in vm_statistics.items() if 'node_rebalance' in vm_info and vm_info['node_rebalance'] == vm_info.get('node_parent')]
|
||||
for vm_name in vms_to_remove:
|
||||
del vm_statistics[vm_name]
|
||||
|
||||
logging.info(f'{info_prefix} Balancing calculations done.')
|
||||
return node_statistics, vm_statistics
|
||||
|
||||
|
||||
def __validate_balancing_method(balancing_method):
|
||||
""" Validate for valid and supported balancing method. """
|
||||
error_prefix = 'Error: [balancing-method-validation]:'
|
||||
info_prefix = 'Info: [balancing-method-validation]]:'
|
||||
|
||||
if balancing_method not in ['memory', 'disk', 'cpu']:
|
||||
logging.error(f'{error_prefix} Invalid balancing method: {balancing_method}')
|
||||
sys.exit(2)
|
||||
else:
|
||||
logging.info(f'{info_prefix} Valid balancing method: {balancing_method}')
|
||||
|
||||
|
||||
def __validate_balanciness(balanciness, balancing_method, node_statistics):
|
||||
""" Validate for balanciness to ensure further rebalancing is needed. """
|
||||
info_prefix = 'Info: [balanciness-validation]]:'
|
||||
node_memory_free_percent_list = []
|
||||
|
||||
for node_name, node_info in node_statistics.items():
|
||||
node_memory_free_percent_list.append(node_info[f'{balancing_method}_free_percent'])
|
||||
|
||||
node_memory_free_percent_list_sorted = sorted(node_memory_free_percent_list)
|
||||
node_lowest_percent = node_memory_free_percent_list_sorted[0]
|
||||
node_highest_percent = node_memory_free_percent_list_sorted[-1]
|
||||
|
||||
if (node_lowest_percent + balanciness) < node_highest_percent:
|
||||
logging.info(f'{info_prefix} Rebalancing is for {balancing_method} is needed.')
|
||||
return True
|
||||
else:
|
||||
logging.info(f'{info_prefix} Rebalancing is for {balancing_method} is not needed.')
|
||||
return False
|
||||
|
||||
|
||||
def __get_most_used_resources_vm(balancing_method, vm_statistics, processed_vms):
|
||||
""" Get and return the most used resources of a VM by the defined balancing method. """
|
||||
if balancing_method == 'memory':
|
||||
vm = max(vm_statistics.items(), key=lambda item: item[1]['memory_used'] if item[0] not in processed_vms else -float('inf'))
|
||||
processed_vms.append(vm[0])
|
||||
return vm, processed_vms
|
||||
if balancing_method == 'disk':
|
||||
vm = max(vm_statistics.items(), key=lambda item: item[1]['disk_used'] if item[0] not in processed_vms else -float('inf'))
|
||||
processed_vms.append(vm[0])
|
||||
return vm, processed_vms
|
||||
if balancing_method == 'cpu':
|
||||
vm = max(vm_statistics.items(), key=lambda item: item[1]['cpu_used'] if item[0] not in processed_vms else -float('inf'))
|
||||
processed_vms.append(vm[0])
|
||||
return vm, processed_vms
|
||||
|
||||
|
||||
def __get_most_free_resources_node(balancing_method, node_statistics):
|
||||
""" Get and return the most free resources of a node by the defined balancing method. """
|
||||
if balancing_method == 'memory':
|
||||
return max(node_statistics.items(), key=lambda item: item[1]['memory_free'])
|
||||
if balancing_method == 'disk':
|
||||
return max(node_statistics.items(), key=lambda item: item[1]['disk_free'])
|
||||
if balancing_method == 'cpu':
|
||||
return max(node_statistics.items(), key=lambda item: item[1]['cpu_free'])
|
||||
|
||||
|
||||
def __update_resource_statistics(resource_highest_used_resources_vm, resource_highest_free_resources_node, vm_statistics, node_statistics, balancing_method):
|
||||
""" Update VM and node resource statistics. """
|
||||
info_prefix = 'Info: [rebalancing-resource-statistics-update]:'
|
||||
|
||||
if resource_highest_used_resources_vm[1]['node_parent'] != resource_highest_free_resources_node[0]:
|
||||
vm_name = resource_highest_used_resources_vm[0]
|
||||
vm_node_parent = resource_highest_used_resources_vm[1]['node_parent']
|
||||
vm_node_rebalance = resource_highest_free_resources_node[0]
|
||||
vm_resource_used = vm_statistics[resource_highest_used_resources_vm[0]][f'{balancing_method}_used']
|
||||
|
||||
# Update dictionaries for new values
|
||||
# Assign new rebalance node to vm
|
||||
vm_statistics[vm_name]['node_rebalance'] = vm_node_rebalance
|
||||
|
||||
# Recalculate values for nodes
|
||||
## Add freed resources to old parent node
|
||||
node_statistics[vm_node_parent][f'{balancing_method}_used'] = int(node_statistics[vm_node_parent][f'{balancing_method}_used']) - int(vm_resource_used)
|
||||
node_statistics[vm_node_parent][f'{balancing_method}_free'] = int(node_statistics[vm_node_parent][f'{balancing_method}_free']) + int(vm_resource_used)
|
||||
node_statistics[vm_node_parent][f'{balancing_method}_free_percent'] = int(int(node_statistics[vm_node_parent][f'{balancing_method}_free']) / int(node_statistics[vm_node_parent][f'{balancing_method}_total']) * 100)
|
||||
|
||||
## Removed newly allocated resources to new rebalanced node
|
||||
node_statistics[vm_node_rebalance][f'{balancing_method}_used'] = int(node_statistics[vm_node_rebalance][f'{balancing_method}_used']) + int(vm_resource_used)
|
||||
node_statistics[vm_node_rebalance][f'{balancing_method}_free'] = int(node_statistics[vm_node_rebalance][f'{balancing_method}_free']) - int(vm_resource_used)
|
||||
node_statistics[vm_node_rebalance][f'{balancing_method}_free_percent'] = int(int(node_statistics[vm_node_rebalance][f'{balancing_method}_free']) / int(node_statistics[vm_node_rebalance][f'{balancing_method}_total']) * 100)
|
||||
|
||||
logging.info(f'{info_prefix} Updated VM and node statistics.')
|
||||
return node_statistics, vm_statistics
|
||||
|
||||
|
||||
def __get_vm_tags_include_groups(vm_statistics, node_statistics, balancing_method):
|
||||
""" Get VMs tags for include groups. """
|
||||
info_prefix = 'Info: [rebalancing-tags-group-include]:'
|
||||
tags_include_vms = {}
|
||||
processed_vm = []
|
||||
|
||||
# Create groups of tags with belongings hosts.
|
||||
for vm_name, vm_values in vm_statistics.items():
|
||||
if vm_values.get('group_include', None):
|
||||
if not tags_include_vms.get(vm_values['group_include'], None):
|
||||
tags_include_vms[vm_values['group_include']] = [vm_name]
|
||||
else:
|
||||
tags_include_vms[vm_values['group_include']] = tags_include_vms[vm_values['group_include']] + [vm_name]
|
||||
|
||||
# Update the VMs to the corresponding node to their group assignments.
|
||||
for group, vm_names in tags_include_vms.items():
|
||||
# Do not take care of tags that have only a single host included.
|
||||
if len(vm_names) < 2:
|
||||
logging.info(f'{info_prefix} Only one host in group assignment.')
|
||||
return node_statistics, vm_statistics
|
||||
|
||||
vm_node_rebalance = False
|
||||
logging.info(f'{info_prefix} Create include groups of VM hosts.')
|
||||
for vm_name in vm_names:
|
||||
if vm_name not in processed_vm:
|
||||
if not vm_node_rebalance:
|
||||
vm_node_rebalance = vm_statistics[vm_name]['node_rebalance']
|
||||
else:
|
||||
_mocked_vm_object = (vm_name, vm_statistics[vm_name])
|
||||
node_statistics, vm_statistics = __update_resource_statistics(_mocked_vm_object, [vm_node_rebalance],
|
||||
vm_statistics, node_statistics, balancing_method)
|
||||
processed_vm.append(vm_name)
|
||||
|
||||
return node_statistics, vm_statistics
|
||||
|
||||
|
||||
def __get_vm_tags_exclude_groups(vm_statistics, node_statistics, balancing_method):
|
||||
""" Get VMs tags for exclude groups. """
|
||||
info_prefix = 'Info: [rebalancing-tags-group-exclude]:'
|
||||
tags_exclude_vms = {}
|
||||
processed_vm = []
|
||||
|
||||
# Create groups of tags with belongings hosts.
|
||||
for vm_name, vm_values in vm_statistics.items():
|
||||
if vm_values.get('group_include', None):
|
||||
if not tags_exclude_vms.get(vm_values['group_include'], None):
|
||||
tags_exclude_vms[vm_values['group_include']] = [vm_name]
|
||||
else:
|
||||
tags_exclude_vms[vm_values['group_include']] = tags_exclude_vms[vm_values['group_include']] + [vm_name]
|
||||
|
||||
# Update the VMs to the corresponding node to their group assignments.
|
||||
for group, vm_names in tags_exclude_vms.items():
|
||||
# Do not take care of tags that have only a single host included.
|
||||
if len(vm_names) < 2:
|
||||
logging.info(f'{info_prefix} Only one host in group assignment.')
|
||||
return node_statistics, vm_statistics
|
||||
|
||||
vm_node_rebalance = False
|
||||
logging.info(f'{info_prefix} Create exclude groups of VM hosts.')
|
||||
for vm_name in vm_names:
|
||||
if vm_name not in processed_vm:
|
||||
if not vm_node_rebalance:
|
||||
random_node = vm_statistics[vm_name]['node_parent']
|
||||
# Get a random node and make sure that it is not by accident the
|
||||
# currently assigned one.
|
||||
while random_node == vm_statistics[vm_name]['node_parent']:
|
||||
random_node = random.choice(list(node_statistics.keys()))
|
||||
else:
|
||||
_mocked_vm_object = (vm_name, vm_statistics[vm_name])
|
||||
node_statistics, vm_statistics = __update_resource_statistics(_mocked_vm_object, [random_node],
|
||||
vm_statistics, node_statistics, balancing_method)
|
||||
processed_vm.append(vm_name)
|
||||
|
||||
return node_statistics, vm_statistics
|
||||
|
||||
|
||||
def run_vm_rebalancing(api_object, vm_statistics_rebalanced):
|
||||
""" Run rebalancing of vms to new nodes in cluster. """
|
||||
error_prefix = 'Error: [rebalancing-executor]:'
|
||||
info_prefix = 'Info: [rebalancing-executor]:'
|
||||
|
||||
logging.info(f'{info_prefix} Starting to rebalance vms to their new nodes.')
|
||||
for vm, value in vm_statistics_rebalanced.items():
|
||||
|
||||
try:
|
||||
logging.info(f'{info_prefix} Rebalancing vm {vm} from node {value["node_parent"]} to node {value["node_rebalance"]}.')
|
||||
api_object.nodes(value['node_parent']).qemu(value['vmid']).migrate().post(target=value['node_rebalance'],online=1)
|
||||
except proxmoxer.core.ResourceException as error_resource:
|
||||
__errors__ = True
|
||||
logging.critical(f'{error_prefix} {error_resource}')
|
||||
|
||||
|
||||
def main():
|
||||
""" Run ProxLB for balancing VM workloads across a Proxmox cluster. """
|
||||
# Initialize PAS.
|
||||
initialize_logger('CRITICAL', 'SystemdHandler()')
|
||||
app_args = initialize_args()
|
||||
config_path = initialize_config_path(app_args)
|
||||
pre_validations(config_path)
|
||||
|
||||
# Parse global config
|
||||
proxmox_api_host, proxmox_api_user, proxmox_api_pass, proxmox_api_ssl_v, balancing_method, \
|
||||
ignore_nodes, ignore_vms, daemon, schedule = initialize_config_options(config_path)
|
||||
|
||||
while True:
|
||||
# API Authentication.
|
||||
api_object = api_connect(proxmox_api_host, proxmox_api_user, proxmox_api_pass, proxmox_api_ssl_v)
|
||||
|
||||
# Get metric & statistics for vms and nodes.
|
||||
node_statistics = get_node_statistics(api_object, ignore_nodes)
|
||||
vm_statistics = get_vm_statistics(api_object, ignore_vms)
|
||||
|
||||
# Calculate rebalancing of vms.
|
||||
node_statistics_rebalanced, vm_statistics_rebalanced = balancing_calculations(balancing_method, node_statistics, vm_statistics)
|
||||
|
||||
# Rebalance vms to new nodes within the cluster.
|
||||
run_vm_rebalancing(api_object, vm_statistics_rebalanced)
|
||||
|
||||
# Validate for any errors
|
||||
post_validations()
|
||||
|
||||
# Validate daemon service
|
||||
validate_daemon(daemon, schedule)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
12
proxlb.conf
12
proxlb.conf
@@ -1,12 +0,0 @@
|
||||
[proxmox]
|
||||
api_host: hypervisor01.gyptazy.ch
|
||||
api_user: root@pam
|
||||
api_pass: FooBar
|
||||
verify_ssl: 1
|
||||
[balancing]
|
||||
method: memory
|
||||
ignore_nodes: dummynode01,dummynode02
|
||||
ignore_vms: testvm01,testvm02
|
||||
[service]
|
||||
daemon: 1
|
||||
schedule: 24
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user