Added lookup_label parameter
This commit is contained in:
parent
3bea967273
commit
2ef8dfecb9
3 changed files with 8 additions and 1 deletions
|
|
@ -37,6 +37,7 @@ The environment variables will setup the HAProxy.
|
||||||
| Environment Variable | Description |
|
| Environment Variable | Description |
|
||||||
|----------------------|-------------------------------------------------------------------------------|
|
|----------------------|-------------------------------------------------------------------------------|
|
||||||
| DISCOVER | How `haproxy.cfg` will be created: `static`, `docker` or `swarm` |
|
| DISCOVER | How `haproxy.cfg` will be created: `static`, `docker` or `swarm` |
|
||||||
|
| LOOKUP_LABEL | (Optional) The key will search to match resources. Default: `easyhaproxy`. |
|
||||||
| HAPROXY_USERNAME | (Optional) The HAProxy username to the statistics. Default: `admin` |
|
| HAPROXY_USERNAME | (Optional) The HAProxy username to the statistics. Default: `admin` |
|
||||||
| HAPROXY_PASSWORD | The HAProxy password to the statistics. If not set disable stats. |
|
| HAPROXY_PASSWORD | The HAProxy password to the statistics. If not set disable stats. |
|
||||||
| HAPROXY_STATS_PORT | (Optional) The HAProxy port to the statistics. Default: `1936` |
|
| HAPROXY_STATS_PORT | (Optional) The HAProxy port to the statistics. Default: `1936` |
|
||||||
|
|
@ -169,6 +170,8 @@ stats:
|
||||||
password: password
|
password: password
|
||||||
port: 1936 # Optional (default 1936)
|
port: 1936 # Optional (default 1936)
|
||||||
|
|
||||||
|
lookup_label: easyhaproxy # The key the system will try to find in the docker labels.
|
||||||
|
|
||||||
customerrors: true # Optional (default false)
|
customerrors: true # Optional (default false)
|
||||||
|
|
||||||
easymapping:
|
easymapping:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ if os.getenv("HAPROXY_PASSWORD"):
|
||||||
"port": os.getenv("HAPROXY_STATS_PORT") if os.getenv("HAPROXY_STATS_PORT") else "1936",
|
"port": os.getenv("HAPROXY_STATS_PORT") if os.getenv("HAPROXY_STATS_PORT") else "1936",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result["metadata"] = {
|
||||||
|
"lookup_label": os.getenv("LOOKUP_LABEL") if os.getenv("LOOKUP_LABEL") else "easyhaproxy",
|
||||||
|
}
|
||||||
|
|
||||||
cfg = HaproxyConfigGenerator(result)
|
cfg = HaproxyConfigGenerator(result)
|
||||||
print(cfg.generate(lineList))
|
print(cfg.generate(lineList))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class DockerLabelHandler:
|
||||||
class HaproxyConfigGenerator:
|
class HaproxyConfigGenerator:
|
||||||
def __init__(self, mapping, ssl_cert_folder="/etc/haproxy/certs"):
|
def __init__(self, mapping, ssl_cert_folder="/etc/haproxy/certs"):
|
||||||
self.mapping = mapping
|
self.mapping = mapping
|
||||||
self.label = DockerLabelHandler("easyhaproxy")
|
self.label = DockerLabelHandler(mapping['lookup_label'] if 'lookup_label' in mapping else "easyhaproxy")
|
||||||
self.ssl_cert_folder = ssl_cert_folder
|
self.ssl_cert_folder = ssl_cert_folder
|
||||||
self.ssl_cert_increment = 0
|
self.ssl_cert_increment = 0
|
||||||
os.makedirs(self.ssl_cert_folder, exist_ok=True)
|
os.makedirs(self.ssl_cert_folder, exist_ok=True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue