This repository has been archived by the owner on Jul 12, 2018. It is now read-only.
/
haproxy.go
71 lines (66 loc) · 1.69 KB
/
haproxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package cloudfoundry
import (
"github.com/enaml-ops/enaml"
"github.com/enaml-ops/omg-product-bundle/products/oss_cf/enaml-gen/haproxy"
"github.com/enaml-ops/omg-product-bundle/products/oss_cf/plugin/config"
)
// HAProxy -
type HAProxy struct {
Config *config.Config
ConsulAgent *ConsulAgent
Metron *Metron
StatsdInjector *StatsdInjector
}
//NewHaProxyPartition -
func NewHaProxyPartition(config *config.Config) InstanceGroupCreator {
return &HAProxy{
Config: config,
ConsulAgent: NewConsulAgent([]string{}, config),
Metron: NewMetron(config),
StatsdInjector: NewStatsdInjector(nil),
}
}
//ToInstanceGroup -
func (s *HAProxy) ToInstanceGroup() (ig *enaml.InstanceGroup) {
if !s.Config.HAProxySkip {
ig = &enaml.InstanceGroup{
Name: "ha_proxy-partition",
Instances: len(s.Config.HAProxyIPs),
VMType: s.Config.HAProxyVMType,
AZs: s.Config.AZs,
Stemcell: s.Config.StemcellName,
Jobs: []enaml.InstanceJob{
s.createHAProxyJob(),
s.ConsulAgent.CreateJob(),
s.Metron.CreateJob(),
s.StatsdInjector.CreateJob(),
},
Networks: []enaml.Network{
enaml.Network{Name: s.Config.NetworkName, StaticIPs: s.Config.HAProxyIPs},
},
Update: enaml.Update{
MaxInFlight: 1,
},
}
}
return
}
func (s *HAProxy) createHAProxyJob() enaml.InstanceJob {
return enaml.InstanceJob{
Name: "haproxy",
Release: "cf",
Properties: &haproxy.HaproxyJob{
RequestTimeoutInSeconds: 180,
HaProxy: &haproxy.HaProxy{
DisableHttp: true,
SslPem: s.Config.HAProxySSLPem,
},
Router: &haproxy.Router{
Servers: s.Config.RouterMachines,
},
Cc: &haproxy.Cc{
AllowAppSshAccess: true,
},
},
}
}