store

package
v1.10.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	NETWORKINGV1 = "networking.k8s.io/v1"

	PATH_TYPE_EXACT                   = "Exact"
	PATH_TYPE_PREFIX                  = "Prefix"
	PATH_TYPE_IMPLEMENTATION_SPECIFIC = "ImplementationSpecific"
)
View Source
const DefaultLocalBackend = "default-local-service"
View Source
const (
	TCPProtocolType string = "TCP"
)

Variables

This section is empty.

Functions

func CopyAnnotations

func CopyAnnotations(in map[string]string) map[string]string

CopyAnnotations returns a copy of annotations map and removes prefixe from annotations name

func EqualMap added in v1.10.0

func EqualMap[T, V Literal](mapA, mapB map[T]V) bool

func EqualPointers added in v1.10.0

func EqualPointers[P Literal](a, b *P) bool

func EqualSlice added in v1.10.0

func EqualSlice[T Equalizer[T]](sliceA, sliceB []T) bool

func EqualSliceComparable added in v1.10.0

func EqualSliceComparable[T comparable](sliceA, sliceB []T) bool

func NoNilPointer added in v1.10.0

func NoNilPointer[P any](pointers ...*P) bool

Types

type AllowedRoutes added in v1.10.0

type AllowedRoutes struct {
	Namespaces *RouteNamespaces
	Kinds      []RouteGroupKind
}

func (*AllowedRoutes) Equal added in v1.10.0

func (ar *AllowedRoutes) Equal(other *AllowedRoutes) bool

type BackendRef added in v1.10.0

type BackendRef struct {
	Namespace *string
	Port      *int32
	Weight    *int32
	Group     *string
	Kind      *string
	Name      string
}

func (*BackendRef) Equal added in v1.10.0

func (backref *BackendRef) Equal(other *BackendRef) bool

type BackendRefs added in v1.10.0

type BackendRefs []BackendRef

func (BackendRefs) Equal added in v1.10.0

func (refs BackendRefs) Equal(other BackendRefs) bool

type ConfigMap

type ConfigMap struct {
	Annotations map[string]string
	Namespace   string
	Name        string
	Status      Status
	Loaded      bool
}

ConfigMap is useful 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 ConfigMaps

type ConfigMaps struct {
	Main         *ConfigMap
	TCPServices  *ConfigMap
	Errorfiles   *ConfigMap
	PatternFiles *ConfigMap
}

type CustomResources

type CustomResources struct {
	Global     map[string]*models.Global
	Defaults   map[string]*models.Defaults
	LogTargets map[string]models.LogTargets
	Backends   map[string]*models.Backend
}

type Endpoints

type Endpoints struct {
	SliceName string
	Namespace string
	Service   string
	Ports     map[string]*PortEndpoints // Ports[portName]
	Status    Status
}

Endpoints describes endpoints of a service

func (*Endpoints) Equal

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

Equal checks if two services have same endpoints

type Equalizer added in v1.10.0

type Equalizer[T any] interface {
	Equal(t T) bool
}

type ErrNotFound

type ErrNotFound error

type Gateway added in v1.10.0

type Gateway struct {
	Namespace        string
	Name             string
	GatewayClassName string
	Status           Status
	Listeners        []Listener
	Generation       int64
}

func (*Gateway) Equal added in v1.10.0

func (gw *Gateway) Equal(other *Gateway) bool

func (*Gateway) IsValid added in v1.10.0

func (gw *Gateway) IsValid() error

type GatewayClass added in v1.10.0

type GatewayClass struct {
	Description    *string
	Name           string
	ControllerName string
	Status         Status
	Generation     int64
}

func (*GatewayClass) Equal added in v1.10.0

func (gwc *GatewayClass) Equal(other *GatewayClass) bool

type HAProxySrv

type HAProxySrv struct {
	// Srv disabled is srv with address ""
	Name     string
	Address  string
	Modified bool
	Port     int64
}

func (*HAProxySrv) String added in v1.8.4

func (h *HAProxySrv) String() string

type Ingress

type Ingress struct {
	IngressCore
	Status    Status // Used for store purpose
	Addresses []string
	Ignored   bool // true if resource ignored because of non matching Controller Class
}

Ingress is useful data from k8s structures about ingress

func ConvertToIngress

func ConvertToIngress(resource interface{}) (ingress *Ingress, err error)

ConvertToIngress detects the interface{} provided by the SharedInformer and select the proper strategy to convert and return the resource as a store.Ingress struct

type IngressClass

type IngressClass struct {
	APIVersion  string
	Name        string
	Controller  string
	Annotations map[string]string
	Status      Status // Used for store purpose
}

func ConvertToIngressClass

func ConvertToIngressClass(resource interface{}) (ingress *IngressClass, err error)

type IngressCore

type IngressCore struct {
	Annotations    map[string]string
	Rules          map[string]*IngressRule
	DefaultBackend *IngressPath
	TLS            map[string]*IngressTLS
	APIVersion     string // Required for K8s.UpdateIngressStatus to select proper versioned Client Set
	Namespace      string
	Name           string
	Class          string
}

