haproxy

package
v0.0.0-...-606a1df Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HAProxy

type HAProxy interface {
	Reload(podIPs []string, targetPort string, servicePort string, mtu string) error
}

HAProxy defines what an HAProxy should be able to do

type HAProxyError

type HAProxyError struct {
	Error       error
	Source      string
	Dest        []string
	TargetPort  string
	MTU         string
	ServicePort string
}

HAProxyError represents an error from HAProxy

type HAProxyManager

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

HAProxyManager manages a single running HAProxy instance

func NewHAProxy

func NewHAProxy(ctx context.Context, binary string, configDir, listenAddr, mtu string, podIPs []string, targetPort, servicePort string, errChan chan HAProxyError, logger logrus.FieldLogger) (*HAProxyManager, error)

NewHAProxy creates a new HAProxyManager instance

func (*HAProxyManager) Reload

func (h *HAProxyManager) Reload(podIPs []string, targetPort, servicePort, mtu string) error

Reload rewrites the configuration and sends a signal to HAProxy to initiate the reload

type HAProxySet

type HAProxySet interface {
	// Configure will create or update an HAProxy Instance.
	Configure(VIPConfig) error

	// StopAll will stop all HAProxy instances.
	// StopAll is blocking until all instances have been destroyed.
	StopAll()

	// StopOne will stop a single HAProxy instance.
	StopOne(listenAddrWithPort string)

	GetRemovals(v6Addrs []string) (removals []string)
}

HAProxySet provides a simple mechanism for managing a group of HAProxy services for multiple source and destination IP addresses. Specifically it provides a mechanism to create and reconfigure an HAProxy instance, as well as an instance to stop all running instances.

type HAProxySetManager

type HAProxySetManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

HAProxySetManager manages several HAProxy instances

func NewHAProxySet

func NewHAProxySet(ctx context.Context, binary, configDir string, logger logrus.FieldLogger) (*HAProxySetManager, error)

NewHAProxySet creates a new HAProxySetManager instance

func (*HAProxySetManager) Configure

func (h *HAProxySetManager) Configure(config VIPConfig) error

Configure creates an haproxy config from a given v6 backend and set of pods. It makes a config for each v6-addr:port combination the reason for this is that when a pod supporting a VIP goes away, the config MUST be rewritten so we don't route traffic to dead pod IPs. When this happens, HAProxy must reload the config which causes a (very brief) downtime for a server. A 1:1 map from backend to pod minimizes the detrimental effect of pod churn from a different service reloading a config for a service that isn't relevant to it

func (*HAProxySetManager) GetRemovals

func (h *HAProxySetManager) GetRemovals(v6addrs []string) []string

GetRemovals documented in HAProxySet interface

func (*HAProxySetManager) StopAll

func (h *HAProxySetManager) StopAll()

StopAll cuaes the HAProxySetManager to stop all instances

func (*HAProxySetManager) StopOne

func (h *HAProxySetManager) StopOne(listenAddrWithPort string)

StopOne key generated by GetRemovals which iterates over h.sources call stop with prebuilt key

type VIPConfig

type VIPConfig struct {
	Addr6 string

	PodIPs      []string
	TargetPort  string
	ServicePort string
	MTU         string
}

VIPConfig An HAProxy contains an IPV6 address, a set of pod IPs, the servicePort for the incoming traffic to the realserver, and the targetPort that endpoint pods use to rcv traffic that signify the service addresses & pod target port

func (*VIPConfig) IsValid

func (v *VIPConfig) IsValid() bool

IsValid determines if the VIPConfig is valid

Jump to

Keyboard shortcuts

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