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(readyFile string, 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 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.
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, vc *varnish.Controller, hc *haproxy.Controller, infFactory informers.SharedInformerFactory, vcrInfFactory vcr_informers.SharedInformerFactory, vsecrInfFactory informers.SharedInformerFactory, tsecrInfFactory informers.SharedInformerFactory, incomplRetryDelay time.Duration, ) (*IngressController, error)
NewIngressController creates a controller.
log: logger initialized at startup ingClass: value of the ingress.class Ingress annotation kubeClient: k8s client initialized at startup vc: Varnish controller infFactory: SharedInformerFactory to create informers & listers for the k8s standard client APIs vcrInfFactory: SharedInformerFactory for the project's own client APIs
func (*IngressController) Run ¶
func (ingc *IngressController) Run( readyFile string, 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, ) *NamespaceQueues
NewNamespaceQueues creates a NamespaceQueues object.
log: logger initialized at startup ingClass: value of the ingress.class Ingress annotation vController: Varnish controller initialied at startup listers: client-go/lister instance for each resource type client: k8s API client initialized at startup recorder: Event broadcaster initialized at startup
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.