type IngressPath

type IngressPath struct {
	SvcPortResolved  *ServicePort
	SvcNamespace     string
	SvcName          string
	SvcPortString    string
	Path             string
	PathTypeMatch    string
	SvcPortInt       int64
	IsDefaultBackend bool
}

IngressPath is useful data from k8s structures about ingress path

type IngressRule

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

IngressRule is useful data from k8s structures about ingress rule

type IngressTLS

type IngressTLS struct {
	Host       string
	SecretName string
}

IngressTLS describes the transport layer security associated with an Ingress.

type K8s

type K8s struct {
	ConfigMaps              ConfigMaps
	NamespacesAccess        NamespacesWatch
	Namespaces              map[string]*Namespace
	IngressClasses          map[string]*IngressClass
	SecretsProcessed        map[string]struct{}
	BackendProcessed        map[string]struct{}
	UpdateStatusFunc        func(ingresses []*Ingress, publishServiceAddresses []string)
	GatewayClasses          map[string]*GatewayClass
	GatewayControllerName   string
	PublishServiceAddresses []string
	NbrHAProxyInst          int64
}

func NewK8sStore

func NewK8sStore(args utils.OSArgs) K8s

func (*K8s) Clean

func (k *K8s) Clean()

func (*K8s) EventBackendCR

func (k *K8s) EventBackendCR(namespace, name string, data *corev1alpha2.Backend) bool

func (*K8s) EventConfigMap

func (k *K8s) EventConfigMap(ns *Namespace, data *ConfigMap) (updateRequired bool)

func (*K8s) EventDefaultsCR

func (k *K8s) EventDefaultsCR(namespace, name string, data *corev1alpha2.Defaults) bool

func (*K8s) EventEndpoints

func (k *K8s) EventEndpoints(ns *Namespace, data *Endpoints, syncHAproxySrvs func(backend *RuntimeBackend, portUpdated bool) error) (updateRequired bool)

func (*K8s) EventGateway added in v1.10.0

func (k *K8s) EventGateway(ns *Namespace, data *Gateway) (updateRequired bool)

func (*K8s) EventGatewayClass added in v1.10.0

func (k *K8s) EventGatewayClass(data *GatewayClass) (updateRequired bool)

func (*K8s) EventGlobalCR

func (k *K8s) EventGlobalCR(namespace, name string, data *corev1alpha2.Global) bool

func (*K8s) EventIngress

func (k *K8s) EventIngress(ns *Namespace, data *Ingress) (updateRequired bool)

func (*K8s) EventIngressClass

func (k *K8s) EventIngressClass(data *IngressClass) (updateRequired bool)

func (*K8s) EventNamespace

func (k *K8s) EventNamespace(ns *Namespace, data *Namespace) (updateRequired bool)

func (*K8s) EventPod

func (k *K8s) EventPod(podEvent PodEvent) (updateRequired bool)

func (*K8s) EventPublishService

func (k *K8s) EventPublishService(ns *Namespace, data *Service) (updateRequired bool)

func (*K8s) EventReferenceGrant added in v1.10.0

func (k *K8s) EventReferenceGrant(ns *Namespace, data *ReferenceGrant) (updateRequired bool)

func (*K8s) EventSecret

func (k *K8s) EventSecret(ns *Namespace, data *Secret) (updateRequired bool)

func (*K8s) EventService

func (k *K8s) EventService(ns *Namespace, data *Service) (updateRequired bool)

func (*K8s) EventTCPRoute added in v1.10.0

func (k *K8s) EventTCPRoute(ns *Namespace, data *TCPRoute) (updateRequired bool)

func (K8s) GetEndpoints

func (k K8s) GetEndpoints(namespace, name string) (endpoints map[string]*PortEndpoints, err error)

GetEndpoints takes the ns and name of a service and provides a map of endpoints: portName --> *PortEndpoints

func (K8s) GetNamespace

func (k K8s) GetNamespace(name string) *Namespace

GetNamespace returns Namespace. Creates one if not existing

func (K8s) GetSecret

func (k K8s) GetSecret(namespace, name string) (*Secret, error)

func (K8s) GetService

func (k K8s) GetService(namespace, name string) (*Service, error)

type LabelSelector added in v1.10.0

type LabelSelector struct {
	MatchLabels      map[string]string
	MatchExpressions []LabelSelectorRequirement
}

func (*LabelSelector) Equal added in v1.10.0

func (labelSelector *LabelSelector) Equal(other *LabelSelector) bool

type LabelSelectorRequirement added in v1.10.0

type LabelSelectorRequirement struct {
	Key      string
	Operator string
	Values   []string
}

func (LabelSelectorRequirement) Equal added in v1.10.0

type Listener added in v1.10.0

type Listener struct {
	Hostname      *string
	AllowedRoutes *AllowedRoutes
	Name          string
	Protocol      string
	GwNamespace   string
	GwName        string
	Port          int32
}

