mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
transparent proxy: add jobspec support (#20144)
Add a transparent proxy block to the existing Connect sidecar service proxy block. This changeset is plumbing required to support transparent proxy configuration on the client. Ref: https://github.com/hashicorp/nomad/issues/10628
This commit is contained in:
@@ -145,8 +145,13 @@ func connectSidecarProxy(info structs.AllocInfo, proxy *structs.ConsulProxy, cPo
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mode := api.ProxyModeDefault
|
||||
if proxy.TransparentProxy != nil {
|
||||
mode = api.ProxyModeTransparent
|
||||
}
|
||||
|
||||
return &api.AgentServiceConnectProxyConfig{
|
||||
Mode: mode,
|
||||
LocalServiceAddress: proxy.LocalServiceAddress,
|
||||
LocalServicePort: proxy.LocalServicePort,
|
||||
Config: connectProxyConfig(proxy.Config, cPort, info),
|
||||
|
||||
@@ -1897,6 +1897,7 @@ func apiConnectSidecarServiceProxyToStructs(in *api.ConsulProxy) *structs.Consul
|
||||
LocalServicePort: in.LocalServicePort,
|
||||
Upstreams: apiUpstreamsToStructs(in.Upstreams),
|
||||
Expose: apiConsulExposeConfigToStructs(expose),
|
||||
TransparentProxy: apiConnectTransparentProxyToStructs(in.TransparentProxy),
|
||||
Config: maps.Clone(in.Config),
|
||||
}
|
||||
}
|
||||
@@ -1949,6 +1950,21 @@ func apiConsulExposeConfigToStructs(in *api.ConsulExposeConfig) *structs.ConsulE
|
||||
}
|
||||
}
|
||||
|
||||
func apiConnectTransparentProxyToStructs(in *api.ConsulTransparentProxy) *structs.ConsulTransparentProxy {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
return &structs.ConsulTransparentProxy{
|
||||
UID: in.UID,
|
||||
OutboundPort: in.OutboundPort,
|
||||
ExcludeInboundPorts: in.ExcludeInboundPorts,
|
||||
ExcludeOutboundPorts: in.ExcludeOutboundPorts,
|
||||
ExcludeOutboundCIDRs: in.ExcludeOutboundCIDRs,
|
||||
ExcludeUIDs: in.ExcludeUIDs,
|
||||
NoDNS: in.NoDNS,
|
||||
}
|
||||
}
|
||||
|
||||
func apiConsulExposePathsToStructs(in []*api.ConsulExposePath) []structs.ConsulExposePath {
|
||||
if len(in) == 0 {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user