proxy

package
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2021 License: Apache-2.0 Imports: 34 Imported by: 2

Documentation

Index

Constants

View Source
const (
	KubeDummyIf       = "kube-dummy-if"
	KubeTunnelIf      = "kube-tunnel-if"
	IfaceNotFound     = "Link not found"
	IfaceHasAddr      = "file exists"
	IfaceHasNoAddr    = "cannot assign requested address"
	IpvsServerExists  = "file exists"
	IpvsMaglevHashing = "mh"
	IpvsSvcFSched1    = "flag-1"
	IpvsSvcFSched2    = "flag-2"
	IpvsSvcFSched3    = "flag-3"

	LeaderElectionRecordAnnotationKey = "control-plane.alpha.kubernetes.io/leader"
)

Variables

View Source
var (
	NodeIP net.IP
)

Functions

This section is empty.

Types

type LinuxNetworking

type LinuxNetworking interface {
	// contains filtered or unexported methods
}

LinuxNetworking interface contains all linux networking subsystem calls

type LinuxNetworkingMock

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

LinuxNetworkingMock is a mock implementation of LinuxNetworking.

    func TestSomethingThatUsesLinuxNetworking(t *testing.T) {

        // make and configure a mocked LinuxNetworking
        mockedLinuxNetworking := &LinuxNetworkingMock{
            cleanupMangleTableRuleFunc: func(ip string, protocol string, port string, fwmark string) error {
	               panic("mock out the cleanupMangleTableRule method")
            },
            getKubeDummyInterfaceFunc: func() (netlink.Link, error) {
	               panic("mock out the getKubeDummyInterface method")
            },
            ipAddrAddFunc: func(iface netlink.Link, ip string, addRoute bool) error {
	               panic("mock out the ipAddrAdd method")
            },
            ipAddrDelFunc: func(iface netlink.Link, ip string) error {
	               panic("mock out the ipAddrDel method")
            },
            ipvsAddFWMarkServiceFunc: func(vip net.IP, protocol uint16, port uint16, persistent bool, persistentTimeout int32, scheduler string, flags schedFlags) (*ipvs.Service, error) {
	               panic("mock out the ipvsAddFWMarkService method")
            },
            ipvsAddServerFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination) error {
	               panic("mock out the ipvsAddServer method")
            },
            ipvsAddServiceFunc: func(svcs []*ipvs.Service, vip net.IP, protocol uint16, port uint16, persistent bool, persistentTimeout int32, scheduler string, flags schedFlags) (*ipvs.Service, error) {
	               panic("mock out the ipvsAddService method")
            },
            ipvsDelDestinationFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination) error {
	               panic("mock out the ipvsDelDestination method")
            },
            ipvsDelServiceFunc: func(ipvsSvc *ipvs.Service) error {
	               panic("mock out the ipvsDelService method")
            },
            ipvsGetDestinationsFunc: func(ipvsSvc *ipvs.Service) ([]*ipvs.Destination, error) {
	               panic("mock out the ipvsGetDestinations method")
            },
            ipvsGetServicesFunc: func() ([]*ipvs.Service, error) {
	               panic("mock out the ipvsGetServices method")
            },
            ipvsNewDestinationFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination) error {
	               panic("mock out the ipvsNewDestination method")
            },
            ipvsNewServiceFunc: func(ipvsSvc *ipvs.Service) error {
	               panic("mock out the ipvsNewService method")
            },
            ipvsUpdateDestinationFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination) error {
	               panic("mock out the ipvsUpdateDestination method")
            },
            ipvsUpdateServiceFunc: func(ipvsSvc *ipvs.Service) error {
	               panic("mock out the ipvsUpdateService method")
            },
            prepareEndpointForDsrFunc: func(containerId string, endpointIP string, vip string) error {
	               panic("mock out the prepareEndpointForDsr method")
            },
            setupPolicyRoutingForDSRFunc: func() error {
	               panic("mock out the setupPolicyRoutingForDSR method")
            },
            setupRoutesForExternalIPForDSRFunc: func(in1 serviceInfoMap) error {
	               panic("mock out the setupRoutesForExternalIPForDSR method")
            },
        }

        // use mockedLinuxNetworking in code that requires LinuxNetworking
        // and then make assertions.

    }

type NetworkServicesController

type NetworkServicesController struct {
	MetricsEnabled bool

	ProxyFirewallSetup *sync.Cond

	ServiceEventHandler   cache.ResourceEventHandler
	EndpointsEventHandler cache.ResourceEventHandler
	// contains filtered or unexported fields
}

NetworkServicesController struct stores information needed by the controller

func NewNetworkServicesController

func NewNetworkServicesController(clientset kubernetes.Interface,
	config *options.KubeRouterConfig, svcInformer cache.SharedIndexInformer,
	epInformer cache.SharedIndexInformer, podInformer cache.SharedIndexInformer, ipsetMutex *sync.Mutex) (*NetworkServicesController, error)

NewNetworkServicesController returns NetworkServicesController object

func (*NetworkServicesController) Cleanup

func (nsc *NetworkServicesController) Cleanup()

Cleanup cleans all the configurations (IPVS, iptables, links) done

func (*NetworkServicesController) OnEndpointsUpdate

func (nsc *NetworkServicesController) OnEndpointsUpdate(ep *api.Endpoints)

OnEndpointsUpdate handle change in endpoints update from the API server

func (*NetworkServicesController) OnServiceUpdate

func (nsc *NetworkServicesController) OnServiceUpdate(svc *api.Service)

OnServiceUpdate handle change in service update from the API server

func (*NetworkServicesController) Run

func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup)

Run periodically sync ipvs configuration to reflect desired state of services and endpoints

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL