varnish

package
v0.0.0-...-1cc3a81 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: BSD-2-Clause Imports: 16 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.

Package varnish instance handler abstraction

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 NewController

func NewController(
	log *logrus.Logger,
	monIntvl time.Duration,
	newVarnishInst HandlerFactory,
) *Controller

NewController 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(svcName string, addrs []vcl.Address,
	nextSpec *vcl.SealedSpec,
) bool

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

svcName: namespace/name key for the Varnish Service
spec: VCL specification derived from the configuration

func (*Controller) HasVarnishSvc

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

HasVarnishSvc returns true iff the configuration of the service identified by svcName 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(svcName 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 goroutines.

func (*Controller) Update

func (vc *Controller) Update(
	svcName string,
	sealed *vcl.SealedSpec,
	addrs []vcl.Address,
	secrName string,
) update.Status

Update a Varnish Service to implement an configuration.

svcName: namespace/name key for the Service
spec: VCL spec corresponding to the configuration
addrs: addresses of the Varnish service instances

func (*Controller) UpdateSvcForSecret

func (vc *Controller) UpdateSvcForSecret(
	svcName, secretName string,
) update.Status

UpdateSvcForSecret associates the Secret identified by the namespace/name secretKey with the Varnish Service identified by the namespace/name svcName.

type Handler

type Handler interface {
	String() string
	Addr() string
	SetCfgLabel(vc *Controller, cfg, lbl string, mayClose bool) error
	CheckInst(vc *Controller, svcName string) bool
	UpdateVarnishInstance(vc *Controller, cfgName string, vclSrc string, metrics *varnishmetrics.InstanceMetrics) error
}

Handler Interface to enable mocking

func NewInst

func NewInst(ns string, name string, addr string, admSecret **[]byte) Handler

NewInst to be used as argument to NewVarnishController

type HandlerFactory

type HandlerFactory func(ns string, name string, addr string, admSecret **[]byte) Handler

HandlerFactory also to be implemented by Mocker

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 mockvarnish is a generated GoMock package.
Package mockvarnish is a generated GoMock package.
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