controller

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FrontendHTTP  = "http"
	FrontendHTTPS = "https"
	FrontendSSL   = "ssl"
)
View Source
const DEBUG_API = false //nolint golint

Variables

View Source
var (
	HAProxyCFG      string
	HAProxyCertDir  string
	HAProxyStateDir string
	HAProxyMapDir   string
)
View Source
var ErrIgnored = errors.New("Ignored resource") //nolint golint

Functions

func ConvertIngressRules

func ConvertIngressRules(ingressRules []extensions.IngressRule) map[string]*IngressRule

ConvertIngressRules converts data from kubernetes format

func ConvertIngressTLS

func ConvertIngressTLS(ingressTLS []extensions.IngressTLS) map[string]*IngressTLS

ConvertIngressRules converts data from kubernetes format

func SetDefaultAnnotation

func SetDefaultAnnotation(annotation, value string)

Types

type ConfigMap

type ConfigMap struct {
	Namespace   string
	Name        string
	Annotations MapStringW
	Status      Status
}

ConfigMap is usefull data from k8s structures about configmap

func (*ConfigMap) Equal

func (a *ConfigMap) Equal(b *ConfigMap) bool

Equal compares two config maps, ignores statuses and old values

type Configuration

type Configuration struct {
	Namespace              map[string]*Namespace
	NamespacesAccess       NamespacesWatch
	IngressClass           string
	ConfigMap              *ConfigMap
	ConfigMapTCPServices   *ConfigMap
	PublishService         *Service
	MapFiles               haproxy.Maps
	HTTPRequests           map[Rule]HTTPRequestRules
	HTTPRequestsStatus     Status
	TCPRequests            map[Rule]TCPRequestRules
	TCPRequestsStatus      Status
	BackendSwitchingRules  map[string]UseBackendRules
	BackendSwitchingStatus map[string]struct{}
	RateLimitingEnabled    bool
	HTTPS                  bool
	SSLPassthrough         bool
}

func (*Configuration) Clean

func (c *Configuration) Clean()

Clean cleans all the statuses of various data that was changed deletes them completely or just resets them if needed

func (*Configuration) GetNamespace

func (c *Configuration) GetNamespace(name string) *Namespace

GetNamespace returns Namespace. Creates one if not existing

func (*Configuration) Init

func (c *Configuration) Init(osArgs utils.OSArgs, mapDir string)

Init itialize configuration

func (*Configuration) IsRelevantNamespace

func (c *Configuration) IsRelevantNamespace(namespace string) bool

func (*Configuration) NewNamespace

func (c *Configuration) NewNamespace(name string) *Namespace

NewNamespace returns new initialized Namespace

type EndpointIP

type EndpointIP struct {
	IP          string
	Name        string
	HAProxyName string
	Disabled    bool
	Status      Status
}

func (*EndpointIP) Equal

func (a *EndpointIP) Equal(b *EndpointIP) bool

type EndpointIPs

type EndpointIPs map[string]*EndpointIP

func (*EndpointIPs) Equal

func (a *EndpointIPs) Equal(b *EndpointIPs) bool

type EndpointPort

type EndpointPort struct {
	Name     string
	Protocol string
	Port     int64
	Status   Status
}

func (*EndpointPort) Equal

func (a *EndpointPort) Equal(b *EndpointPort) bool

type EndpointPorts

type EndpointPorts []*EndpointPort

func (*EndpointPorts) Equal

func (a *EndpointPorts) Equal(b *EndpointPorts) bool

type Endpoints

type Endpoints struct {
	Namespace   string
	Service     StringW
	BackendName string
	Ports       *EndpointPorts
	Addresses   *EndpointIPs
	Status      Status
}

Endpoints is usefull data from k8s structures about Endpoints

func (*Endpoints) Equal

func (a *Endpoints) Equal(b *Endpoints) bool

Equal checks if pods are equal

type HAProxyController

type HAProxyController struct {
	NativeAPI                   *clientnative.HAProxyClient
	ActiveTransaction           string
	ActiveTransactionHasChanges bool
	// contains filtered or unexported fields
}

HAProxyController is ingress controller

func (*HAProxyController) ActiveConfiguration

func (c *HAProxyController) ActiveConfiguration() (*parser.Parser, error)

func (*HAProxyController) HAProxyInitialize

func (c *HAProxyController) HAProxyInitialize()

HAProxyInitialize runs HAProxy for the first time so native client can have access to it

func (*HAProxyController) HAProxyReload

func (c *HAProxyController) HAProxyReload() error

func (*HAProxyController) RequestsHTTPRefresh

func (c *HAProxyController) RequestsHTTPRefresh() (needsReload bool)

func (*HAProxyController) RequestsTCPRefresh added in v1.4.0

func (c *HAProxyController) RequestsTCPRefresh() (needsReload bool)

func (*HAProxyController) Start

func (c *HAProxyController) Start(ctx context.Context, osArgs utils.OSArgs)

Start initialize and run HAProxyController

func (*HAProxyController) SyncData

func (c *HAProxyController) SyncData(jobChan <-chan SyncDataEvent, chConfigMapReceivedAndProcessed chan bool)

SyncData gets all kubernetes changes, aggregates them and apply to HAProxy. All the changes must come through this function

type HTTPRequestRules added in v1.4.0

type HTTPRequestRules map[uint64]models.HTTPRequestRule

type Ingress

type Ingress struct {
	Namespace      string
	Name           string
	Annotations    MapStringW
	Rules          map[string]*IngressRule
	DefaultBackend *IngressPath
	TLS            map[string]*IngressTLS
	Status         Status
}

Ingress is usefull data from k8s structures about ingress

func (*Ingress) Equal

func (a *Ingress) Equal(b *Ingress) bool

Equal compares two Ingresses, ignores

type IngressPath

type IngressPath struct {
	ServiceName       string
	ServicePortInt    int64
	ServicePortString string
	TargetPort        int64
	Path              string
	IsTCPService      bool
	IsSSLPassthrough  bool
	IsDefaultBackend  bool
	Status            Status
}

IngressPath is usefull data from k8s structures about ingress path

func ConvertIngressBackend

func ConvertIngressBackend(ingressBackend *extensions.IngressBackend) *IngressPath

func (*IngressPath) Equal

func (a *IngressPath) Equal(b *IngressPath) bool

Equal checks if Ingress Paths are equal

type IngressRule

type IngressRule struct {
	Host   string
	Paths  map[string]*IngressPath
	Status Status
}

IngressRule is usefull data from k8s structures about ingress rule

func (*IngressRule) Equal

func (a *IngressRule) Equal(b *IngressRule) bool

Equal checks if Ingress Rules are equal

type IngressTLS

type IngressTLS struct {
	Host       string
	SecretName StringW
	Status     Status
}

IngressTLS describes the transport layer security associated with an Ingress.

func (*IngressTLS) Equal added in v1.4.0

func (a *IngressTLS) Equal(b *IngressTLS) bool

Equal checks if Ingress secrets are equal

type K8s

type K8s struct {
	API *kubernetes.Clientset
}

K8s is structure with all data required to synchronize with k8s

func GetKubernetesClient

func GetKubernetesClient() (*K8s, error)

GetKubernetesClient returns new client that communicates with k8s

func GetRemoteKubernetesClient

func GetRemoteKubernetesClient(kubeconfig string) (*K8s, error)

GetRemoteKubernetesClient returns new client that communicates with k8s

func (*K8s) EventsConfigfMaps

func (k *K8s) EventsConfigfMaps(channel chan *ConfigMap, stop chan struct{})

func (*K8s) EventsEndpoints

func (k *K8s) EventsEndpoints(channel chan *Endpoints, stop chan struct{})

func (*K8s) EventsIngresses

func (k *K8s) EventsIngresses(channel chan *Ingress, stop chan struct{})

func (*K8s) EventsNamespaces

func (k *K8s) EventsNamespaces(channel chan *Namespace, stop chan struct{})

func (*K8s) EventsSecrets

func (k *K8s) EventsSecrets(channel chan *Secret, stop chan struct{})

func (*K8s) EventsServices

func (k *K8s) EventsServices(channel chan *Service, stop chan struct{}, publishSvc *Service)

func (*K8s) GetPublishServiceAddresses

func (k *K8s) GetPublishServiceAddresses(service *corev1.Service, publishSvc *Service)

func (*K8s) UpdateIngressStatus

func (k *K8s) UpdateIngressStatus(ingress *Ingress, publishSvc *Service) (err error)

type MapStringW

type MapStringW map[string]*StringW

MapStringW stores values and enables

func ConvertToMapStringW

func ConvertToMapStringW(annotations map[string]string) MapStringW

ConvertToMapStringW removes prefixes in annotation

func (*MapStringW) Clean

func (a *MapStringW) Clean()

Clean removes all with status

func (*MapStringW) Clone

func (a *MapStringW) Clone() MapStringW

Clone removes all with status

func (*MapStringW) Equal

func (a *MapStringW) Equal(b MapStringW) bool

Equal comapres if two maps are equal

func (*MapStringW) Get

