update backends

This commit is contained in:
holzi1005 2024-12-21 19:18:32 +01:00
parent 3615874533
commit bb248f41e5
3 changed files with 38 additions and 11 deletions

View file

@ -10,8 +10,6 @@ import jinja2
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
KUBERNETES_MASTER_PORT_LISTEN = 7443
# the next two constants come from openstack for one of the master nodes
KUBERNETES_MASTER_PORT = 6443
KUBERNETES_MASTER_IP = "10.0.20.7" # update with the private IP of one of the master nodes
KUBECTL_HOST = "https://%s:%d" % (KUBERNETES_MASTER_IP, KUBERNETES_MASTER_PORT)
@ -55,7 +53,7 @@ def get_endpoints_for_loadbalancers():
gateway_endpoint['mode'] = "%s" % port['protocol'].lower()
gateway_endpoint['balance'] = 'leastconn'
gateway_endpoint['servers'] = []
server_number = 0
server_number = 1
if 'addresses' in subset:
for address in subset['addresses']:
gateway_endpoint['servers'].append("server %s_%s %s:%d check cookie %s" % (service_name, server_number, address['ip'], port['targetPort']), server_number)
@ -65,7 +63,7 @@ def get_endpoints_for_loadbalancers():
def get_haproxy_config():
load_balanced_endpoints = get_endpoints_for_loadbalancers()
haproxy_config = get_haproxy_config_template().render(services=load_balanced_endpoints)
haproxy_config = get_haproxy_config_template().render(backends=load_balanced_endpoints)
return haproxy_config
def main():

View file

@ -15,15 +15,15 @@ defaults
timeout client 50000
timeout server 50000
{% for service in services %}
backend {{ service.name }}
mode {{ service.mode }}
balance {{ service.balance }}
{% for key, value in service.labels %}
{% for backend in backends %}
backend {{ backend.name }}
mode {{ backend.mode }}
balance {{ backend.balance }}
{% for key, value in backend.labels %}
option {{ value }} # {{ key }}
{% endfor %
cookie {{ service.mode }} insert indirect nocache
{% for server in service.servers -%}
cookie {{ backend.mode }} insert indirect nocache
{% for server in backend.servers -%}
{{ server }}
{% endfor %}

29
oroginal Normal file
View file

@ -0,0 +1,29 @@
backend be_open_event_manager
description default backend for open-event-manager
mode http
balance roundrobin
option httpchk GET /health/check
option forwardfor
cookie OEM_SERVERID insert indirect nocache
server DE-NUE-WEB01 10.106.10.11:8081 check cookie 1
server DE-NUE-WEB02 10.106.10.12:8081 check cookie 2
server DE-NUE-WEB04 10.106.10.14:8081 check cookie 3
server DE-NUE-WEB05 10.106.10.5:8081 check cookie 4
server DE-NUE-WEB06 10.106.10.6:8081 check cookie 5
"metadata": {
"labels": {
"key1" : "value1",
"key2" : "value2"
}
}
{% for key, value in dict_item.items() %}
<h1>Key: {{key}}</h1>
<h2>Value: {{value}}</h2>
{% endfor %}