kubernetes: k8s.io/kubernetes/pkg/proxy/userspace Index | Files

package userspace

import "k8s.io/kubernetes/pkg/proxy/userspace"

Index

Package Files

loadbalancer.go port_allocator.go proxier.go proxysocket.go rlimit.go roundrobin.go

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")
)

func CleanupLeftovers Uses

func CleanupLeftovers(ipt iptables.Interface) (encounteredError bool)

CleanupLeftovers removes all iptables rules and chains created by the Proxier It returns true if an error was encountered. Errors are logged.

func IsProxyLocked Uses

func IsProxyLocked(err error) bool

IsProxyLocked returns true if the proxy could not acquire the lock on iptables.

func ProxyTCP Uses

func ProxyTCP(in, out *net.TCPConn)

ProxyTCP proxies data bi-directionally between in and out.

func TryConnectEndpoints Uses

func TryConnectEndpoints(service proxy.ServicePortName, srcAddr net.Addr, protocol string, loadBalancer LoadBalancer) (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.

type ClientCache Uses

type ClientCache struct {
    Mu      sync.Mutex
    Clients map[string]net.Conn // addr string -> connection
}

Holds all the known UDP clients that have not timed out.

type LoadBalancer Uses

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, sessionAffinityReset bool) (string, error)
    NewService(service proxy.ServicePortName, sessionAffinityType v1.ServiceAffinity, stickyMaxAgeSeconds int) error
    DeleteService(service proxy.ServicePortName)
    CleanupStaleStickySessions(service proxy.ServicePortName)
    ServiceHasEndpoints(service proxy.ServicePortName) bool

    proxyconfig.EndpointsHandler
}

LoadBalancer is an interface for distributing incoming requests to service endpoints.

type LoadBalancerRR Uses

type LoadBalancerRR struct {
    // contains filtered or unexported fields
}

LoadBalancerRR is a round-robin load balancer.

func NewLoadBalancerRR Uses

func NewLoadBalancerRR() *LoadBalancerRR

NewLoadBalancerRR returns a new LoadBalancerRR.

func (*LoadBalancerRR) CleanupStaleStickySessions Uses

func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName)

func (*LoadBalancerRR) DeleteService Uses

func (lb *LoadBalancerRR) DeleteService(svcPort proxy.ServicePortName)

func (*LoadBalancerRR) NewService Uses

func (lb *LoadBalancerRR) NewService(svcPort proxy.ServicePortName, affinityType v1.ServiceAffinity, ttlSeconds int) error

func (*LoadBalancerRR) NextEndpoint Uses

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 Uses

func (lb *LoadBalancerRR) OnEndpointsAdd(endpoints *v1.Endpoints)

func (*LoadBalancerRR) OnEndpointsDelete Uses

func (lb *LoadBalancerRR) OnEndpointsDelete(endpoints *v1.Endpoints)

func (*LoadBalancerRR) OnEndpointsSynced Uses

func (lb *LoadBalancerRR) OnEndpointsSynced()

func (*LoadBalancerRR) OnEndpointsUpdate Uses

func (lb *LoadBalancerRR) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoints)

func (*LoadBalancerRR) ServiceHasEndpoints Uses

func (lb *LoadBalancerRR) ServiceHasEndpoints(svcPort proxy.ServicePortName) bool

ServiceHasEndpoints checks whether a service entry has endpoints.

type PortAllocator Uses

type PortAllocator interface {
    AllocateNext() (int, error)
    Release(int)
}

type Proxier Uses

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 NewCustomProxier Uses

func NewCustomProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, exec utilexec.Interface, pr utilnet.PortRange, syncPeriod, minSyncPeriod, udpIdleTimeout time.Duration, nodePortAddresses []string, makeProxySocket ProxySocketFunc) (*Proxier, error)

NewCustomProxier functions similarly to NewProxier, returning a new Proxier for the given LoadBalancer and address. The new proxier is constructed using the ProxySocket constructor provided, however, instead of constructing the default ProxySockets.

func NewProxier Uses

func NewProxier(loadBalancer LoadBalancer, listenIP net.IP, iptables iptables.Interface, exec utilexec.Interface, pr utilnet.PortRange, syncPeriod, minSyncPeriod, udpIdleTimeout time.Duration, nodePortAddresses []string) (*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) OnEndpointsAdd Uses

func (proxier *Proxier) OnEndpointsAdd(endpoints *v1.Endpoints)

func (*Proxier) OnEndpointsDelete Uses

func (proxier *Proxier) OnEndpointsDelete(endpoints *v1.Endpoints)

func (*Proxier) OnEndpointsSynced Uses

func (proxier *Proxier) OnEndpointsSynced()

func (*Proxier) OnEndpointsUpdate Uses

func (proxier *Proxier) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoints)

func (*Proxier) OnServiceAdd Uses

func (proxier *Proxier) OnServiceAdd(service *v1.Service)

func (*Proxier) OnServiceDelete Uses

func (proxier *Proxier) OnServiceDelete(service *v1.Service)

func (*Proxier) OnServiceSynced Uses

func (proxier *Proxier) OnServiceSynced()

func (*Proxier) OnServiceUpdate Uses

func (proxier *Proxier) OnServiceUpdate(oldService, service *v1.Service)

func (*Proxier) Sync Uses

func (proxier *Proxier) Sync()

Sync is called to synchronize the proxier state to iptables as soon as possible.

func (*Proxier) SyncLoop Uses

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.

type ProxySocket Uses

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 LoadBalancer)
    // ListenPort returns the host port that the ProxySocket is listening on
    ListenPort() int
}

Abstraction over TCP/UDP sockets which are proxied.

type ProxySocketFunc Uses

type ProxySocketFunc func(protocol v1.Protocol, ip net.IP, port int) (ProxySocket, error)

ProxySocketFunc is a function which constructs a ProxySocket from a protocol, ip, and port

type ServiceInfo Uses

type ServiceInfo struct {
    // Timeout is the read/write timeout (used for UDP connections)
    Timeout time.Duration
    // ActiveClients is the cache of active UDP clients being proxied by this proxy for this service
    ActiveClients *ClientCache
    // contains filtered or unexported fields
}

ServiceInfo contains information and state for a particular proxied service

func (*ServiceInfo) IsAlive Uses

func (info *ServiceInfo) IsAlive() bool

Package userspace imports 30 packages (graph) and is imported by 28 packages. Updated 2019-06-01. Refresh now. Tools for package owners.