gslbutils

package
v0.0.0-...-c7431a4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// GSLBKubePath is a temporary path to put the kubeconfig
	GSLBKubePath = "/tmp/gslb-kubeconfig"

	//AVISystem is the namespace where everything AVI related is created
	AVISystem = "avi-system"

	// Ingestion layer operations
	ObjectAdd    = "ADD"
	ObjectDelete = "DELETE"
	ObjectUpdate = "UPDATE"

	// Ingestion layer objects
	RouteType            = gdpalphav2.RouteObj
	IngressType          = gdpalphav2.IngressObj
	SvcType              = gdpalphav2.LBSvcObj
	MCIType              = "MCI"
	GSFQDNType           = "GSFqdn"
	PassthroughRoute     = "passthrough"
	ThirdPartyMemberType = "ThirdPartyMember"
	HostRuleType         = "HostRule"

	// Refresh cycle for AVI cache in seconds
	DefaultRefreshInterval = 600

	// Refresh cycle for member clusters in seconds
	DefaultClusterConnectInterval = 30

	// Store types
	AcceptedStore = "Accepted"
	RejectedStore = "Rejected"

	// Multi-cluster key lengths
	IngMultiClusterKeyLen = 6
	MultiClusterKeyLen    = 5
	GSFQDNKeyLen          = 3
	HostRuleKeyLen        = 7

	// Default values for Retry Operations
	SlowSyncTime      = 120
	SlowRetryQueue    = "SlowRetry"
	FastRetryQueue    = "FastRetry"
	DefaultRetryCount = 5

	// Identify objects created by AMKO
	AmkoUser = "amko-gslb"

	// AMKO Event related constants
	AMKOEventComponent      = "avi-multicluster-kubernetes-operator"
	AMKOShutdown            = "AMKOShutdown"
	GSLBConfigValidation    = "GSLBConfigValidation"
	GSLBConfigError         = "GSLBConfigError"
	MemberClusterValidation = "MemberClusterValidation"
	AMKOClusterReady        = "AMKOClusterReady"

	// Go routines in the rest layer
	NumRestWorkers = 8

	// Service Protocols
	ProtocolTCP = "TCP"
	ProtocolUDP = "UDP"

	// Health monitors
	SystemHealthMonitorTypeTCP   = "HEALTH_MONITOR_TCP"
	SystemHealthMonitorTypeUDP   = "HEALTH_MONITOR_UDP"
	SystemGslbHealthMonitorTCP   = "System-GSLB-TCP"
	SystemGslbHealthMonitorHTTP  = "HEALTH_MONITOR_HTTP"
	SystemGslbHealthMonitorHTTPS = "HEALTH_MONITOR_HTTPS"

	// default passthrough health monitor (TCP), to be used for all passthrough routes
	SystemGslbHealthMonitorPassthrough = "amko--passthrough-hm-tcp"

	// Ports for health monitoring
	DefaultTCPHealthMonitorPort   = "80"
	DefaultHTTPHealthMonitorPort  = 80
	DefaultHTTPSHealthMonitorPort = 443

	// Timeout for rest operations
	RestTimeoutSecs = 600

	// Env vars
	GslbLeader = "GSLB_CTRL_IP_ADDRESS"

	// HostRule status constants
	HostRuleAccepted = "Accepted"
	HostRuleRejected = "Rejected"

	// Wait time before a new rest call is made for retries
	RestSleepTime = 5 * time.Second

	// AMKO UUID annotation
	AmkoUuid = "amko.vmware.com/amko-uuid"

	// AMKO Created by label key for HM labels
	CreatedByLabelKey = "created-by"

	// HM template constants
	CreatedByUser                = "created by: user"
	RequestHeaderStringSeparator = " "
	NoOfRequestHeaderParams      = 3
	CreatedFrom                  = "created from: "

	// Default secret constants
	DefaultSecretEnabled = "ako.vmware.com/enable-tls"
)
View Source
const (
	WGIngestion = "ingestion"
	WGFastRetry = "fastretry"
	WGSlowRetry = "slowretry"
	WGGraph     = "graph"
)

Variables

View Source
var AddToScheme = localSchemeBuilder.AddToScheme
View Source
var Debugf = utils.AviLog.Debugf

Debugf is aliased to utils' Debug.Printf

View Source
var Errf = utils.AviLog.Errorf

Errf is aliased to utils' Error.Printf

View Source
var EventScheme = runtime.NewScheme()
View Source
var InformersPerCluster *utils.AviCache

InformersPerCluster is the number of informers per cluster

View Source
var Logf = utils.AviLog.Infof

