[ha] Add haproxy on opendaylight nodes 47/63947/1
authorMichael Polenchuk <mpolenchuk@mirantis.com>
Wed, 24 Oct 2018 10:47:18 +0000 (14:47 +0400)
committerMichael Polenchuk <mpolenchuk@mirantis.com>
Wed, 24 Oct 2018 10:57:24 +0000 (14:57 +0400)
Setup haproxy on opendaylight nodes to listen/bind on VIP address.
Keepalived will be checking existence of haproxy daemon.

Change-Id: Ie0a3a6ebb82523388d528529709415644f67a380
Signed-off-by: Michael Polenchuk <mpolenchuk@mirantis.com>
mcp/config/states/opendaylight
mcp/salt-formulas/salt-formula-opendaylight/metadata/service/server/cluster.yml

index de15d0c..b17b15e 100755 (executable)
@@ -14,7 +14,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../../scripts/lib.sh"
 
 # Get OpenDaylight server options with prefix odl_
 function odl() {
-  salt --out txt -I 'opendaylight:server' pillar.get "opendaylight:server:odl_$1" | cut -d ' ' -f2
+  salt --out txt -I 'opendaylight:server and *01*' pillar.get "opendaylight:server:odl_$1" | cut -d ' ' -f2
 }
 
 wait_for 5.0 "salt -I 'opendaylight:server' state.sls opendaylight"
index 69e1d84..a310fa3 100644 (file)
@@ -10,6 +10,7 @@ applications:
   - opendaylight
 classes:
   - service.keepalived.cluster.single
+  - service.haproxy.proxy.single
 parameters:
   _param:
     opendaylight_version: fluorine
@@ -17,6 +18,7 @@ parameters:
     keepalived_vip_address: ${_param:opendaylight_service_host}
     keepalived_vip_password: ${_param:opnfv_main_password}
     keepalived_vip_interface: ${_param:single_nic}
+    haproxy_odl_api_check_params: check inter 20s fastinter 2s
   opendaylight:
     server:
       enabled: 'True'
@@ -28,14 +30,33 @@ parameters:
   keepalived:
     cluster:
       vrrp_scripts:
-        check_port:
-          args:
-            - ${_param:opendaylight_rest_port}
-            - TCP
-            - 4
-          interval: 15
+        check_pidof:
+          args: haproxy
+          interval: 20
           rise: 3
           fall: 1
       instance:
         VIP:
-          track_script: check_port
+          track_script: check_pidof
+  haproxy:
+    proxy:
+      listen:
+        opendaylight_api:
+          type: general-service
+          balance: source
+          binds:
+            - address: ${_param:opendaylight_service_host}
+              port: ${_param:opendaylight_rest_port}
+          servers:
+            - name: ${_param:opendaylight_server_node01_hostname}
+              host: ${_param:opendaylight_server_node01_address}
+              port: ${_param:opendaylight_rest_port}
+              params: ${_param:haproxy_odl_api_check_params}
+            - name: ${_param:opendaylight_server_node02_hostname}
+              host: ${_param:opendaylight_server_node02_address}
+              port: ${_param:opendaylight_rest_port}
+              params: ${_param:haproxy_odl_api_check_params}
+            - name: ${_param:opendaylight_server_node03_hostname}
+              host: ${_param:opendaylight_server_node03_address}
+              port: ${_param:opendaylight_rest_port}
+              params: ${_param:haproxy_odl_api_check_params}