Documentation ¶
Index ¶
- Variables
- func CleanupLeftovers(ipt iptables.Interface) (encounteredError bool)
- func IsProxyLocked(err error) bool
- type LoadBalancer
- type LoadBalancerRR
- func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName)
- func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ...) error
- func (lb *LoadBalancerRR) NextEndpoint(svcPort proxy.ServicePortName, srcAddr net.Addr) (string, error)
- func (lb *LoadBalancerRR) OnEndpointsUpdate(allEndpoints []api.Endpoints)
- type PortAllocator
- type Proxier
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingServiceEntry = errors.New("missing service entry") ErrMissingEndpoints = errors.New("missing endpoints") )
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") )
Functions ¶
func CleanupLeftovers ¶
CleanupLeftovers removes all iptables rules and chains created by the Proxier It returns true if an error was encountered. Errors are logged.
func IsProxyLocked ¶
IsProxyLocked returns true if the proxy could not acquire the lock on iptables.
Types ¶
type LoadBalancer ¶
type LoadBalancer interface { // NextEndpoint returns the endpoint to handle a request for the given // service-port and source address. NextEndpoint(service proxy.ServicePortName, srcAddr net.Addr) (string, error) NewService(service proxy.ServicePortName, sessionAffinityType api.ServiceAffinity, stickyMaxAgeMinutes int) error CleanupStaleStickySessions(service proxy.ServicePortName) }
LoadBalancer is an interface for distributing incoming requests to service endpoints.
type LoadBalancerRR ¶
type LoadBalancerRR struct {
// contains filtered or unexported fields
}
LoadBalancerRR is a round-robin load balancer.
func NewLoadBalancerRR ¶
func NewLoadBalancerRR(kubeClient *kubeclient.Client, withHaproxier bool) *LoadBalancerRR
NewLoadBalancerRR returns a new LoadBalancerRR.
func (*LoadBalancerRR) CleanupStaleStickySessions ¶
func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName)
func (*LoadBalancerRR) NewService ¶
func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType api.ServiceAffinity, ttlMinutes int) error
func (*LoadBalancerRR) NextEndpoint ¶
func (lb *LoadBalancerRR) NextEndpoint(svcPort proxy.ServicePortName, srcAddr net.Addr) (string, error)
NextEndpoint returns a service endpoint. The service endpoint is chosen using the round-robin algorithm.
func (*LoadBalancerRR) OnEndpointsUpdate ¶
func (lb *LoadBalancerRR) OnEndpointsUpdate(allEndpoints []api.Endpoints)
OnEndpointsUpdate manages the registered service endpoints. Registered endpoints are updated if found in the update set or unregistered if missing from the update set.
type PortAllocator ¶
type Proxier ¶
type Proxier struct {
// 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(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, pr utilnet.PortRange, syncPeriod, udpIdleTimeout time.Duration, kubeClient *kubeclient.Client, withHaproxier bool) (*Proxier, error)
NewProxier returns a new Proxier given a LoadBalancer and an address on which to listen. Because of the iptables logic, It is assumed that there is only a single Proxier active on a machine. An error will be returned if the proxier cannot be started due to an invalid ListenIP (loopback) or if iptables fails to update or acquire the initial lock. Once a proxier is created, it will keep iptables up to date in the background and will not terminate if a particular iptables call fails.
func (*Proxier) OnServiceUpdate ¶
OnServiceUpdate manages the active set of service proxies. Active service proxies are reinitialized if found in the update set or shutdown if missing from the update set.