Logf is aliased to utils' Info.Printf

View Source
var Warnf = utils.AviLog.Warnf

Warnf is aliased to utils' Warning.Printf

Functions

func AMKOControlConfig

func AMKOControlConfig() *amkoControlConfig

func AddClusterContext

func AddClusterContext(cc string)

func CheckNameLength

func CheckNameLength(name string, prefixToExclude string) bool

func ClusterContextPresentInList

func ClusterContextPresentInList(key string, clusterProperties map[string]ClusterProperties) bool

func EncodeHMName

func EncodeHMName(gsName string) string

func ExtractGSLBHostRuleKey

func ExtractGSLBHostRuleKey(key string) (string, string, string, error)

func ExtractMultiClusterHostRuleKey

func ExtractMultiClusterHostRuleKey(key string) (string, string, string, string, string, string, error)

func ExtractMultiClusterKey

func ExtractMultiClusterKey(key string) (string, string, string, string, string)

func GSFQDNKey

func GSFQDNKey(operation, objType, gsFqdn string) string

func GSLBHostRuleKey

func GSLBHostRuleKey(operation, objType, objName string) string

func GetAviAdminTenantRef

func GetAviAdminTenantRef() string

func GetCustomFqdnMode

func GetCustomFqdnMode() bool

func GetDefaultPKI

func GetDefaultPKI(aviClient *clients.AviClient) *string

func GetDomainNameMap

func GetDomainNameMap() *gsToDomainName

func GetFqdnMap

func GetFqdnMap() *globalToLocalFqdn

func GetGDPObj

func GetGDPObj() (string, string)

func GetGSLBConfigNameAndNS

func GetGSLBConfigNameAndNS() (string, string)

func GetGSLBConfigObjectChan

func GetGSLBConfigObjectChan() *chan bool

func GetGSLBHmChecksum

func GetGSLBHmChecksum(hmType string, port int32, description []string, createdBy string) uint32

description is taken as []string For path based Hms, the checksum is computed for all paths

func GetGSLBServiceChecksum

func GetGSLBServiceChecksum(serverList, domainList, memberObjs, hmNames []string,
	persistenceProfileRef *string, ttl *uint32, pa *gslbalphav1.PoolAlgorithmSettings,
	downResponse *gslbalphav1.DownResponse, pkiProfileRef *string, createdBy string) uint32

func GetGslbConfigObjUpdated

func GetGslbConfigObjUpdated() bool

func GetHmTypeForProtocol

func GetHmTypeForProtocol(protocol string) (string, error)

func GetHmTypeForTLS

func GetHmTypeForTLS(tls bool) string

func GetInformersPerCluster

func GetInformersPerCluster(clusterName string) *utils.Informers

func GetIngressNameFromSname

func GetIngressNameFromSname(sname string) string

sname for ingress is ingName/hostname

func GetKeyIdx

func GetKeyIdx(strList []string, key string) (int, bool)

func GetObjectTypeFromKey

func GetObjectTypeFromKey(key string) (string, error)

func GetTenant

func GetTenant() string

func GetUriFromAvi

func GetUriFromAvi(uri string, aviClient *clients.AviClient, infiniteRetry bool) (*session.AviCollectionResult, error)

GetUriFromAvi is a wrapper over Avi SDK's GetCollectionRaw which keeps on calling the get uri till we either get a result or a 404. It retries infinitely for calls which have infiniteRetry set. For others, it retries 3 times.

func GetWaitGroupFromMap

func GetWaitGroupFromMap(name string) *sync.WaitGroup

func HMCreatedByAMKO

func HMCreatedByAMKO(hmName string) bool

hmCreatedByAMKO checks if the health monitor is created by AMKO by checking the prefix of the HM name. If the prefix "amko" exists for the HM name, we return true, else false.

func InTestMode

func InTestMode() bool

func InitResync

func InitResync()

func IsClusterContextPresent

func IsClusterContextPresent(cc string) bool

func IsControllerLeader

func IsControllerLeader() bool

func IsDefaultSecretEnabled

func IsDefaultSecretEnabled(annotations map[string]string) bool

func IsDownResponseChanged

func IsDownResponseChanged(old, new *gdpv1alpha2.GlobalDeploymentPolicy) bool

func IsEmpty

func IsEmpty() bool

func IsGSLBConfigSet

func IsGSLBConfigSet() bool

func IsHmTemplateChanged

func IsHmTemplateChanged(old, new *gdpv1alpha2.GlobalDeploymentPolicy) bool

func IsLogLevelValid

func IsLogLevelValid(level string) bool

func IsResyncRequired

func IsResyncRequired() bool

