controllers

package
v0.2.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KUBE_DUMMY_IF      = "kube-dummy-if"
	KUBE_TUNNEL_IF     = "kube-tunnel-if"
	IFACE_NOT_FOUND    = "Link not found"
	IFACE_HAS_ADDR     = "file exists"
	IFACE_HAS_NO_ADDR  = "cannot assign requested address"
	IPVS_SERVER_EXISTS = "file exists"

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

Variables

This section is empty.

Functions

This section is empty.

Types

type ControllerHeartbeat

type ControllerHeartbeat struct {
	Component     string
	LastHeartBeat time.Time
}

ControllerHeartbeat is the structure to hold the heartbeats sent by controllers

type HealthController

type HealthController struct {
	HealthPort  uint16
	HTTPEnabled bool
	Status      HealthStats
	Config      *options.KubeRouterConfig
}

HealthController reports the health of the controller loops as a http endpoint

func NewHealthController

func NewHealthController(config *options.KubeRouterConfig) (*HealthController, error)

NewHealthController creates a new health controller and returns a reference to it

func (*HealthController) CheckHealth

func (hc *HealthController) CheckHealth() bool

CheckHealth evaluates the time since last heartbeat to decide if the controller is running or not

func (*HealthController) HandleHeartbeat

func (hc *HealthController) HandleHeartbeat(beat *ControllerHeartbeat)

HandleHeartbeat handles received heartbeats on the health channel

func (*HealthController) Handler

func (hc *HealthController) Handler(w http.ResponseWriter, req *http.Request)

Handler writes HTTP responses to the health path

func (*HealthController) Run

func (hc *HealthController) Run(healthChan <-chan *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup) error

Run starts the HealthController

type HealthStats

type HealthStats struct {
	sync.Mutex
	Healthy                        bool
	MetricsControllerAlive         time.Time
	NetworkPolicyControllerAlive   time.Time
	NetworkRoutingControllerAlive  time.Time
	NetworkServicesControllerAlive time.Time
}

HealthStats is holds the latest heartbeats

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("TODO: mock out the cleanupMangleTableRule method")
            },
            getKubeDummyInterfaceFunc: func() (netlink.Link, error) {
	               panic("TODO: mock out the getKubeDummyInterface method")
            },
            ipAddrAddFunc: func(iface netlink.Link, ip string) error {
	               panic("TODO: mock out the ipAddrAdd method")
            },
            ipAddrDelFunc: func(iface netlink.Link, ip string) error {
	               panic("TODO: mock out the ipAddrDel method")
            },
            ipvsAddFWMarkServiceFunc: func(vip net.IP, protocol uint16, port uint16, persistent bool, scheduler string) (*ipvs.Service, error) {
	               panic("TODO: mock out the ipvsAddFWMarkService method")
            },
            ipvsAddServerFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination, local bool, podCidr string) error {
	               panic("TODO: mock out the ipvsAddServer method")
            },
            ipvsAddServiceFunc: func(svcs []*ipvs.Service, vip net.IP, protocol uint16, port uint16, persistent bool, scheduler string) (*ipvs.Service, error) {
	               panic("TODO: mock out the ipvsAddService method")
            },
            ipvsDelDestinationFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination) error {
	               panic("TODO: mock out the ipvsDelDestination method")
            },
            ipvsDelServiceFunc: func(ipvsSvc *ipvs.Service) error {
	               panic("TODO: mock out the ipvsDelService method")
            },
            ipvsGetDestinationsFunc: func(ipvsSvc *ipvs.Service) ([]*ipvs.Destination, error) {
	               panic("TODO: mock out the ipvsGetDestinations method")
            },
            ipvsGetServicesFunc: func() ([]*ipvs.Service, error) {
	               panic("TODO: mock out the ipvsGetServices method")
            },
            ipvsNewDestinationFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination) error {
	               panic("TODO: mock out the ipvsNewDestination method")
            },
            ipvsNewServiceFunc: func(ipvsSvc *ipvs.Service) error {
	               panic("TODO: mock out the ipvsNewService method")
            },
            ipvsUpdateDestinationFunc: func(ipvsSvc *ipvs.Service, ipvsDst *ipvs.Destination) error {
	               panic("TODO: mock out the ipvsUpdateDestination method")
            },
            ipvsUpdateServiceFunc: func(ipvsSvc *ipvs.Service) error {
	               panic("TODO: mock out the ipvsUpdateService method")
            },
            prepareEndpointForDsrFunc: func(containerId string, endpointIP string, vip string) error {
	               panic("TODO: mock out the prepareEndpointForDsr method")
            },
            setupPolicyRoutingForDSRFunc: func() error {
	               panic("TODO: mock out the setupPolicyRoutingForDSR method")
            },
            setupRoutesForExternalIPForDSRFunc: func(in1 serviceInfoMap) error {
	               panic("TODO: mock out the setupRoutesForExternalIPForDSR method")
            },
        }

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

    }

type MetricsController

type MetricsController struct {
	MetricsPath string
	MetricsPort uint16
	// contains filtered or unexported fields
}

MetricsController Holds settings for the metrics controller

func NewMetricsController

func NewMetricsController(clientset kubernetes.Interface, config *options.KubeRouterConfig) (*MetricsController, error)

NewMetricsController returns new MetricController object

func (*MetricsController) Run

func (mc *MetricsController) Run(healthChan chan<- *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup) error

Run prometheus metrics controller

type NetworkPolicyController

type NetworkPolicyController struct {
	MetricsEnabled bool

	PodEventHandler           cache.ResourceEventHandler
	NamespaceEventHandler     cache.ResourceEventHandler
	NetworkPolicyEventHandler cache.ResourceEventHandler
	// contains filtered or unexported fields
}

NetworkPolicyController strcut to hold information required by NetworkPolicyController

func NewNetworkPolicyController

func NewNetworkPolicyController(clientset kubernetes.Interface,
	config *options.KubeRouterConfig, podInformer cache.SharedIndexInformer,
	npInformer cache.SharedIndexInformer, nsInformer cache.SharedIndexInformer) (*NetworkPolicyController, error)

NewNetworkPolicyController returns new NetworkPolicyController object

func (*NetworkPolicyController) Cleanup

func (npc *NetworkPolicyController) Cleanup()

Cleanup cleanup configurations done

func (*NetworkPolicyController) ListNamespaceByLabels

func (npc *NetworkPolicyController) ListNamespaceByLabels(set labels.Set) ([]*api.Namespace, error)

func (*NetworkPolicyController) ListPodsByNamespaceAndLabels

func (npc *NetworkPolicyController) ListPodsByNamespaceAndLabels(namespace string, labelsToMatch labels.Set) (ret []*api.Pod, err error)

func (*NetworkPolicyController) OnNamespaceUpdate

func (npc *NetworkPolicyController) OnNamespaceUpdate(obj interface{})

OnNamespaceUpdate handles updates to namespace from kubernetes api server

func (*NetworkPolicyController) OnNetworkPolicyUpdate

func (npc *NetworkPolicyController) OnNetworkPolicyUpdate(obj interface{})

OnNetworkPolicyUpdate handles updates to network policy from the kubernetes api server

func (*NetworkPolicyController) OnPodUpdate

func (npc *NetworkPolicyController) OnPodUpdate(obj interface{})

OnPodUpdate handles updates to pods from the Kubernetes api server

func (*NetworkPolicyController) Run

func (npc *NetworkPolicyController) Run(healthChan chan<- *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup)

Run runs forver till we receive notification on stopCh

func (*NetworkPolicyController) Sync

func (npc *NetworkPolicyController) Sync() error

Sync synchronizes iptables to desired state of network policies

type NetworkRoutingController

type NetworkRoutingController struct {
	MetricsEnabled bool

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

NetworkRoutingController is struct to hold necessary information required by controller

func NewNetworkRoutingController

func NewNetworkRoutingController(clientset kubernetes.Interface,
	kubeRouterConfig *options.KubeRouterConfig,
	nodeInformer cache.SharedIndexInformer, svcInformer cache.SharedIndexInformer,
	epInformer cache.SharedIndexInformer) (*NetworkRoutingController, error)

NewNetworkRoutingController returns new NetworkRoutingController object

func (*NetworkRoutingController) Cleanup

func (nrc *NetworkRoutingController) Cleanup()

Cleanup performs the cleanup of configurations done

func (*NetworkRoutingController) OnEndpointsUpdate

func (nrc *NetworkRoutingController) OnEndpointsUpdate(obj interface{})

func (*NetworkRoutingController) OnNodeUpdate

func (nrc *NetworkRoutingController) OnNodeUpdate(obj interface{})

OnNodeUpdate Handle updates from Node watcher. Node watcher calls this method whenever there is new node is added or old node is deleted. So peer up with new node and drop peering from old node

func (*NetworkRoutingController) OnServiceDelete

func (nrc *NetworkRoutingController) OnServiceDelete(obj interface{})

func (*NetworkRoutingController) OnServiceUpdate

func (nrc *NetworkRoutingController) OnServiceUpdate(obj interface{})

func (*NetworkRoutingController) Run

func (nrc *NetworkRoutingController) Run(healthChan chan<- *ControllerHeartbeat, stopCh <-chan struct{}, wg *sync.WaitGroup)

Run runs forever until we are notified on stop channel

type NetworkServicesController

type NetworkServicesController struct {
	MetricsEnabled bool

	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) (*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(obj interface{})

OnEndpointsUpdate handle change in endpoints update from the API server

func (*NetworkServicesController) OnServiceUpdate

func (nsc *NetworkServicesController) OnServiceUpdate(obj interface{})

OnServiceUpdate handle change in service update from the API server

func (*NetworkServicesController) Run

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

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