func (*Listener) Equal added in v1.10.0

func (listener *Listener) Equal(other *Listener) bool

type Listeners added in v1.10.0

type Listeners []Listener

func (Listeners) Equal added in v1.10.0

func (listeners Listeners) Equal(other Listeners) bool

type Literal added in v1.10.0

type Literal interface {
	~int | ~uint | ~float32 | ~float64 | ~complex64 | ~complex128 | ~int32 | ~int64 | ~string | ~bool
}

type MapStringW

type MapStringW map[string]*StringW

MapStringW stores values and enables

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 compares 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 Namespace

type Namespace struct {
	Secret          map[string]*Secret
	Ingresses       map[string]*Ingress
	Endpoints       map[string]map[string]*Endpoints // service -> sliceName -> Endpoints
	Services        map[string]*Service
	HAProxyRuntime  map[string]map[string]*RuntimeBackend // service -> portName -> Backend
	CRs             *CustomResources
	Gateways        map[string]*Gateway
	TCPRoutes       map[string]*TCPRoute
	ReferenceGrants map[string]*ReferenceGrant
	Labels          map[string]string
	Name            string
	Status          Status
	Relevant        bool
	// contains filtered or unexported fields
}

Namespace is useful data from k8s structures about namespace

func (*Namespace) Equal added in v1.10.0

func (ns *Namespace) Equal(other *Namespace) bool

type NamespacesWatch

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

type ParentRef added in v1.10.0

type ParentRef struct {
	Namespace   *string
	SectionName *string
	Port        *int32
	Group       string
	Kind        string
	Name        string
}

func (ParentRef) Equal added in v1.10.0

func (pr ParentRef) Equal(other ParentRef) bool

type ParentRefs added in v1.10.0

type ParentRefs []ParentRef

func (ParentRefs) Equal added in v1.10.0

func (refs ParentRefs) Equal(other ParentRefs) bool

type PodEvent

type PodEvent struct {
	Created bool
}

PodEvent carries creation/deletion pod event.

type PortEndpoints

type PortEndpoints struct {
	Addresses map[string]struct{}
	Port      int64
}

PortEndpoints describes endpoints of a service port

func (*PortEndpoints) Equal

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

Equal checks if old PortEndpoints equals to a new PortEndpoints.

type ReferenceGrant added in v1.10.0

type ReferenceGrant struct {
	Namespace  string
	Name       string
	Status     Status
	From       []ReferenceGrantFrom
	To         []ReferenceGrantTo
	Generation int64
}

func (*ReferenceGrant) Equal added in v1.10.0

func (rf *ReferenceGrant) Equal(other *ReferenceGrant) bool

type ReferenceGrantFrom added in v1.10.0

type ReferenceGrantFrom struct {
	Group     string
	Kind      string
	Namespace string
}

type ReferenceGrantTo added in v1.10.0

type ReferenceGrantTo struct {
	Name  *string
	Group string
	Kind  string
}

func (ReferenceGrantTo) Equal added in v1.10.0

func (refto ReferenceGrantTo) Equal(other ReferenceGrantTo) bool

type RouteGroupKind added in v1.10.0

type RouteGroupKind struct {
	Group *string
	Kind  string
}

type RouteGroupKinds added in v1.10.0

type RouteGroupKinds []RouteGroupKind

func (RouteGroupKinds) Equal added in v1.10.0

func (rgks RouteGroupKinds) Equal(other RouteGroupKinds) bool

type RouteNamespaces added in v1.10.0

type RouteNamespaces struct {
	From     *string
	Selector *LabelSelector
}

func (*RouteNamespaces) Equal added in v1.10.0

func (rn *RouteNamespaces) Equal(other *RouteNamespaces) bool

type RuntimeBackend

type RuntimeBackend struct {
	Endpoints       PortEndpoints
	Name            string
	HAProxySrvs     []*HAProxySrv
	DynUpdateFailed bool
}

RuntimeBackend holds the runtime state of an HAProxy backend

type Secret

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

Secret is useful 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 {
	Annotations map[string]string
	Namespace   string
	Name        string
	DNS         string
	Status      Status
	Ports       []ServicePort
	Addresses   []string // Used only for publish-service
}

Service is useful 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

func (*Service) EqualWithAddresses

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

type ServicePort

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

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 (*StringW) Equal

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

Equal compares only Value, rest is not relevant

type TCPRoute added in v1.10.0

type TCPRoute struct {
	CreationTime time.Time
	Name         string
	Namespace    string
	Status       Status
	BackendRefs  []BackendRef
	ParentRefs   []ParentRef
	Generation   int64
}

func (*TCPRoute) Equal added in v1.10.0

func (tcp *TCPRoute) Equal(other *TCPRoute) bool

type TCPRoutes added in v1.10.0

type TCPRoutes []TCPRoute

func (TCPRoutes) Less added in v1.10.0

func (tcproutes TCPRoutes) Less(i, j int) bool

Jump to

Keyboard shortcuts

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