func LogAndPanic

func LogAndPanic(panicMsg string)

LogAndPanic first logs an error message and then calls panic to stop the execution. This ensures that logs messages are not missing when PVC is used for storing the logs

func MultiClusterKey

func MultiClusterKey(operation, objType, clusterName, ns, objName string) string

func MultiClusterKeyForHostRule

func MultiClusterKeyForHostRule(operation, objType, clusterName, ns, objName, lfqdn, gfqdn string) string

func MultiClusterKeyWithObjName

func MultiClusterKeyWithObjName(operation, objType, compositeName string) string

func PresentInList

func PresentInList(key string, strList []string) bool

func RouteGetIPAddr

func RouteGetIPAddr(route *routev1.Route) (string, bool)

func SetControllerAsFollower

func SetControllerAsFollower()

func SetControllerAsLeader

func SetControllerAsLeader()

func SetCustomFqdnMode

func SetCustomFqdnMode(custom *bool)

func SetDifference

func SetDifference(a, b []string) []string

Difference compares two slices a & b, returns the elements in `a` that aren't in `b`.

func SetEqual

func SetEqual(a, b []string) bool

func SetGDPObj

func SetGDPObj(name, ns string)

func SetGSLBConfig

func SetGSLBConfig(value bool)

func SetGSLBConfigObj

func SetGSLBConfigObj(gc *gslbalphav1.GSLBConfig)

func SetGslbConfigObjUpdated

func SetGslbConfigObjUpdated(value bool)

func SetInformersPerCluster

func SetInformersPerCluster(clusterName string, info *utils.Informers)

func SetResyncRequired

func SetResyncRequired(value bool)

func SetTestMode

func SetTestMode(t bool)

func SetWaitGroupMap

func SetWaitGroupMap()

func SplitMultiClusterIngHostName

func SplitMultiClusterIngHostName(name string) (string, string, string, string, error)

func SplitMultiClusterNS

func SplitMultiClusterNS(name string) (string, string, error)

func SplitMultiClusterObjectName

func SplitMultiClusterObjectName(name string) (string, string, string, error)

func UpdateAmkoUuidGSLBConfig

func UpdateAmkoUuidGSLBConfig(gc *gslbalphav1.GSLBConfig, uuid string) error

func UpdateGSLBConfigStatus

func UpdateGSLBConfigStatus(msg string) error

func WaitForWorkersToExit

func WaitForWorkersToExit()

Types

type AppFilter

type AppFilter struct {
	Label
}

type AviControllerConfig

type AviControllerConfig struct {
	Username string
	Password string
	IPAddr   string
	Version  string
	Tenant   string
}

func GetAviConfig

func GetAviConfig() AviControllerConfig

func NewAviControllerConfig

func NewAviControllerConfig(username, password, ipAddr, version string, tenant string) *AviControllerConfig

type ClusterProperties

type ClusterProperties struct {
	// SyncVipsOnly advises AMKO to sync only the VIPs of the member objects of a GS
	SyncVipsOnly bool
}

ClusterProperties contains the properties for a cluster.

type ClusterTraffic

type ClusterTraffic struct {
	ClusterName string
	Weight      uint32
	Priority    uint32
}

ClusterTraffic determines the "Weight" of traffic routed to a cluster with name "ClusterName"

type EventRecorder

type EventRecorder struct {
	Recorder record.EventRecorder
}

func NewEventRecorder

func NewEventRecorder(id string, kubeClient kubernetes.Interface) *EventRecorder

type FullSyncThread

type FullSyncThread struct {
	Shutdown     chan interface{}
	Interval     time.Duration
	SyncFunction func()
}

func NewFullSyncThread

func NewFullSyncThread(interval time.Duration) *FullSyncThread

func (*FullSyncThread) Run

func (t *FullSyncThread) Run()

type GDPObj

type GDPObj struct {
	Namespace string
	Name      string
	GDPLock   sync.RWMutex
}

type GSDomainName

type GSDomainName struct {
	Cluster    string
	DomainName string
}

type GSFqdnHostRules

type GSFqdnHostRules struct {
	GSHostRuleList map[string]*GSHostRules
	GlobalLock     sync.RWMutex
}

func GetGSHostRulesList

func GetGSHostRulesList() *GSFqdnHostRules

func (*GSFqdnHostRules) BuildAndSetGSHostRulesForFQDN

func (ghrules *GSFqdnHostRules) BuildAndSetGSHostRulesForFQDN(gslbhr *gslbhralphav1.GSLBHostRule)

func (*GSFqdnHostRules) DeleteGSHostRulesForFQDN

