Add TCP Servers Transports support
Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
parent
c2dac39da1
commit
3eeea2bb2b
101 changed files with 5956 additions and 1669 deletions
|
@ -41,6 +41,17 @@ func (p *Provider) buildConfiguration(ctx context.Context, items []itemData, cer
|
|||
if len(confFromLabel.TCP.Routers) > 0 || len(confFromLabel.TCP.Services) > 0 {
|
||||
tcpOrUDP = true
|
||||
|
||||
if item.ExtraConf.ConsulCatalog.Connect {
|
||||
if confFromLabel.TCP.ServersTransports == nil {
|
||||
confFromLabel.TCP.ServersTransports = make(map[string]*dynamic.TCPServersTransport)
|
||||
}
|
||||
|
||||
serversTransportKey := itemServersTransportKey(item)
|
||||
if confFromLabel.TCP.ServersTransports[serversTransportKey] == nil {
|
||||
confFromLabel.TCP.ServersTransports[serversTransportKey] = certInfo.tcpServersTransport(item)
|
||||
}
|
||||
}
|
||||
|
||||
if err := p.buildTCPServiceConfiguration(item, confFromLabel.TCP); err != nil {
|
||||
logger.Error().Err(err).Send()
|
||||
continue
|
||||
|
@ -131,13 +142,10 @@ func (p *Provider) keepContainer(ctx context.Context, item itemData) bool {
|
|||
|
||||
func (p *Provider) buildTCPServiceConfiguration(item itemData, configuration *dynamic.TCPConfiguration) error {
|
||||
if len(configuration.Services) == 0 {
|
||||
configuration.Services = make(map[string]*dynamic.TCPService)
|
||||
|
||||
lb := &dynamic.TCPServersLoadBalancer{}
|
||||
lb.SetDefaults()
|
||||
|
||||
configuration.Services[getName(item)] = &dynamic.TCPService{
|
||||
LoadBalancer: lb,
|
||||
configuration.Services = map[string]*dynamic.TCPService{
|
||||
getName(item): {
|
||||
LoadBalancer: new(dynamic.TCPServersLoadBalancer),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,6 +223,14 @@ func (p *Provider) addServerTCP(item itemData, loadBalancer *dynamic.TCPServersL
|
|||
return errors.New("port is missing")
|
||||
}
|
||||
|
||||
if item.Address == "" {
|
||||
return errors.New("address is missing")
|
||||
}
|
||||
|
||||
if item.ExtraConf.ConsulCatalog.Connect {
|
||||
loadBalancer.ServersTransport = itemServersTransportKey(item)
|
||||
}
|
||||
|
||||
loadBalancer.Servers[0].Address = net.JoinHostPort(item.Address, port)
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue