k8s

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NodeHasHealthyEndpoint added in v0.2.0

func NodeHasHealthyEndpoint(eps *v1.Endpoints, node string) bool

NodeHasHealthyEndpoint return true if this node has at least one healthy endpoint.

Types

type Client

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

Client watches a Kubernetes cluster and translates events into Controller method calls.

func NewClient

func NewClient(name, masterAddr, kubeconfig string, watchEps bool, ctrls ...Controller) (*Client, error)

NewClient connects to masterAddr, using kubeconfig to authenticate, and calls methods on ctrls as the cluster state changes.

The client uses the given name to identify itself to the cluster (e.g. when logging events). watchEps defines whether ctrl cares about the endpoints associated with a service. If watchEps is false, the controller will not watch endpoint objects, and the endpoints in SetBalancer calls will always be nil.

func (*Client) Errorf

func (c *Client) Errorf(svc *v1.Service, kind, msg string, args ...interface{})

Errorf logs an error event about svc to the Kubernetes cluster.

func (*Client) Infof

func (c *Client) Infof(svc *v1.Service, kind, msg string, args ...interface{})

Infof logs an informational event about svc to the Kubernetes cluster.

func (*Client) NewLeaderElector added in v0.2.0

func (c *Client) NewLeaderElector(a *arp.Announce, lockName string) (*le.LeaderElector, error)

NewLeaderElector returns a new LeaderElector used for endpoint leader election using c.

func (*Client) Run

func (c *Client) Run(httpPort int) error

Run watches for events on the Kubernetes cluster, and dispatches calls to the Controller.

func (*Client) Update

func (c *Client) Update(svc *v1.Service) (*v1.Service, error)

Update writes svc back into the Kubernetes cluster. If successful, the updated Service is returned. Note that changes to svc.Status are not propagated, for that you need to call UpdateStatus.

func (*Client) UpdateStatus

func (c *Client) UpdateStatus(svc *v1.Service) error

UpdateStatus writes the protected "status" field of svc back into the Kubernetes cluster.

type Controller

type Controller interface {
	// SetBalancer is called whenever a Service or its related
	// Endpoints change. When the Service is deleted, SetBalancer is
	// called with svc=nil and eps=nil.
	SetBalancer(name string, svc *v1.Service, eps *v1.Endpoints) error
	// SetConfig is called whenever the MetalLB configuration for the
	// cluster changes. If the config is deleted from the cluster,
	// SetConfig is called with cfg=nil.
	SetConfig(cfg *config.Config) error
	// MarkSynced is called when SetBalancer has been called at least
	// once for every Service in the cluster, and SetConfig has been
	// called.
	MarkSynced()
}

A Controller takes action when watched Kubernetes objects change.

Jump to

Keyboard shortcuts

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