From d9467bf520759f9d7bdc45265f5f6a699f254d2a Mon Sep 17 00:00:00 2001 From: dcore94 Date: Thu, 20 May 2021 17:17:16 +0200 Subject: [PATCH] added support for load balanced network on external node --- inventory/hosts.dev | 8 ++-- roles/pep/tasks/main.yaml | 7 ++++ .../templates/pep-swarm-ha_network.yaml.j2 | 38 +++++++++++++++++++ site-dev.yaml | 1 + site-pre.yaml | 1 + site-prod.yaml | 1 + 6 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 roles/pep/templates/pep-swarm-ha_network.yaml.j2 diff --git a/inventory/hosts.dev b/inventory/hosts.dev index f50e1e5..1cb02f1 100644 --- a/inventory/hosts.dev +++ b/inventory/hosts.dev @@ -1,5 +1,5 @@ -[dev_infra:children] -dev_cluster +[prod_infra:children] +prod_cluster -[dev_cluster] -conductor.dev.d4science.org +[prod_cluster] +docker-swarm1.int.d4science.net docker_swarm_manager_main_node=True diff --git a/roles/pep/tasks/main.yaml b/roles/pep/tasks/main.yaml index fe134f0..4782d4c 100644 --- a/roles/pep/tasks/main.yaml +++ b/roles/pep/tasks/main.yaml @@ -32,3 +32,10 @@ template: src: templates/pep-swarm.yaml.j2 dest: "{{ target_path }}/pep-swarm.yaml" + +- name: Generate pep-docker-swarm when behind HA proxy + when: ha_network is defined and ha_network == True + template: + src: templates/pep-swarm-ha_network.yaml.j2 + dest: "{{ target_path }}/pep-swarm.yaml" + diff --git a/roles/pep/templates/pep-swarm-ha_network.yaml.j2 b/roles/pep/templates/pep-swarm-ha_network.yaml.j2 new file mode 100644 index 0000000..b14e141 --- /dev/null +++ b/roles/pep/templates/pep-swarm-ha_network.yaml.j2 @@ -0,0 +1,38 @@ +version: '3.6' + +services: + + pep: + image: nginx:stable-alpine + networks: + - conductor-network + - haproxy-public +{% if pep is defined and pep == True %} + volumes: + - "./pep.js:/etc/nginx/pep.js" + - "./config.js:/etc/nginx/config.js" +{% endif %} + deploy: + replicas: 1 + placement: + constraints: [node.role != worker] + endpoint_mode: dnsrr + restart_policy: + condition: on-failure + delay: 10s + window: 120s + configs: + - source: nginxconf + target: /etc/nginx/templates/default.conf.template + - source: nginxbaseconf + target: /etc/nginx/nginx.conf + +networks: + conductor-network: + haproxy-public: + external: true +configs: + nginxconf: + file: ./nginx.default.conf + nginxbaseconf: + file: ./nginx.conf diff --git a/site-dev.yaml b/site-dev.yaml index 3a04412..01502af 100644 --- a/site-dev.yaml +++ b/site-dev.yaml @@ -10,6 +10,7 @@ iam_host: https://accounts.dev.d4science.org pep: True pep_credentials: "{{ dev_pep_credentials }}" + ha_network: True conductor_ui_secret: "{{ dev_conductor_ui_secret }}" conductor_auth: oauth2 conductor_server_name: conductor.dev.d4science.org diff --git a/site-pre.yaml b/site-pre.yaml index c74164a..aa5e4ce 100644 --- a/site-pre.yaml +++ b/site-pre.yaml @@ -10,6 +10,7 @@ iam_host: https://accounts.pre.d4science.org pep: True pep_credentials: "{{ pre_pep_credentials }}" + ha_network: True conductor_ui_secret: "{{ pre_conductor_ui_secret }}" conductor_auth: oauth2 conductor_server_name: conductor.pre.d4science.org diff --git a/site-prod.yaml b/site-prod.yaml index be15cae..736a3bc 100644 --- a/site-prod.yaml +++ b/site-prod.yaml @@ -10,6 +10,7 @@ iam_host: https://accounts.d4science.org pep: True pep_credentials: "{{ prod_pep_credentials }}" + ha_network: True conductor_ui_secret: "{{ prod_conductor_ui_secret }}" conductor_auth: oauth2 conductor_server_name: conductor.d4science.org