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
|
# File 'lib/mkit/app/helpers/migrations_helper.rb', line 12
def ports_to_ingress(ports)
ingress = { frontend: [], backend: [] }
ports.each_with_index do |port_config, index|
match = port_config.match(/^(.*?):(.*?):(tcp|http):(.*?)($|:ssl$|:ssl,(.+))$/)
next unless match
external_port, internal_port, mode, load_bal, ssl, cert = match.captures
frontend = {
name: "frontend-#{external_port}",
options: [],
bind: {
port: external_port,
mode: mode
},
default_backend: "backend-#{external_port}"
}
if ssl.start_with?(':ssl')
frontend[:bind][:ssl] = true
frontend[:bind][:cert] = cert
end
backend = {
name: "backend-#{external_port}",
bind: {
port: internal_port,
mode: mode
},
balance: load_bal
}
if mode == 'http'
a= [
'option httpclose',
'option forwardfor',
'cookie JSESSIONID prefix'
]
backend[:options] = a
backend[:bind][:options] = [ 'cookie A check' ]
end
ingress[:frontend] << frontend
ingress[:backend] << backend
end
ingress.remove_symbols_from_keys
end
|