func (a *MapStringW) Get(name string) (data *StringW, err error)

Get checks if name exists and if not, returns default value if defined

func (*MapStringW) SetStatus

func (a *MapStringW) SetStatus(old MapStringW) (different bool)

SetStatus sets Status state for all items in map

func (*MapStringW) SetStatusState

func (a *MapStringW) SetStatusState(state Status)

SetStatusState sets all watches to desired state

func (*MapStringW) String

func (a *MapStringW) String() string

Get checks if name exists and if not, returns default value if defined

type Mode

type Mode string
const (
	ModeHTTP Mode = "http"
	ModeTCP  Mode = "tcp"
)

func (Mode) MarshalFlag

func (n Mode) MarshalFlag() (string, error)

MarshalFlag Marshals flag

func (*Mode) UnmarshalFlag

func (n *Mode) UnmarshalFlag(value string) error

UnmarshalFlag Unmarshal flag

type Namespace

type Namespace struct {
	Name      string
	Relevant  bool
	Ingresses map[string]*Ingress
	Endpoints map[string]*Endpoints
	Services  map[string]*Service
	Secret    map[string]*Secret
	Status    Status
	// contains filtered or unexported fields
}

Namespace is usefull data from k8s structures about namespace

type NamespacesWatch

type NamespacesWatch struct {
	Whitelist map[string]struct{}
	Blacklist map[string]struct{}
}

type Rule added in v1.4.0

type Rule string
const (
	//nolint
	BLACKLIST Rule = "blacklist"
	//nolint
	RATE_LIMIT Rule = "rate-limit"
	//nolint
	SSL_REDIRECT Rule = "ssl-redirect"
	//nolint
	PROXY_PROTOCOL Rule = "proxy-protocol"
	//nolint
	REQUEST_CAPTURE Rule = "request-capture"
	//nolint
	REQUEST_SET_HEADER Rule = "request-set-header"
	//nolint
	WHITELIST Rule = "whitelist"
)

type Secret

type Secret struct {
	Namespace string
	Name      string
	Data      map[string][]byte
	Status    Status
}

Secret is usefull data from k8s structures about secret

func (*Secret) Equal

func (a *Secret) Equal(b *Secret) bool

Equal compares two secrets, ignores statuses and old values

type Service

type Service struct {
	Namespace   string
	Name        string
	Ports       []ServicePort
	Addresses   []string //Used only for publish-service
	Annotations MapStringW
	Selector    MapStringW
	Status      Status
}

Service is usefull data from k8s structures about service

func (*Service) Equal

func (a *Service) Equal(b *Service) bool

Equal compares two services, ignores statuses and old values

type ServicePort

type ServicePort struct {
	Name     string
	Protocol string
	Port     int64
	Status   Status
}

ServicePort describes port of a service

func (*ServicePort) Equal

func (a *ServicePort) Equal(b *ServicePort) bool

type Status

type Status string
const (
	ADDED    Status = "ADDED"
	DELETED  Status = "DELETED"
	ERROR    Status = "ERROR"
	EMPTY    Status = ""
	MODIFIED Status = "MODIFIED"
)

type StringW

type StringW struct {
	Value    string
	OldValue string
	Status   Status
}

StringW string value that has modified flag

func GetValueFromAnnotations

func GetValueFromAnnotations(annotationName string, annotations ...MapStringW) (data *StringW, err error)

GetValueFromAnnotations returns value by checking in multiple annotatins. moves through list until it finds value if value is new or deleted, we check for next state to correctly set watch & value

func (*StringW) Equal

func (a *StringW) Equal(b *StringW) bool

Equal compares only Value, rest is not relevant

type SyncDataEvent

type SyncDataEvent struct {
	SyncType
	Namespace string
	Data      interface{}
	// contains filtered or unexported fields
}

SyncDataEvent represents converted k8s received message

type SyncType

type SyncType string

SyncType represents type of k8s received message

const (
	COMMAND   SyncType = "COMMAND"
	CONFIGMAP SyncType = "CONFIGMAP"
	ENDPOINTS SyncType = "ENDPOINTS"
	INGRESS   SyncType = "INGRESS"
	NAMESPACE SyncType = "NAMESPACE"
	SERVICE   SyncType = "SERVICE"
	SECRET    SyncType = "SECRET"
)

SyncType values

type TCPRequestRules added in v1.4.0

type TCPRequestRules map[uint64]models.TCPRequestRule

type UseBackendRule

type UseBackendRule struct {
	Host      string
	Path      string
	Backend   string
	Namespace string
}

type UseBackendRules

type UseBackendRules map[string]UseBackendRule

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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