backends

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendPool

type BackendPool interface {
	Init(p ProbeProvider)
	Ensure(ports []ServicePort, igs []*compute.InstanceGroup) error
	Get(port int64, isAlpha bool) (*BackendService, error)
	Delete(port int64) error
	GC(ports []ServicePort) error
	Shutdown() error
	Status(name string) string
	List() ([]interface{}, error)
	Link(port ServicePort, zones []string) error
}

BackendPool is an interface to manage a pool of kubernetes nodePort services as gce backendServices, and sync them through the BackendServices interface.

type BackendService added in v1.1.0

type BackendService struct {
	Alpha *computealpha.BackendService
	Ga    *compute.BackendService
}

BackendService embeds both the GA and alpha compute BackendService types

func (*BackendService) GetDescription added in v1.1.0

func (be *BackendService) GetDescription() string

GetDescription gets the Description off the correct BackendService

func (be *BackendService) GetHealthCheckLink() string

GetHealthCheckLink gets the Healthcheck link off the correct BackendService

func (*BackendService) GetProtocol added in v1.1.0

func (be *BackendService) GetProtocol() string

GetProtocol gets the Protocol off the correct BackendService

type BackendServices

type BackendServices interface {
	GetGlobalBackendService(name string) (*compute.BackendService, error)
	GetAlphaGlobalBackendService(name string) (*computealpha.BackendService, error)
	UpdateGlobalBackendService(bg *compute.BackendService) error
	UpdateAlphaGlobalBackendService(bg *computealpha.BackendService) error
	CreateGlobalBackendService(bg *compute.BackendService) error
	CreateAlphaGlobalBackendService(bg *computealpha.BackendService) error
	DeleteGlobalBackendService(name string) error
	ListGlobalBackendServices() ([]*compute.BackendService, error)
	GetGlobalBackendServiceHealth(name, instanceGroupLink string) (*compute.BackendServiceGroupHealth, error)
}

BackendServices is an interface for managing gce backend services.

type Backends

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

Backends implements BackendPool.

func NewBackendPool

func NewBackendPool(
	cloud BackendServices,
	negGetter NEGGetter,
	healthChecker healthchecks.HealthChecker,
	nodePool instances.NodePool,
	namer *utils.Namer,
	ignorePorts []int64,
	resyncWithCloud bool) *Backends

NewBackendPool returns a new backend pool. - cloud: implements BackendServices and syncs backends with a cloud provider - healthChecker: is capable of producing health checks for backends. - nodePool: implements NodePool, used to create/delete new instance groups. - namer: procudes names for backends. - ignorePorts: is a set of ports to avoid syncing/GCing. - resyncWithCloud: if true, periodically syncs with cloud resources.

func (*Backends) Delete

func (b *Backends) Delete(port int64) (err error)

Delete deletes the Backend for the given port.

func (*Backends) Ensure

func (b *Backends) Ensure(svcPorts []ServicePort, igs []*compute.InstanceGroup) error

Ensure will update or create Backends for the given ports. Uses the given instance groups if non-nil, else creates instance groups.

func (*Backends) GC

func (b *Backends) GC(svcNodePorts []ServicePort) error

GC garbage collects services corresponding to ports in the given list.

func (*Backends) Get

func (b *Backends) Get(port int64, isAlpha bool) (*BackendService, error)

Get returns a single backend.

func (*Backends) Init

func (b *Backends) Init(pp ProbeProvider)

Init sets the probeProvider interface value

func (b *Backends) Link(port ServicePort, zones []string) error

func (*Backends) List

func (b *Backends) List() ([]interface{}, error)

List lists all backends.

func (*Backends) Shutdown

func (b *Backends) Shutdown() error

Shutdown deletes all backends and the default backend. This will fail if one of the backends is being used by another resource.

func (*Backends) Status

func (b *Backends) Status(name string) string

Status returns the status of the given backend by name.

type BalancingMode

type BalancingMode string

BalancingMode represents the loadbalancing configuration of an individual Backend in a BackendService. This is *effectively* a cluster wide setting since you can't mix modes across Backends pointing to the same IG, and you can't have a single node in more than 1 loadbalanced IG.

const (
	// Rate balances incoming requests based on observed RPS.
	// As of this writing, it's the only balancing mode supported by GCE's
	// internal LB. This setting doesn't make sense for Kubernets clusters
	// because requests can get proxied between instance groups in different
	// zones by kube-proxy without GCE even knowing it. Setting equal RPS on
	// all IGs should achieve roughly equal distribution of requests.
	Rate BalancingMode = "RATE"
	// Utilization balances incoming requests based on observed utilization.
	// This mode is only useful if you want to divert traffic away from IGs
	// running other compute intensive workloads. Utilization statistics are
	// aggregated per instances, not per container, and requests can get proxied
	// between instance groups in different zones by kube-proxy without GCE even
	// knowing about it.
	Utilization BalancingMode = "UTILIZATION"
	// Connections balances incoming requests based on a connection counter.
	// This setting currently doesn't make sense for Kubernetes clusters,
	// because we use NodePort Services as HTTP LB backends, so GCE's connection
	// counters don't accurately represent connections per container.
	Connections BalancingMode = "CONNECTION"
)

type FakeBackendServices

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

FakeBackendServices fakes out GCE backend services.

func NewFakeBackendServices

func NewFakeBackendServices(ef func(op int, be *compute.BackendService) error, alpha bool) *FakeBackendServices

NewFakeBackendServices creates a new fake backend services manager.

func (*FakeBackendServices) CreateAlphaGlobalBackendService added in v1.1.0

func (f *FakeBackendServices) CreateAlphaGlobalBackendService(be *computealpha.BackendService) error

CreateGlobalBackendService fakes updating a backend service.

func (*FakeBackendServices) CreateGlobalBackendService

func (f *FakeBackendServices) CreateGlobalBackendService(be *compute.BackendService) error

CreateGlobalBackendService fakes backend service creation.

func (*FakeBackendServices) DeleteGlobalBackendService

func (f *FakeBackendServices) DeleteGlobalBackendService(name string) error

DeleteGlobalBackendService fakes backend service deletion.

func (*FakeBackendServices) GetAlphaGlobalBackendService

func (f *FakeBackendServices) GetAlphaGlobalBackendService(name string) (*computealpha.BackendService, error)

func (*FakeBackendServices) GetGlobalBackendService

func (f *FakeBackendServices) GetGlobalBackendService(name string) (*compute.BackendService, error)

GetGlobalBackendService fakes getting a backend service from the cloud.

func (*FakeBackendServices) GetGlobalBackendServiceHealth

func (f *FakeBackendServices) GetGlobalBackendServiceHealth(name, instanceGroupLink string) (*compute.BackendServiceGroupHealth, error)

GetGlobalBackendServiceHealth fakes getting backend service health.

func (*FakeBackendServices) ListGlobalBackendServices

func (f *FakeBackendServices) ListGlobalBackendServices() ([]*compute.BackendService, error)

ListGlobalBackendServices fakes backend service listing.

func (*FakeBackendServices) UpdateAlphaGlobalBackendService

func (f *FakeBackendServices) UpdateAlphaGlobalBackendService(be *computealpha.BackendService) error

UpdateGlobalBackendService fakes updating a backend service.

func (*FakeBackendServices) UpdateGlobalBackendService

func (f *FakeBackendServices) UpdateGlobalBackendService(be *compute.BackendService) error

UpdateGlobalBackendService fakes updating a backend service.

type FakeProbeProvider

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

FakeProbeProvider implements the probeProvider interface for tests.

func NewFakeProbeProvider

func NewFakeProbeProvider(probes map[ServicePort]*api_v1.Probe) *FakeProbeProvider

NewFakeProbeProvider returns a struct which satisfies probeProvider interface

func (*FakeProbeProvider) GetProbe

func (pp *FakeProbeProvider) GetProbe(port ServicePort) (*api_v1.Probe, error)

GetProbe returns the probe for a given nodePort

type NEGGetter

type NEGGetter interface {
	GetNetworkEndpointGroup(name string, zone string) (*computealpha.NetworkEndpointGroup, error)
}

NEGGetter is an interface to retrieve NEG object

type ProbeProvider

type ProbeProvider interface {
	GetProbe(sp ServicePort) (*api_v1.Probe, error)
}

ProbeProvider retrieves a probe struct given a nodePort

type ServicePort

type ServicePort struct {
	SvcName       types.NamespacedName
	SvcPort       intstr.IntOrString
	NodePort      int64
	Protocol      annotations.AppProtocol
	SvcTargetPort string
	NEGEnabled    bool
}

ServicePort for tupling port and protocol

func (ServicePort) Description

func (sp ServicePort) Description() string

Description returns a string describing the ServicePort.

Jump to

Keyboard shortcuts

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