Documentation ¶
Index ¶
- Constants
- Variables
- func ProxyTCP(in, out *net.TCPConn)
- func TryConnectEndpoints(service proxy.ServicePortName, srcAddr net.Addr, protocol string, ...) (out net.Conn, err error)
- type LoadBalancerRR
- func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName)
- func (lb *LoadBalancerRR) DeleteService(svcPort proxy.ServicePortName)
- func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType v1.ServiceAffinity, ttlSeconds int) error
- func (lb *LoadBalancerRR) NextEndpoint(svcPort proxy.ServicePortName, srcAddr net.Addr, sessionAffinityReset bool) (string, error)
- func (lb *LoadBalancerRR) OnEndpointsAdd(endpoints *v1.Endpoints)
- func (lb *LoadBalancerRR) OnEndpointsDelete(endpoints *v1.Endpoints)
- func (lb *LoadBalancerRR) OnEndpointsSynced()
- func (lb *LoadBalancerRR) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoints)
- func (lb *LoadBalancerRR) ServiceHasEndpoints(svcPort proxy.ServicePortName) bool
- type NeedPodsSignaler
- type PortAllocator
- type Proxier
- func (p *Proxier) OnEndpointSliceAdd(slice *discoveryv1.EndpointSlice)
- func (p *Proxier) OnEndpointSliceDelete(slice *discoveryv1.EndpointSlice)
- func (p *Proxier) OnEndpointSliceUpdate(oldSlice, slice *discoveryv1.EndpointSlice)
- func (p *Proxier) OnEndpointSlicesSynced()
- func (proxier *Proxier) OnEndpointsAdd(endpoints *v1.Endpoints)
- func (proxier *Proxier) OnEndpointsDelete(endpoints *v1.Endpoints)
- func (proxier *Proxier) OnEndpointsSynced()
- func (proxier *Proxier) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoints)
- func (proxier *Proxier) OnServiceAdd(service *v1.Service)
- func (proxier *Proxier) OnServiceDelete(service *v1.Service)
- func (proxier *Proxier) OnServiceSynced()
- func (proxier *Proxier) OnServiceUpdate(oldService, service *v1.Service)
- func (p *Proxier) ReloadIPTables()
- func (p *Proxier) SetSyncRunner(b *async.BoundedFrequencyRunner)
- func (proxier *Proxier) Sync()
- func (proxier *Proxier) SyncLoop()
- func (p *Proxier) SyncProxyRules()
- type ProxySocket
- type ProxySocketFunc
- type ServiceInfo
Constants ¶
const ( UDPBufferSize = 4096 // 4KiB should be enough for most whole-packets NeedPodsReason = "NeedPods" )
Variables ¶
var ( ErrMissingServiceEntry = errors.New("missing service entry") ErrMissingEndpoints = errors.New("missing endpoints") )
var EndpointDialTimeouts = []time.Duration{250 * time.Millisecond, 500 * time.Millisecond, 1 * time.Second, 2 * time.Second}
How long we wait for a connection to a backend in seconds
var ( // ErrProxyOnLocalhost is returned by NewProxier if the user requests a proxier on // the loopback address. May be checked for by callers of NewProxier to know whether // the caller provided invalid input. ErrProxyOnLocalhost = fmt.Errorf("cannot proxy on localhost") )
var ( // MaxHeldConnections is the maximum number of TCP connections per service that // will be held by the unidler at once (new connections will cause older ones // to be dropped after the limit is reached) MaxHeldConnections = 16 )
Functions ¶
func TryConnectEndpoints ¶
func TryConnectEndpoints(service proxy.ServicePortName, srcAddr net.Addr, protocol string, loadBalancer *LoadBalancerRR) (out net.Conn, err error)
TryConnectEndpoints attempts to connect to the next available endpoint for the given service, cycling through until it is able to successfully connect, or it has tried with all timeouts in EndpointDialTimeouts.
Types ¶
type LoadBalancerRR ¶
type LoadBalancerRR struct {
// contains filtered or unexported fields
}
LoadBalancerRR is a round-robin load balancer.
func NewLoadBalancerRR ¶
func NewLoadBalancerRR() *LoadBalancerRR
NewLoadBalancerRR returns a new LoadBalancerRR.
func (*LoadBalancerRR) CleanupStaleStickySessions ¶
func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName)
func (*LoadBalancerRR) DeleteService ¶
func (lb *LoadBalancerRR) DeleteService(svcPort proxy.ServicePortName)
func (*LoadBalancerRR) NewService ¶
func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType v1.ServiceAffinity, ttlSeconds int) error
func (*LoadBalancerRR) NextEndpoint ¶
func (lb *LoadBalancerRR) NextEndpoint(svcPort proxy.ServicePortName, srcAddr net.Addr, sessionAffinityReset bool) (string, error)
NextEndpoint returns a service endpoint. The service endpoint is chosen using the round-robin algorithm.
func (*LoadBalancerRR) OnEndpointsAdd ¶
func (lb *LoadBalancerRR) OnEndpointsAdd(endpoints *v1.Endpoints)
func (*LoadBalancerRR) OnEndpointsDelete ¶
func (lb *LoadBalancerRR) OnEndpointsDelete(endpoints *v1.Endpoints)
func (*LoadBalancerRR) OnEndpointsSynced ¶
func (lb *LoadBalancerRR) OnEndpointsSynced()
func (*LoadBalancerRR) OnEndpointsUpdate ¶
func (lb *LoadBalancerRR) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoints)
func (*LoadBalancerRR) ServiceHasEndpoints ¶
func (lb *LoadBalancerRR) ServiceHasEndpoints(svcPort proxy.ServicePortName) bool
ServiceHasEndpoints checks whether a service entry has endpoints.
type NeedPodsSignaler ¶
type NeedPodsSignaler struct {
// contains filtered or unexported fields
}
func (*NeedPodsSignaler) NeedPods ¶
func (sig *NeedPodsSignaler) NeedPods(serviceName types.NamespacedName, port string) error
NeedPods signals that endpoint addresses are needed in order to service a traffic coming to the given service and port
type PortAllocator ¶
type Proxier ¶
type Proxier struct { // TODO(imroc): implement node handler for userspace proxier. config.NoopNodeHandler // contains filtered or unexported fields }
Proxier is a simple proxy for TCP connections between a localhost:lport and services that provide the actual implementations.
func NewProxier ¶
func NewProxier(listenIP net.IP, iptables iptables.Interface, exec utilexec.Interface, pr utilnet.PortRange, syncPeriod, minSyncPeriod, udpIdleTimeout time.Duration, nodePortAddresses []string, makeProxySocket ProxySocketFunc) (*Proxier, error)
NewProxier returns a new Proxier for the given address.
func NewUnidlerProxier ¶
func NewUnidlerProxier(listenIP net.IP, iptables iptables.Interface, exec utilexec.Interface, pr utilnet.PortRange, syncPeriod, minSyncPeriod, udpIdleTimeout time.Duration, nodePortAddresses []string, eventRecorder record.EventRecorder) (*Proxier, error)
NewUnidlerProxier creates a new Proxier for the given LoadBalancer and address which fires off unidling signals connections and traffic. It is intended to be used as one half of a HybridProxier.
func (*Proxier) OnEndpointSliceAdd ¶
func (p *Proxier) OnEndpointSliceAdd(slice *discoveryv1.EndpointSlice)
These functions never get called on the unidling proxy, but are needed to satisfy the interface
func (*Proxier) OnEndpointSliceDelete ¶
func (p *Proxier) OnEndpointSliceDelete(slice *discoveryv1.EndpointSlice)
func (*Proxier) OnEndpointSliceUpdate ¶
func (p *Proxier) OnEndpointSliceUpdate(oldSlice, slice *discoveryv1.EndpointSlice)
func (*Proxier) OnEndpointSlicesSynced ¶
func (p *Proxier) OnEndpointSlicesSynced()
func (*Proxier) OnEndpointsAdd ¶
OnEndpointsAdd is called whenever creation of new endpoints object is observed.
func (*Proxier) OnEndpointsDelete ¶
OnEndpointsDelete is called whenever deletion of an existing endpoints object is observed.
func (*Proxier) OnEndpointsSynced ¶
func (proxier *Proxier) OnEndpointsSynced()
OnEndpointsSynced is called once all the initial event handlers were called and the state is fully propagated to local cache.
func (*Proxier) OnEndpointsUpdate ¶
OnEndpointsUpdate is called whenever modification of an existing endpoints object is observed.
func (*Proxier) OnServiceAdd ¶
OnServiceAdd is called whenever creation of new service object is observed.
func (*Proxier) OnServiceDelete ¶
OnServiceDelete is called whenever deletion of an existing service object is observed.
func (*Proxier) OnServiceSynced ¶
func (proxier *Proxier) OnServiceSynced()
OnServiceSynced is called once all the initial event handlers were called and the state is fully propagated to local cache.
func (*Proxier) OnServiceUpdate ¶
OnServiceUpdate is called whenever modification of an existing service object is observed.
func (*Proxier) ReloadIPTables ¶
func (p *Proxier) ReloadIPTables()
ReloadIPTables is part of sdnproxy.HybridizableProxy
func (*Proxier) SetSyncRunner ¶
func (p *Proxier) SetSyncRunner(b *async.BoundedFrequencyRunner)
SetSyncRunner is part of sdnproxy.HybridizableProxy
func (*Proxier) Sync ¶
func (proxier *Proxier) Sync()
Sync is called to synchronize the proxier state to iptables as soon as possible.
func (*Proxier) SyncLoop ¶
func (proxier *Proxier) SyncLoop()
SyncLoop runs periodic work. This is expected to run as a goroutine or as the main loop of the app. It does not return.
func (*Proxier) SyncProxyRules ¶
func (p *Proxier) SyncProxyRules()
SyncProxyRules is part of sdnproxy.HybridizableProxy
type ProxySocket ¶
type ProxySocket interface { // Addr gets the net.Addr for a ProxySocket. Addr() net.Addr // Close stops the ProxySocket from accepting incoming connections. // Each implementation should comment on the impact of calling Close // while sessions are active. Close() error // ProxyLoop proxies incoming connections for the specified service to the service endpoints. ProxyLoop(service proxy.ServicePortName, info *ServiceInfo, loadBalancer *LoadBalancerRR) // ListenPort returns the host port that the ProxySocket is listening on ListenPort() int }
Abstraction over TCP/UDP sockets which are proxied.
type ProxySocketFunc ¶
ProxySocketFunc is a function which constructs a ProxySocket from a protocol, ip, and port
type ServiceInfo ¶
type ServiceInfo struct { // Timeout is the read/write timeout (used for UDP connections) Timeout time.Duration // contains filtered or unexported fields }
ServiceInfo contains information and state for a particular proxied service
func (*ServiceInfo) IsAlive ¶
func (info *ServiceInfo) IsAlive() bool
func (*ServiceInfo) IsFinished ¶
func (info *ServiceInfo) IsFinished() bool
func (*ServiceInfo) IsStarted ¶
func (info *ServiceInfo) IsStarted() bool