func (ghrules *GSFqdnHostRules) DeleteGSHostRulesForFQDN(fqdn string)

func (*GSFqdnHostRules) GetAllGSHostRules

func (ghrules *GSFqdnHostRules) GetAllGSHostRules() []GSHostRules

func (*GSFqdnHostRules) GetGSHostRulesForFQDN

func (ghrules *GSFqdnHostRules) GetGSHostRulesForFQDN(gsFqdn string) *GSHostRules

func (*GSFqdnHostRules) SetGSHostRulesForFQDN

func (ghrules *GSFqdnHostRules) SetGSHostRulesForFQDN(ghr *GSHostRules)

type GSHostRules

type GSHostRules struct {
	GSFqdn            string
	HmRefs            []string
	HmTemplate        *string
	SitePersistence   *gslbhralphav1.SitePersistence
	TTL               *uint32
	TrafficSplit      []gslbhralphav1.TrafficSplitElem
	PublicIP          []gslbhralphav1.PublicIPElem
	ThirdPartyMembers []gslbhralphav1.ThirdPartyMember
	GslbPoolAlgorithm *gslbhralphav1.PoolAlgorithmSettings
	GslbDownResponse  *gslbhralphav1.DownResponse
	Checksum          uint32
	Lock              *sync.RWMutex
}

func GetGSHostRuleForGSLBHR

func GetGSHostRuleForGSLBHR(gslbhr *gslbhralphav1.GSLBHostRule) *GSHostRules

GetGSHostRuleForGSLBHr parses a GSLB HostRule object and returns a GSHostRules struct

func (*GSHostRules) CalculateAndSetChecksum

func (ghr *GSHostRules) CalculateAndSetChecksum()

func (*GSHostRules) DeepCopyInto

func (in *GSHostRules) DeepCopyInto(out *GSHostRules)

func (*GSHostRules) GetChecksum

func (ghr *GSHostRules) GetChecksum() uint32

type GSLBConfigObj

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

GSLBConfigObj is global and is initialized only once

type GlobalFilter

type GlobalFilter struct {
	// AppFilter contains rules for selecting applications
	AppFilter *AppFilter
	// NamespaceRules contains NamespaceSelector rules
	NSFilter *NamespaceFilter
	// TrafficSplit provides weights of traffic routed to different clusters
	TrafficSplit []ClusterTraffic
	// ApplicableClusters contain the list of clusters on which the filters
	// will be applicable
	ApplicableClusters map[string]ClusterProperties
	// List of health monitors to be attached to all the GSs
	HealthMonitorRefs []string
	// Health monitor template created by the user
	HealthMonitorTemplate *string
	// Site Persistence properties to be applied to all the GSs
	SitePersistenceRef *string
	// PKI Profile to be used with site persistence
	PkiProfileRef *string
	// Time To Live value for each fqdn
	TTL *uint32
	// Gslb Pool algorithm settings
	GslbPoolAlgorithm *gslbalphav1.PoolAlgorithmSettings
	// Response to the client when the GSLB service is down
	GslbDownResponse *gslbalphav1.DownResponse
	Checksum         uint32
	// Respective filters for the namespaces.
	// NSFilterMap map[string]*NSFilter
	// GlobalLock is locked before accessing any of the filters.
	GlobalLock sync.RWMutex
}

GlobalFilter is all the filters at one place. It also holds a list of ApplicableClusters to which all the filters are applicable. This list cannot be empty.

var (
	// Need to keep this global since, it will be used across multiple layers and multiple handlers
	Gfi *GlobalFilter
)

func GetGlobalFilter

func GetGlobalFilter() *GlobalFilter

GetGlobalFilter returns the existing global filter

func GetNewGlobalFilter

func GetNewGlobalFilter() *GlobalFilter

GetNewGlobalFilter returns a new GlobalFilter. It is to be called only once with the the GDP object as the input. Either the namespace of the GDP object is AVISystem or its some other namespace. Based on that this GlobalFilter is created.

func (*GlobalFilter) AddNSToNSFilter

func (gf *GlobalFilter) AddNSToNSFilter(cname, ns string) error

func (*GlobalFilter) AddToFilter

func (gf *GlobalFilter) AddToFilter(gdp *gdpv1alpha2.GlobalDeploymentPolicy)

AddToFilter handles creation of new filters, cluster or otherwise. Only one GDP object allowed per-cluster.

func (*GlobalFilter) ComputeChecksum

func (gf *GlobalFilter) ComputeChecksum()

func (*GlobalFilter) DeleteFromGlobalFilter

