Documentation ¶
Index ¶
- Variables
- type Cluster
- func (c *Cluster) AddClusterEventHandler(handler ClusterNodeEventHandler)
- func (c *Cluster) AliveNodes() sets.String
- func (c *Cluster) RejoinNodes()
- func (c *Cluster) Run(stopCh <-chan struct{})
- func (c *Cluster) SelectNodeForIP(ip, externalIPPool string, filters ...func(string) bool) (string, error)
- func (c *Cluster) ShouldSelectIP(ip, externalIPPool string, filters ...func(string) bool) (bool, error)
- type ClusterNodeEventHandler
- type Interface
- type Memberlist
Constants ¶
This section is empty.
Variables ¶
var ErrNoNodeAvailable = errors.New("no Node available")
ErrNoNodeAvailable is the error returned if no Node is chosen in SelectNodeForIP and ShouldSelectIP.
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster implements ClusterInterface.
func NewCluster ¶
func NewCluster( nodeIP net.IP, clusterBindPort int, nodeName string, nodeInformer coreinformers.NodeInformer, externalIPPoolInformer crdinformers.ExternalIPPoolInformer, ml Memberlist, ) (*Cluster, error)
NewCluster returns a new *Cluster.
func (*Cluster) AddClusterEventHandler ¶
func (c *Cluster) AddClusterEventHandler(handler ClusterNodeEventHandler)
AddClusterEventHandler adds a clusterNodeEventHandler, which will run when consistentHashMap is updated, due to an ExternalIPPool or Node event.
func (*Cluster) AliveNodes ¶ added in v1.5.0
AliveNodes returns the list of nodeNames in the cluster.
func (*Cluster) RejoinNodes ¶ added in v1.7.2
func (c *Cluster) RejoinNodes()
RejoinNodes rejoins Nodes that were removed from the member list by memberlist because they were unreachable for more than 15 seconds (the GossipToTheDeadTime we are using). Without it, once there is a network downtime lasting more than 15 seconds, the agent wouldn't try to reach any other Node and would think it's the only alive Node until it's restarted.
func (*Cluster) Run ¶
func (c *Cluster) Run(stopCh <-chan struct{})
Run will join all the other K8s Nodes in a memberlist cluster and will create defaultWorkers workers (go routines) which will process the ExternalIPPool or Node events from the work queue.
func (*Cluster) SelectNodeForIP ¶ added in v1.5.0
func (c *Cluster) SelectNodeForIP(ip, externalIPPool string, filters ...func(string) bool) (string, error)
SelectNodeForIP returns the closest item (Node name) in the hash to the provided key (IP) and ExternalIPPool.
func (*Cluster) ShouldSelectIP ¶ added in v1.5.0
func (c *Cluster) ShouldSelectIP(ip, externalIPPool string, filters ...func(string) bool) (bool, error)
ShouldSelectIP returns true if the local Node selected as the owner Node of the IP in the specific ExternalIPPool. The local Node in the cluster holds the same consistent hash ring for each ExternalIPPool, consistentHash.Get gets the closest item (Node name) in the hash to the provided key (IP), if the name of the local Node is equal to the name of the selected Node, returns true.
type ClusterNodeEventHandler ¶ added in v1.5.0
type ClusterNodeEventHandler func(objName string)