|
| 1 | +# Introduction |
| 2 | +# Class used to load-balance brokers in a |
| 3 | +# high-availability OpenShift deployment. |
| 4 | +# |
| 5 | +# Module Dependencies |
| 6 | +# duritong/sysctl |
| 7 | +# arioch/keepalived |
| 8 | +# puppetlabs/haproxy |
| 9 | +# |
| 10 | +# Example Usage |
| 11 | +# class { 'openshift_origin' : |
| 12 | +# broker_cluster_members => ['broker01.example.com','broker02.example.com','broker03.example.com'], |
| 13 | +# broker_cluster_ip_addresses => ['10.10.10.11','10.10.10.12','10.10.10.13'], |
| 14 | +# broker_virtual_ip_address => '10.10.10.10', |
| 15 | +# broker_virtual_hostname => 'broker.example.com', |
| 16 | +# load_balancer_master => true, |
| 17 | +# } |
| 18 | +# |
| 19 | +class openshift_origin::load_balancer( |
| 20 | + $enable = true, |
| 21 | + $manage_service = true, |
| 22 | + $state_master = $::openshift_origin::load_balancer_master, |
| 23 | + $virtual_ipaddress = $::openshift_origin::broker_virtual_ip_address, |
| 24 | + $server_names = $::openshift_origin::broker_cluster_members, |
| 25 | + $ipaddresses = $::openshift_origin::broker_cluster_ip_addresses, |
| 26 | + $interface = $::openshift_origin::conf_node_external_eth_dev, |
| 27 | + $http_port = '80', |
| 28 | + $ssl_port = '443', |
| 29 | + $virtual_router_id = '50', |
| 30 | + $auth_pass = $::openshift_origin::load_balancer_auth_password, |
| 31 | + |
| 32 | +) { |
| 33 | + |
| 34 | + include keepalived |
| 35 | + |
| 36 | + if 'broker' and 'load_balancer' in $::openshift_origin::roles { |
| 37 | + Class[openshift_origin::plugins::frontend::apache] -> Class['haproxy'] |
| 38 | + } |
| 39 | + |
| 40 | + if ($state_master == true) { |
| 41 | + $priority = '101' |
| 42 | + } else { |
| 43 | + $priority = '100' |
| 44 | + } |
| 45 | + |
| 46 | + # Required by sysctl module |
| 47 | + Exec { path => '/usr/bin:/usr/sbin:/bin:/sbin' } |
| 48 | + |
| 49 | + sysctl::value { 'net.ipv4.ip_nonlocal_bind': |
| 50 | + value => '1', |
| 51 | + } |
| 52 | + |
| 53 | + keepalived::vrrp::instance { $virtual_router_id: |
| 54 | + interface => $interface, |
| 55 | + priority => $priority, |
| 56 | + state => $state_master, |
| 57 | + virtual_ipaddress => [$virtual_ipaddress], |
| 58 | + virtual_router_id => $virtual_router_id, |
| 59 | + auth_type => 'PASS', |
| 60 | + auth_pass => $auth_pass, |
| 61 | + track_script => ['haproxy'], |
| 62 | + } |
| 63 | + |
| 64 | + keepalived::vrrp::script { 'haproxy': |
| 65 | + script => '/usr/bin/killall -0 haproxy', |
| 66 | + } |
| 67 | + |
| 68 | + class { 'haproxy': |
| 69 | + manage_service => $manage_service, |
| 70 | + enable => $enable, |
| 71 | + defaults_options => { |
| 72 | + 'log' => 'global', |
| 73 | + 'option' => 'redispatch', |
| 74 | + 'retries' => '3', |
| 75 | + 'timeout' => [ |
| 76 | + 'http-request 10s', |
| 77 | + 'queue 1m', |
| 78 | + 'connect 10s', |
| 79 | + 'client 1m', |
| 80 | + 'server 1m', |
| 81 | + 'check 10s', |
| 82 | + ], |
| 83 | + 'maxconn' => '8000', |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + haproxy::listen { 'broker_http_cluster': |
| 88 | + ipaddress => $virtual_ipaddress, |
| 89 | + ports => $http_port, |
| 90 | + options => { |
| 91 | + 'option' => ['tcpka', 'tcplog'], |
| 92 | + 'mode' => 'tcp', |
| 93 | + 'balance' => 'source', |
| 94 | + }, |
| 95 | + } |
| 96 | + |
| 97 | + haproxy::balancermember { 'http_brokers': |
| 98 | + listening_service => 'broker_http_cluster', |
| 99 | + server_names => $server_names, |
| 100 | + ipaddresses => $ipaddresses, |
| 101 | + ports => $http_port, |
| 102 | + options => 'check inter 2000 rise 2 fall 5', |
| 103 | + } |
| 104 | + |
| 105 | + haproxy::listen { 'broker_ssl_cluster': |
| 106 | + ipaddress => $virtual_ipaddress, |
| 107 | + ports => $ssl_port, |
| 108 | + options => { |
| 109 | + 'option' => ['tcpka', 'tcplog'], |
| 110 | + 'mode' => 'tcp', |
| 111 | + 'balance' => 'source', |
| 112 | + }, |
| 113 | + } |
| 114 | + |
| 115 | + haproxy::balancermember { 'ssl_brokers': |
| 116 | + listening_service => 'broker_ssl_cluster', |
| 117 | + server_names => $server_names, |
| 118 | + ipaddresses => $ipaddresses, |
| 119 | + ports => $ssl_port, |
| 120 | + options => 'check inter 2000 rise 2 fall 5', |
| 121 | + } |
| 122 | +} |
0 commit comments