Documentation
¶
Overview ¶
Package controller provides access to the k8s server API and drives the main loops of the Ingress controller. It sets up informers, lister, event handlers, queues and workers, and it starts and stops the workers that sync resources.
Only this package imports packages from k8s.io and from the project's own client APIs (in pkg/client).
Index ¶
- func IncompleteIfNotFound(err error, format string, args ...interface{}) update.Status
- func InitMetrics()
- func ServeMetrics(log *logrus.Logger, port uint16)
- type IngressController
- func (ingc *IngressController) Run(readyFunc ReadyFunc, syncedFunc ReadyFunc, metricsPort uint16, devMode bool)
- func (ingc *IngressController) Stop()
- func (ingc *IngressController) SvcInfoEvent(svcKey, reason, msgFmt string, args ...interface{})
- func (ingc *IngressController) SvcWarnEvent(svcKey, reason, msgFmt string, args ...interface{})
- type Listers
- type NamespaceQueues
- type NamespaceWorker
- type ReadyFunc
- type SyncObj
- type SyncType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IncompleteIfNotFound ¶
IncompleteIfNotFound returns an update.Status of type Incomplete if err is a k8s NotFound error, as determined by errors.IsNotFound() in k8s.io/apimachinery/pkg/api/errors. Otherwise, a Recoverable Status is returned.
func InitMetrics ¶
func InitMetrics()
InitMetrics sets the prometheus provider for the workqueue metrics, and registers the counter vectors.
func ServeMetrics ¶
ServeMetrics executes the HTTP Handler for the /metrics endpoint.
Types ¶
type IngressController ¶
type IngressController struct {
// contains filtered or unexported fields
}
IngressController watches Kubernetes API and reconfigures Varnish via varnish.Controller when needed.
func NewIngressController ¶
func NewIngressController( log *logrus.Logger, ingClass string, namespace string, devMode bool, varnishImpl string, kubeClient kubernetes.Interface, vingClient clientset.Interface, vc *varnish.Controller, hc *haproxy.Controller, resyncPeriod time.Duration, incomplRetryDelay time.Duration, maxSyncRetries uint, ) (*IngressController, error)
NewIngressController creates a controller.
log: logger initialized at startup ingClass: value of the ingress.class Ingress annotation namespace: namespace to which the controller is restricted devMode: true if development mode was specfied at invocation varnishImpl: name of the varnish implementation (varnish, klarlack) kubeClient: k8s client initialized at startup vingClient: go-client generated clientset vc: Varnish controller hc: haproxy controller resyncPeriod: if > 0, update even if nothing changed incomplRetryDelay: duration until SyncIncomplete errors are re-queued maxSyncRetries: max re-queues for SyncIncomplete or SyncRecoverable
func (*IngressController) Run ¶
func (ingc *IngressController) Run( readyFunc ReadyFunc, syncedFunc ReadyFunc, metricsPort uint16, devMode bool, )
Run the Ingress controller -- start the informers in goroutines, wait for the caches to sync, and call Run() for the NamespaceQueues. Then block until Stop() is invoked.
If readyFile is non-empty, it is the path of a file to touch when the controller is ready (after informers have launched).
func (*IngressController) Stop ¶
func (ingc *IngressController) Stop()
Stop the Ingress controller -- signal the workers to stop.
func (*IngressController) SvcInfoEvent ¶
func (ingc *IngressController) SvcInfoEvent(svcKey, reason, msgFmt string, args ...interface{})
SvcInfoEvent generates an Event with type "Normal" for the Service whose namespace/name is svcKey.
func (*IngressController) SvcWarnEvent ¶
func (ingc *IngressController) SvcWarnEvent(svcKey, reason, msgFmt string, args ...interface{})
SvcWarnEvent generates an Event with type "Warning" for the Service whose namespace/name is svcKey.
type Listers ¶
type Listers struct {
// contains filtered or unexported fields
}
Listers aggregates listers from k8s.io/client-go/listers for the various resource types of interested. These are initialized by IngressController, and handed off to NamespaceWorker workers to read data from the client-go cache.
type NamespaceQueues ¶
type NamespaceQueues struct {
Queue workqueue.RateLimitingInterface
// contains filtered or unexported fields
}
NamespaceQueues reads from the main queue to which informers add new work items from all namespaces. The worker reads items from the queue and places them on separate queues for NamespaceWorkers responsible for each namespace.
func NewNamespaceQueues ¶
func NewNamespaceQueues( log *logrus.Logger, ingClass string, vController *varnish.Controller, hController *haproxy.Controller, listers *Listers, client kubernetes.Interface, recorder record.EventRecorder, incomplRetryDelay time.Duration, devMode bool, varnishImpl string, maxSyncRetries uint, ) *NamespaceQueues
NewNamespaceQueues creates a NamespaceQueues object.
log: logger initialized at startup ingClass: value of the ingress.class Ingress annotation vController: Varnish controller initialized at startup hController: haproxy controller initialized at startup listers: client-go/lister instance for each resource type client: k8s API client initialized at startup recorder: Event broadcaster initialized at startup incomplRetryDelay: duration until SyncIncomplete errors are re-queued devMode: true if development mode was specified at invocation varnishImpl: name of the varnish implementation (varnish, klarlack) maxSyncRetries: max re-queues for SyncIncomplete or SyncRecoverable
func (*NamespaceQueues) Run ¶
func (qs *NamespaceQueues) Run()
Run comprises the main loop of the controller, reading from the main queue of work items and handing them off to workers for each namespace.
func (*NamespaceQueues) Stop ¶
func (qs *NamespaceQueues) Stop()
Stop shuts down the main queue loop initiated by Run(), and in turn shuts down all of the NamespaceWorkers.
func (*NamespaceQueues) StopNS ¶
func (qs *NamespaceQueues) StopNS(ns string)
StopNS stops the queue for a namespace and its associated worker. The NamespaceWorker object is de-referenced, becoming available for garbage collection.
type NamespaceWorker ¶
type NamespaceWorker struct {
// contains filtered or unexported fields
}
NamespaceWorker serves fanout of work items to workers for each namespace for which the controller is notified about a resource update. The NamespaceQueues object creates a new instance when it reads an item from a new namespace from its main queue. Each worker has its own queue and listers filtered for its namespace. Thus each namespace is synced separately and sequentially, and all of the namespaces are synced in parallel.
type ReadyFunc ¶
type ReadyFunc func(ingc *IngressController) (string, error)
ReadyFunc typed arguments are called by Run() when certain stages have completed
type SyncObj ¶
type SyncObj struct {
Type SyncType
Obj interface{}
}
SyncObj wraps the object for which event handlers are notified, and encodes the sync event. These are the objects passed into the queues for workers.
func NewSyncObj ¶
NewSyncObj creates a SyncObj with check that it is not doubly wrapping
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mock2mocktest is to test the controller "mocked end to mocked end"
|
Package mock2mocktest is to test the controller "mocked end to mocked end" |