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

package proxy

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

Package proxy implements the layer-3 network proxy.

Index

Package Files

doc.go endpoints.go endpointslicecache.go service.go topology.go types.go

type BaseEndpointInfo Uses

type BaseEndpointInfo struct {
    Endpoint string // TODO: should be an endpointString type
    // IsLocal indicates whether the endpoint is running in same host as kube-proxy.
    IsLocal  bool
    Topology map[string]string
}

BaseEndpointInfo contains base information that defines an endpoint. This could be used directly by proxier while processing endpoints, or can be used for constructing a more specific EndpointInfo struct defined by the proxier if needed.

func (*BaseEndpointInfo) Equal Uses

func (info *BaseEndpointInfo) Equal(other Endpoint) bool

Equal is part of proxy.Endpoint interface.

func (*BaseEndpointInfo) GetIsLocal Uses

func (info *BaseEndpointInfo) GetIsLocal() bool

GetIsLocal is part of proxy.Endpoint interface.

func (*BaseEndpointInfo) GetTopology Uses

func (info *BaseEndpointInfo) GetTopology() map[string]string

GetTopology returns the topology information of the endpoint.

func (*BaseEndpointInfo) IP Uses

func (info *BaseEndpointInfo) IP() string

IP returns just the IP part of the endpoint, it's a part of proxy.Endpoint interface.

func (*BaseEndpointInfo) Port Uses

func (info *BaseEndpointInfo) Port() (int, error)

Port returns just the Port part of the endpoint.

func (*BaseEndpointInfo) String Uses

func (info *BaseEndpointInfo) String() string

String is part of proxy.Endpoint interface.

type BaseServiceInfo Uses

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

BaseServiceInfo contains base information that defines a service. This could be used directly by proxier while processing services, or can be used for constructing a more specific ServiceInfo struct defined by the proxier if needed.

func (*BaseServiceInfo) ClusterIP Uses

func (info *BaseServiceInfo) ClusterIP() net.IP

ClusterIP is part of ServicePort interface.

func (*BaseServiceInfo) ExternalIPStrings Uses

func (info *BaseServiceInfo) ExternalIPStrings() []string

ExternalIPStrings is part of ServicePort interface.

func (*BaseServiceInfo) HealthCheckNodePort Uses

func (info *BaseServiceInfo) HealthCheckNodePort() int

HealthCheckNodePort is part of ServicePort interface.

func (*BaseServiceInfo) LoadBalancerIPStrings Uses

func (info *BaseServiceInfo) LoadBalancerIPStrings() []string

LoadBalancerIPStrings is part of ServicePort interface.

func (*BaseServiceInfo) LoadBalancerSourceRanges Uses

func (info *BaseServiceInfo) LoadBalancerSourceRanges() []string

LoadBalancerSourceRanges is part of ServicePort interface

func (*BaseServiceInfo) NodePort Uses

func (info *BaseServiceInfo) NodePort() int

NodePort is part of the ServicePort interface.

func (*BaseServiceInfo) OnlyNodeLocalEndpoints Uses

func (info *BaseServiceInfo) OnlyNodeLocalEndpoints() bool

OnlyNodeLocalEndpoints is part of ServicePort interface.

func (*BaseServiceInfo) Port Uses

func (info *BaseServiceInfo) Port() int

Port is part of ServicePort interface.

func (*BaseServiceInfo) Protocol Uses

func (info *BaseServiceInfo) Protocol() v1.Protocol

Protocol is part of ServicePort interface.

func (*BaseServiceInfo) SessionAffinityType Uses

func (info *BaseServiceInfo) SessionAffinityType() v1.ServiceAffinity

SessionAffinityType is part of the ServicePort interface.

func (*BaseServiceInfo) StickyMaxAgeSeconds Uses

func (info *BaseServiceInfo) StickyMaxAgeSeconds() int

StickyMaxAgeSeconds is part of the ServicePort interface

func (*BaseServiceInfo) String Uses

func (info *BaseServiceInfo) String() string

String is part of ServicePort interface.

func (*BaseServiceInfo) TopologyKeys Uses

func (info *BaseServiceInfo) TopologyKeys() []string

TopologyKeys is part of ServicePort interface.

type Endpoint Uses

type Endpoint interface {
    // String returns endpoint string.  An example format can be: `IP:Port`.
    // We take the returned value as ServiceEndpoint.Endpoint.
    String() string
    // GetIsLocal returns true if the endpoint is running in same host as kube-proxy, otherwise returns false.
    GetIsLocal() bool
    // GetTopology returns the topology information of the endpoint.
    GetTopology() map[string]string
    // IP returns IP part of the endpoint.
    IP() string
    // Port returns the Port part of the endpoint.
    Port() (int, error)
    // Equal checks if two endpoints are equal.
    Equal(Endpoint) bool
}

Endpoint in an interface which abstracts information about an endpoint. TODO: Rename functions to be consistent with ServicePort.

func FilterTopologyEndpoint Uses

func FilterTopologyEndpoint(nodeLabels map[string]string, topologyKeys []string, endpoints []Endpoint) []Endpoint

FilterTopologyEndpoint returns the appropriate endpoints based on the cluster topology. This uses the current node's labels, which contain topology information, and the required topologyKeys to find appropriate endpoints. If both the endpoint's topology and the current node have matching values for topologyKeys[0], the endpoint will be chosen. If no endpoints are chosen, toplogyKeys[1] will be considered, and so on. If either the node or the endpoint do not have values for a key, it is considered to not match.

If topologyKeys is specified, but no endpoints are chosen for any key, the the service has no viable endpoints for clients on this node, and connections should fail.

The special key "*" may be used as the last entry in topologyKeys to indicate "any endpoint" is acceptable.

If topologyKeys is not specified or empty, no topology constraints will be applied and this will return all endpoints.

type EndpointChangeTracker Uses

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

EndpointChangeTracker carries state about uncommitted changes to an arbitrary number of Endpoints, keyed by their namespace and name.

func NewEndpointChangeTracker Uses

func NewEndpointChangeTracker(hostname string, makeEndpointInfo makeEndpointFunc, isIPv6Mode *bool, recorder record.EventRecorder, endpointSlicesEnabled bool) *EndpointChangeTracker

NewEndpointChangeTracker initializes an EndpointsChangeMap

func (*EndpointChangeTracker) EndpointSliceUpdate Uses

func (ect *EndpointChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.EndpointSlice, removeSlice bool) bool

EndpointSliceUpdate updates given service's endpoints change map based on the <previous, current> endpoints pair. It returns true if items changed, otherwise return false. Will add/update/delete items of EndpointsChangeMap. If removeSlice is true, slice will be removed, otherwise it will be added or updated.

func (*EndpointChangeTracker) Update Uses

func (ect *EndpointChangeTracker) Update(previous, current *v1.Endpoints) bool

Update updates given service's endpoints change map based on the <previous, current> endpoints pair. It returns true if items changed, otherwise return false. Update can be used to add/update/delete items of EndpointsChangeMap. For example, Add item

- pass <nil, endpoints> as the <previous, current> pair.

Update item

- pass <oldEndpoints, endpoints> as the <previous, current> pair.

Delete item

- pass <endpoints, nil> as the <previous, current> pair.

type EndpointSliceCache Uses

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

EndpointSliceCache is used as a cache of EndpointSlice information.

func NewEndpointSliceCache Uses

func NewEndpointSliceCache(hostname string, isIPv6Mode *bool, recorder record.EventRecorder, makeEndpointInfo makeEndpointFunc) *EndpointSliceCache

NewEndpointSliceCache initializes an EndpointSliceCache.

type EndpointsMap Uses

type EndpointsMap map[ServicePortName][]Endpoint

EndpointsMap maps a service name to a list of all its Endpoints.

func (EndpointsMap) Update Uses

func (em EndpointsMap) Update(changes *EndpointChangeTracker) (result UpdateEndpointMapResult)

Update updates endpointsMap base on the given changes.

type Provider Uses

type Provider interface {
    config.EndpointsHandler
    config.EndpointSliceHandler
    config.ServiceHandler
    config.NodeHandler

    // Sync immediately synchronizes the Provider's current state to proxy rules.
    Sync()
    // SyncLoop runs periodic work.
    // This is expected to run as a goroutine or as the main loop of the app.
    // It does not return.
    SyncLoop()
}

Provider is the interface provided by proxier implementations.

type ServiceChangeTracker Uses

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

ServiceChangeTracker carries state about uncommitted changes to an arbitrary number of Services, keyed by their namespace and name.

func NewServiceChangeTracker Uses

func NewServiceChangeTracker(makeServiceInfo makeServicePortFunc, isIPv6Mode *bool, recorder record.EventRecorder) *ServiceChangeTracker

NewServiceChangeTracker initializes a ServiceChangeTracker

func (*ServiceChangeTracker) Update Uses

func (sct *ServiceChangeTracker) Update(previous, current *v1.Service) bool

Update updates given service's change map based on the <previous, current> service pair. It returns true if items changed, otherwise return false. Update can be used to add/update/delete items of ServiceChangeMap. For example, Add item

- pass <nil, service> as the <previous, current> pair.

Update item

- pass <oldService, service> as the <previous, current> pair.

Delete item

- pass <service, nil> as the <previous, current> pair.

type ServiceEndpoint Uses

type ServiceEndpoint struct {
    Endpoint        string
    ServicePortName ServicePortName
}

ServiceEndpoint is used to identify a service and one of its endpoint pair.

type ServiceMap Uses

type ServiceMap map[ServicePortName]ServicePort

ServiceMap maps a service to its ServicePort.

type ServicePort Uses

type ServicePort interface {
    // String returns service string.  An example format can be: `IP:Port/Protocol`.
    String() string
    // GetClusterIP returns service cluster IP in net.IP format.
    ClusterIP() net.IP
    // GetPort returns service port if present. If return 0 means not present.
    Port() int
    // GetSessionAffinityType returns service session affinity type
    SessionAffinityType() v1.ServiceAffinity
    // GetStickyMaxAgeSeconds returns service max connection age
    StickyMaxAgeSeconds() int
    // ExternalIPStrings returns service ExternalIPs as a string array.
    ExternalIPStrings() []string
    // LoadBalancerIPStrings returns service LoadBalancerIPs as a string array.
    LoadBalancerIPStrings() []string
    // GetProtocol returns service protocol.
    Protocol() v1.Protocol
    // LoadBalancerSourceRanges returns service LoadBalancerSourceRanges if present empty array if not
    LoadBalancerSourceRanges() []string
    // GetHealthCheckNodePort returns service health check node port if present.  If return 0, it means not present.
    HealthCheckNodePort() int
    // GetNodePort returns a service Node port if present. If return 0, it means not present.
    NodePort() int
    // GetOnlyNodeLocalEndpoints returns if a service has only node local endpoints
    OnlyNodeLocalEndpoints() bool
    // TopologyKeys returns service TopologyKeys as a string array.
    TopologyKeys() []string
}

ServicePort is an interface which abstracts information about a service.

type ServicePortName Uses

type ServicePortName struct {
    types.NamespacedName
    Port     string
    Protocol v1.Protocol
}

ServicePortName carries a namespace + name + portname. This is the unique identifier for a load-balanced service.

func (ServicePortName) String Uses

func (spn ServicePortName) String() string

type UpdateEndpointMapResult Uses

type UpdateEndpointMapResult struct {
    // HCEndpointsLocalIPSize maps an endpoints name to the length of its local IPs.
    HCEndpointsLocalIPSize map[types.NamespacedName]int
    // StaleEndpoints identifies if an endpoints service pair is stale.
    StaleEndpoints []ServiceEndpoint
    // StaleServiceNames identifies if a service is stale.
    StaleServiceNames []ServicePortName
    // List of the trigger times for all endpoints objects that changed. It's used to export the
    // network programming latency.
    // NOTE(oxddr): this can be simplified to []time.Time if memory consumption becomes an issue.
    LastChangeTriggerTimes map[types.NamespacedName][]time.Time
}

UpdateEndpointMapResult is the updated results after applying endpoints changes.

type UpdateServiceMapResult Uses

type UpdateServiceMapResult struct {
    // HCServiceNodePorts is a map of Service names to node port numbers which indicate the health of that Service on this Node.
    // The value(uint16) of HCServices map is the service health check node port.
    HCServiceNodePorts map[types.NamespacedName]uint16
    // UDPStaleClusterIP holds stale (no longer assigned to a Service) Service IPs that had UDP ports.
    // Callers can use this to abort timeout-waits or clear connection-tracking information.
    UDPStaleClusterIP sets.String
}

UpdateServiceMapResult is the updated results after applying service changes.

func UpdateServiceMap Uses

func UpdateServiceMap(serviceMap ServiceMap, changes *ServiceChangeTracker) (result UpdateServiceMapResult)

UpdateServiceMap updates ServiceMap based on the given changes.

Directories

PathSynopsis
apis
apis/config
apis/config/fuzzer
apis/config/scheme
apis/config/v1alpha1
apis/config/validation
configPackage config provides decoupling between various configuration sources (etcd, files,...) and the pieces that actually care about them (loadbalancer, proxy).
healthcheckPackage healthcheck provides tools for serving kube-proxy healthchecks.
iptables
ipvs
ipvs/testing
metaproxier
metrics
userspace
util
util/iptables
util/testing
winkernel
winuserspace

Package proxy imports 19 packages (graph) and is imported by 434 packages. Updated 2020-05-29. Refresh now. Tools for package owners.