varnish

package
v0.0.0-...-cc11b02 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: BSD-2-Clause Imports: 14 Imported by: 0

README

GoDoc

Documentation

Overview

Package varnish encapsulates interaction with Varnish instances to transform desired states from Ingress and VarnishConfig configs to the actual state of the cluster. Only this package imports varnishapi/pkg/admin to interact with the CLI of each Varnish instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdmError

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

AdmError encapsulates an error encountered for an individual Varnish instance, and satisfies the Error interface.

func (AdmError) Error

func (vadmErr AdmError) Error() string

Error returns an error meesage for an error encountered at a Varnish instance, identifying the instance by its Pod namespace/name if known, and its Endpoint address (internal IP) and admin port.

type AdmErrors

type AdmErrors []AdmError

AdmErrors is a collection of errors encountered at Varnish instances. Most attempts to sync the state of Varnish instances do not break off at the first error; the attempt is repeated for each instance in a cluster, collecting error information along the way. This object contains error information for each instance in a cluster that failed to sync. The type satisifies the Error interface.

func (AdmErrors) Error

func (vadmErrs AdmErrors) Error() string

Error returns an error message that includes errors for each instance in a Varnish cluster that failed a sync operation, where each instance is identified by it Endpoint (internal IP) and admin port.

type Controller

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

Controller encapsulates information about each Varnish cluster deployed as Ingress implementations in the cluster, and their current states.

func NewVarnishController

func NewVarnishController(
	log *logrus.Logger,
	monIntvl time.Duration,
) *Controller

NewVarnishController returns an instance of Controller.

log: logger object initialized at startup

func (*Controller) AddOrUpdateVarnishSvc

func (vc *Controller) AddOrUpdateVarnishSvc(
	key string,
	addrs []vcl.Address,
	secrName string,
	loadVCL bool,
) update.Status

AddOrUpdateVarnishSvc causes a sync for the Varnish Service identified by namespace/name key.

addrs: list of admin addresses for instances in the Service
       (internal IPs and admin ports)
secrName: namespace/name of the admin secret to use for the
          Service
loadVCL: true if the VCL config for the Service should be
         reloaded

func (*Controller) DeleteAdmSecret

func (vc *Controller) DeleteAdmSecret(name string)

DeleteAdmSecret removes the secret identified by the namespace/name key.

func (*Controller) DeleteVarnishSvc

func (vc *Controller) DeleteVarnishSvc(key string) update.Status

DeleteVarnishSvc is called on the Delete event for the Varnish Service identified by the namespace/name key. The Varnish instance is set to the unready state, and no further action is taken (other resources in the cluster may shut down the Varnish instances).

func (*Controller) EvtGenerator

func (vc *Controller) EvtGenerator(svcEvt interfaces.SvcEventGenerator)

EvtGenerator sets the object that implements interface SvcEventGenerator, and will be used by the monitor goroutine to generate Events for Varnish Services.

func (*Controller) HasConfig

func (vc *Controller) HasConfig(svcKey string, addrs []vcl.Address,
	spec vcl.Spec, ingsMeta map[string]Meta, vcfgMeta Meta,
	bcfgMeta map[string]Meta) bool

HasConfig returns true iff a configuration is already loaded for a Varnish Service (so a new sync attempt is not necessary).

svcKey: namespace/name key for the Varnish Service
spec: VCL specification derived from the configuration
ingsMeta: Ingress meta-data
vcfgMeta: VarnishConfig meta-data
bcfgMeta: BackendConfig meta-data

func (*Controller) HasVarnishSvc

func (vc *Controller) HasVarnishSvc(svcKey string) bool

HasVarnishSvc returns true iff the configuration of the service identified by svcKey has been specified for the Varnish controller.

func (*Controller) Quit

func (vc *Controller) Quit()

Quit stops the Varnish controller.

func (*Controller) SetAdmSecret

func (vc *Controller) SetAdmSecret(key string, secret []byte)

SetAdmSecret stores the Secret data identified by the namespace/name key.

func (*Controller) SetNotReady

func (vc *Controller) SetNotReady(svcKey string) error

SetNotReady may be called on the Delete event on an Ingress, if no Ingresses remain that are to be implemented by a Varnish Service. The Service is set to the not configured state, by relabelling VCL so that the "configured" endpoint is not answered with status 200. Also set the "regular" label to the "not available" config.

func (*Controller) Start

func (vc *Controller) Start()

Start initiates the Varnish controller and starts the monitor goroutine.

func (*Controller) Update

func (vc *Controller) Update(
	svcKey string,
	spec vcl.Spec,
	addrs []vcl.Address,
	ingsMeta map[string]Meta,
	vcfgMeta Meta,
	bcfgMeta map[string]Meta,
) update.Status

Update a Varnish Service to implement an configuration.

svcKey: namespace/name key for the Service
spec: VCL spec corresponding to the configuration
ingsMeta: Ingress meta-data
vcfgMeta: VarnishConfig meta-data
bcfgMeta: BackendConfig meta-data

func (*Controller) UpdateSvcForSecret

func (vc *Controller) UpdateSvcForSecret(
	svcKey, secretKey string,
) update.Status

UpdateSvcForSecret associates the Secret identified by the namespace/name secretKey with the Varnish Service identified by the namespace/name svcKey. The Service is newly synced if necessary.

type Meta

type Meta struct {
	Key string
	UID string
	Ver string
}

Meta encapsulates meta-data for the resource types that enter into a Varnish configuration: Ingress, VarnishConfig and BackendConfig.

Key: namespace/name
UID: UID field from the resource meta-data
Ver: ResourceVersion field from the resource meta-data

Directories

Path Synopsis
Package vcl encapsulates representations of a VCL configuration derived from Ingress and VarnishConfig specifications, and checking the representations for equivalence (to check if new syncs are necessary).
Package vcl encapsulates representations of a VCL configuration derived from Ingress and VarnishConfig specifications, and checking the representations for equivalence (to check if new syncs are necessary).

Jump to

Keyboard shortcuts

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