func (gf *GlobalFilter) DeleteFromGlobalFilter(gdp *gdpv1alpha2.GlobalDeploymentPolicy)

DeleteFromGlobalFilter deletes a filter pertaining to gdp.

func (*GlobalFilter) GetAppFilterLabel

func (gf *GlobalFilter) GetAppFilterLabel() (Label, error)

func (*GlobalFilter) GetAviHmRefs

func (gf *GlobalFilter) GetAviHmRefs() []string

func (*GlobalFilter) GetAviHmTemplate

func (gf *GlobalFilter) GetAviHmTemplate() *string

func (*GlobalFilter) GetCopy

func (gf *GlobalFilter) GetCopy() *GlobalFilter

func (*GlobalFilter) GetDownResponse

func (gf *GlobalFilter) GetDownResponse() *gslbalphav1.DownResponse

func (*GlobalFilter) GetGslbPoolAlgorithm

func (gf *GlobalFilter) GetGslbPoolAlgorithm() *gslbalphav1.PoolAlgorithmSettings

func (*GlobalFilter) GetNSFilterLabel

func (gf *GlobalFilter) GetNSFilterLabel() (Label, error)

func (*GlobalFilter) GetPKIProfile

func (gf *GlobalFilter) GetPKIProfile() *string

func (*GlobalFilter) GetSitePersistence

func (gf *GlobalFilter) GetSitePersistence() *string

func (*GlobalFilter) GetTTL

func (gf *GlobalFilter) GetTTL() *uint32

func (*GlobalFilter) GetTrafficPriority

func (gf *GlobalFilter) GetTrafficPriority(cname string) (uint32, error)

func (*GlobalFilter) GetTrafficWeight

func (gf *GlobalFilter) GetTrafficWeight(cname string) (uint32, error)

func (*GlobalFilter) IsClusterAllowed

func (gf *GlobalFilter) IsClusterAllowed(cname string) bool

func (*GlobalFilter) IsClusterSyncVIPOnly

func (gf *GlobalFilter) IsClusterSyncVIPOnly(cname string) (bool, error)

func (*GlobalFilter) UpdateGlobalFilter

func (gf *GlobalFilter) UpdateGlobalFilter(oldGDP, newGDP *gdpv1alpha2.GlobalDeploymentPolicy) (bool, bool, []string)

UpdateGlobalFilter takes two arguments: the old and the new GDP objects, and verifies whether a change is required to any of the filters. If yes, it changes either the cluster filter or one of the namespace filters.

type HostRuleMeta

type HostRuleMeta struct {
	LFqdn   string
	GSFqdn  string
	TLS     bool
	Aliases []string
}

HostRuleMeta stores a partial set of information stripped from the HostRule object, information only required for AMKO.

func GetHostRuleMeta

func GetHostRuleMeta(lFqdn, gsFqdn string, tls bool, aliases []string) HostRuleMeta

type IngressHostIP

type IngressHostIP struct {
	Hostname string
	IPAddr   string
}

func IngressGetIPAddrs

func IngressGetIPAddrs(ingress *networkingv1.Ingress) []IngressHostIP

type Label

type Label struct {
	Key   string
	Value string
}

type LocalFqdn

type LocalFqdn struct {
	Cluster string
	Fqdn    string
}

type LocalToGlobalFqdn

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

func (*LocalToGlobalFqdn) AddUpdateFqdnMapping

func (lgFqdn *LocalToGlobalFqdn) AddUpdateFqdnMapping(gsFqdn, lFqdn, cname string)

func (*LocalToGlobalFqdn) DeleteFqdn

func (lgFqdn *LocalToGlobalFqdn) DeleteFqdn(cname string, lFqdn string)

func (*LocalToGlobalFqdn) GetGlobalFqdnFor

func (lgFqdn *LocalToGlobalFqdn) GetGlobalFqdnFor(cname string, lFqdn string) (string, error)

type NamespaceFilter

type NamespaceFilter struct {
	Label
	// SelectedNS contains a list of namespaces selected via this filter
	// updated by the namespace event handlers
	SelectedNS map[string][]string
	// Checksum to check for changes if GDP changes and to see if a
	// re-application of namespaces is required
	Checksum uint32
	Lock     sync.RWMutex
}

func (*NamespaceFilter) AddNS

func (nsFilter *NamespaceFilter) AddNS(cname, ns string)

func (*NamespaceFilter) GetChecksum

func (nsFilter *NamespaceFilter) GetChecksum() uint32

func (*NamespaceFilter) GetFilterLabel

func (nsFilter *NamespaceFilter) GetFilterLabel() Label

type ResyncStatus

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

Jump to

Keyboard shortcuts

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