util

package
v0.0.0-...-a1c3796 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Action = "action"

	CreateALBListener                               = "CreateALBListener"
	CreateALBListenerAsynchronous                   = "CreateALBListenerAsynchronous"
	DeleteALBListener                               = "DeleteALBListener"
	UpdateALBListenerAttribute                      = "UpdateALBListenerAttribute"
	ListALBListeners                                = "ListALBListeners"
	GetALBListenerAttribute                         = "GetALBListenerAttribute"
	ListALBListenerCertificates                     = "ListALBListenerCertificates"
	AssociateALBAdditionalCertificatesWithListener  = "AssociateALBAdditionalCertificatesWithListener"
	DissociateALBAdditionalCertificatesFromListener = "DissociateALBAdditionalCertificatesFromListener"

	CreateALBLoadBalancer             = "CreateALBLoadBalancer"
	CreateALBLoadBalancerAsynchronous = "CreateALBLoadBalancerAsynchronous"
	DeleteALBLoadBalancer             = "DeleteALBLoadBalancer"
	ListALBLoadBalancers              = "ListALBLoadBalancers"
	GetALBLoadBalancerAttribute       = "GetALBLoadBalancerAttribute"
	UpdateALBLoadBalancerAttribute    = "UpdateALBLoadBalancerAttribute"
	UpdateALBLoadBalancerEdition      = "UpdateALBLoadBalancerEdition"
	EnableALBLoadBalancerAccessLog    = "EnableALBLoadBalancerAccessLog"
	DisableALBLoadBalancerAccessLog   = "DisableALBLoadBalancerAccessLog"
	EnableALBDeletionProtection       = "EnableALBDeletionProtection"
	DisableALBDeletionProtection      = "DisableALBDeletionProtection"

	TagALBResource    = "TagALBResource"
	AnalyzeProductLog = "AnalyzeProductLog"

	CreateALBRule           = "CreateALBRule"
	CreateALBRules          = "CreateALBRules"
	DeleteALBRule           = "DeleteALBRule"
	DeleteALBRules          = "DeleteALBRules"
	ListALBRules            = "ListALBRules"
	UpdateALBRuleAttribute  = "UpdateALBRuleAttribute"
	UpdateALBRulesAttribute = "UpdateALBRulesAttribute"

	CreateALBServerGroup                        = "CreateALBServerGroup"
	DeleteALBServerGroup                        = "DeleteALBServerGroup"
	UpdateALBServerGroupAttribute               = "UpdateALBServerGroupAttribute"
	ListALBServerGroups                         = "ListALBServerGroups"
	ListALBServerGroupServers                   = "ListALBServerGroupServers"
	AddALBServersToServerGroupAsynchronous      = "AddALBServersToServerGroupAsynchronous"
	AddALBServersToServerGroup                  = "AddALBServersToServerGroup"
	RemoveALBServersFromServerGroupAsynchronous = "RemoveALBServersFromServerGroupAsynchronous"
	RemoveALBServersFromServerGroup             = "RemoveALBServersFromServerGroup"
	ReplaceALBServersInServerGroupAsynchronous  = "ReplaceALBServersInServerGroupAsynchronous"
	ReplaceALBServersInServerGroup              = "ReplaceALBServersInServerGroup"
)
View Source
const (
	// IngressClass
	IngressClass = "kubernetes.io/ingress.class"

	// Ingress annotation suffixes
	IngressSuffixAlbConfigName  = "albconfig.name"
	IngressSuffixAlbConfigOrder = "albconfig.order"
	IngressSuffixListenPorts    = "listen-ports"
)
View Source
const (
	BatchRegisterDeregisterServersMaxNum = 40
	BatchRegisterServersDefaultNum       = 30
	BatchDeregisterServersDefaultNum     = 30

	ServerStatusAdding      = "Adding"
	ServerStatusAvailable   = "Available"
	ServerStatusConfiguring = "Configuring"
	ServerStatusRemoving    = "Removing"

	LoadBalancerStatusActive       = "Active"
	LoadBalancerStatusInactive     = "Inactive"
	LoadBalancerStatusProvisioning = "Provisioning"
	LoadBalancerStatusConfiguring  = "Configuring"
	LoadBalancerStatusCreateFailed = "CreateFailed"

	ListenerStatusProvisioning = "Provisioning"
	ListenerStatusRunning      = "Running"
	ListenerStatusConfiguring  = "Configuring"
	ListenerStatusStopped      = "Stopped"
)
View Source
const (
	BatchCreateDeleteUpdateRulesMaxNum = 10
	BatchCreateRulesDefaultNum         = 9
	BatchDeleteRulesDefaultNum         = 9
	BatchUpdateRulesDefaultNum         = 9
)
View Source
const (
	CreateLoadBalancerWaitActiveMaxRetryTimes = 10
	CreateLoadBalancerWaitActiveRetryInterval = 2 * time.Second

	CreateListenerWaitRunningMaxRetryTimes = 15
	CreateListenerWaitRunningRetryInterval = 1 * time.Second
)
View Source
const (
	DefaultLogAcceptFormat = "xml"
	DefaultLogCloudProduct = "k8s-nginx-ingress"
	DefaultLogLang         = "cn"
	DefaultLogDomainSuffix = "-intranet.log.aliyuncs.com/open-api"

	MinLogProjectNameLen = 4
	MaxLogProjectNameLen = 63
	MinLogStoreNameLen   = 2
	MaxLogStoreNameLen   = 64
)
View Source
const (
	ServerGroupResourceType  = "ServerGroup"
	LoadBalancerResourceType = "LoadBalancer"
)
View Source
const (
	ServerTypeEcs = "Ecs"
	ServerTypeEni = "Eni"
	ServerTypeEci = "Eci"
)
View Source
const (
	AddALBServersToServerGroupWaitAvailableMaxRetryTimes = 60
	AddALBServersToServerGroupWaitAvailableRetryInterval = time.Second
	RemoveALBServersFromServerGroupMaxRetryTimes         = 60
	RemoveALBServersFromServerGroupRetryInterval         = time.Second
	ReplaceALBServersInServerGroupMaxRetryTimes          = 60
	ReplaceALBServersInServerGroupRetryInterval          = time.Second
)
View Source
const (
	TrafficPolicyEni     = "eni"
	TrafficPolicyLocal   = "local"
	TrafficPolicyCluster = "cluster"
)
View Source
const (
	ServerGroupConcurrentNum = 5
	ListenerConcurrentNum    = 5
)
View Source
const (
	LabelNodeRoleMaster = "node-role.kubernetes.io/master"

	LabelNodeExcludeApplicationLoadBalancer = "alpha.service-controller.kubernetes.io/exclude-alb"

	LabelNodeTypeVK = "virtual-kubelet"

	DefaultServerWeight = 100
)
View Source
const (
	ClusterTagKey          = "ack.aliyun.com"
	ServiceNamespaceTagKey = IngressTagKeyPrefix + "/service_ns"
	ServiceNameTagKey      = IngressTagKeyPrefix + "/service_name"
	ServicePortTagKey      = IngressTagKeyPrefix + "/service_port"
	IngressNameTagKey      = IngressTagKeyPrefix + "/ingress_name"

	AlbConfigTagKey = "albconfig"
)
View Source
const (
	RuleActionTypeFixedResponse string = "FixedResponse"
	RuleActionTypeRedirect      string = "Redirect"
	RuleActionTypeForward       string = "ForwardGroup"
)
View Source
const (
	RuleConditionFieldHost        string = "Host"
	RuleConditionFieldPath        string = "Path"
	RuleConditionFieldHeader      string = "Header"
	RuleConditionFieldQueryString string = "QueryString"
	RuleConditionFieldMethod      string = "Method"
	RuleConditionFieldCookie      string = "Cookie"
)
View Source
const (
	DefaultServerGroupScheduler string = ServerGroupSchedulerWrr
	DefaultServerGroupProtocol  string = ServerGroupProtocolHTTP
	DefaultServerGroupType      string = "instance"

	DefaultServerGroupHealthCheckInterval            = 2                                   // 1~50
	DefaultServerGroupHealthyThreshold               = 3                                   // 2~10
	DefaultServerGroupHealthCheckHost                = "$SERVER_IP"                        // GET OR HEAD
	DefaultServerGroupHealthCheckPath                = "/"                                 // GET OR HEAD
	DefaultServerGroupHealthCheckHttpVersion         = ServerGroupHealthCheckHttpVersion11 // HTTP1.0 OR HTTP1.1
	DefaultServerGroupHealthCheckEnabled             = false
	DefaultServerGroupHealthCheckTimeout             = 5 // 1~300
	DefaultServerGroupHealthCheckTcpFastCloseEnabled = false
	DefaultServerGroupHealthCheckConnectPort         = 0                                  // 0~65535
	DefaultServerGroupHealthCheckHTTPCodes           = ServerGroupHealthCheckCodes2xx     // http_2xx、http_3xx、http_4xx OR http_5xx
	DefaultServerGroupHealthCheckCodes               = ServerGroupHealthCheckCodes2xx     // http_2xx、http_3xx、http_4xx OR http_5xx
	DefaultServerGroupHealthCheckMethod              = ServerGroupHealthCheckMethodHEAD   // GET OR HEAD
	DefaultServerGroupUnhealthyThreshold             = 3                                  // 2~10
	DefaultServerGroupHealthCheckProtocol            = ServerGroupHealthCheckProtocolHTTP // HTTP、HTTPS

	// Cookie timeout period. Unit: second
	// Value: 1~86400
	// Default value: 1000
	// Description: When StickySessionEnabled is true and StickySessionType is Insert, this parameter is mandatory.
	DefaultServerGroupStickySessionCookieTimeout = 1000
	// Whether to enable session retention, value: true or false (default value).
	DefaultServerGroupStickySessionEnabled = false
	//Cookie processing method. Value:
	//Insert (default value): Insert Cookie.
	//When the client visits for the first time, the load balancer will implant a cookie in the return request (that is, insert the SERVERID in the HTTP or HTTPS response message), the next time the client visits with this cookie, the load balance service will direct the request Forward to the back-end server previously recorded.
	//Server: Rewrite Cookie.
	//The load balancer finds that the user has customized the cookie and will rewrite the original cookie. The next time the client visits with a new cookie, the load balancer service will direct the request to the back-end server that was previously recorded.
	DefaultServerGroupStickySessionType = ServerGroupStickySessionTypeInsert

	DefaultLoadBalancerAddressType                        string = LoadBalancerAddressTypeInternet
	DefaultLoadBalancerAddressAllocatedMode               string = LoadBalancerAddressAllocatedModeDynamic
	DefaultLoadBalancerEdition                            string = LoadBalancerEditionBasic
	DefaultLoadBalancerBillingConfigPayType               string = LoadBalancerPayTypePostPay
	DefaultLoadBalancerDeletionProtectionConfigEnabled    bool   = true
	DefaultLoadBalancerModificationProtectionConfigStatus string = LoadBalancerModificationProtectionStatusConsoleProtection

	DefaultListenerProtocol         = ListenerProtocolHTTP
	DefaultListenerPort             = 80
	DefaultListenerIdleTimeout      = 15
	DefaultListenerRequestTimeout   = 60
	DefaultListenerGzipEnabled      = true
	DefaultListenerHttp2Enabled     = true
	DefaultListenerSecurityPolicyId = "tls_cipher_policy_1_0"
)
View Source
const (
	ServerGroupSchedulerWrr = "Wrr"
	ServerGroupSchedulerWlc = "Wlc"
	ServerGroupSchedulerSch = "Sch"

	ServerGroupProtocolHTTP  = "HTTP"
	ServerGroupProtocolHTTPS = "HTTPS"

	ServerGroupHealthCheckMethodGET     = "GET"
	ServerGroupHealthCheckMethodHEAD    = "HEAD"
	ServerGroupHealthCheckProtocolHTTP  = "HTTP"
	ServerGroupHealthCheckProtocolHTTPS = "HTTPS"
	ServerGroupHealthCheckCodes2xx      = "http_2xx"
	ServerGroupHealthCheckCodes3xx      = "http_3xx"
	ServerGroupHealthCheckCodes4xx      = "http_4xx"
	ServerGroupHealthCheckCodes5xx      = "http_5xx"
	ServerGroupHealthCheckHttpVersion10 = "HTTP1.0"
	ServerGroupHealthCheckHttpVersion11 = "HTTP1.1"

	ServerGroupStickySessionTypeInsert = "Insert"
	ServerGroupStickySessionTypeServer = "Server"
)
View Source
const (
	LoadBalancerEditionBasic    = "Basic"
	LoadBalancerEditionStandard = "Standard"

	LoadBalancerAddressTypeInternet = "Internet"
	LoadBalancerAddressTypeIntranet = "Intranet"

	LoadBalancerPayTypePostPay = "PostPay"

	LoadBalancerAddressAllocatedModeFixed   = "Fixed"
	LoadBalancerAddressAllocatedModeDynamic = "Dynamic"

	LoadBalancerModificationProtectionStatusNonProtection     = "NonProtection"
	LoadBalancerModificationProtectionStatusConsoleProtection = "ConsoleProtection"
)
View Source
const (
	ListenerProtocolHTTP  = "HTTP"
	ListenerProtocolHTTPS = "HTTPS"
	ListenerProtocolQUIC  = "QUIC"
)
View Source
const (
	ApplierManagerLogLevel     = 0
	ApplierSynthesizerLogLevel = 0
)
View Source
const (
	BatchReplaceServersMaxNum = 40
)
View Source
const ConcurrentMaxSleepMillisecondTime = 200
View Source
const (
	DefaultListenerFlag = "-listener-"
)
View Source
const IndexKeyServiceRefName = "spec.serviceRef.name"
View Source
const (
	IngressClassALB = "alb"
)
View Source
const (
	IngressFinalizer = IngressTagKeyPrefix + "/resources"
)
View Source
const (
	IngressTagKeyPrefix = "ingress.k8s.alibaba"
)
View Source
const IsWaitServersAsynchronousComplete = true
View Source
const (
	MgrLogLevel = ApplierManagerLogLevel
)
View Source
const (
	SynLogLevel = ApplierSynthesizerLogLevel
)
View Source
const (
	TraceID = ContextTraceID("traceID")
)

Variables

View Source
var (
	ServiceLog logr.Logger
	NLBLog     logr.Logger
	NodeLog    logr.Logger
)
View Source
var RandomSleepFunc = func(max int) {
	if max <= 0 {
		max = ConcurrentMaxSleepMillisecondTime
	}
	time.Sleep(time.Duration(rand.Intn(max)) * time.Millisecond)
}

Functions

func ClusterVersionAtLeast

func ClusterVersionAtLeast(client *apiext.Clientset, min string) (bool, error)

ClusterVersionAtLeast Check kubernetes version whether higher than the specific version

func DiffLoadBalancerTags

func DiffLoadBalancerTags(local, remote []tag.Tag) ([]tag.Tag, []tag.Tag)

func HandleReconcileResult

func HandleReconcileResult(request reconcile.Request, err error) (reconcile.Result, error)

func IsStringSliceEqual

func IsStringSliceEqual(s1, s2 []string) bool

func Key

func Key(obj metav1.Object) string

func MergeStringMap

func MergeStringMap(maps ...map[string]string) map[string]string

MergeStringMap will merge multiple map[string]string into single one. The merge is executed for maps argument in sequential order, if a key already exists, the value from previous map is kept. e.g. MergeStringMap(map[string]string{"a": "1", "b": "2"}, map[string]string{"a": "3", "d": "4"}) == map[string]string{"a": "1", "b": "2", "d": "4"}

func NamespacedName

func NamespacedName(obj metav1.Object) types.NamespacedName

func PrettyJson

func PrettyJson(object interface{}) string

func RetryImmediateOnError

func RetryImmediateOnError(interval time.Duration, timeout time.Duration, retryable func(error) bool, fn func() error) error

Types

type Attempt

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

func (*Attempt) HasNext

func (a *Attempt) HasNext() bool

HasNext returns whether another attempt will be made if the current one fails. If it returns true, the following call to Next is guaranteed to return true.

func (*Attempt) Next

func (a *Attempt) Next() bool

Next waits until it is time to perform the next attempt or returns false if it is time to stop trying.

type AttemptStrategy

type AttemptStrategy struct {
	Total time.Duration // total duration of attempt.
	Delay time.Duration // interval between each try in the burst.
	Min   int           // minimum number of retries; overrides Total
}

AttemptStrategy represents a strategy for waiting for an action to complete successfully. This is an internal type used by the implementation of other packages.

func (AttemptStrategy) Start

func (s AttemptStrategy) Start() *Attempt

Start begins a new sequence of attempts for the given strategy.

type ContextTraceID

type ContextTraceID string

type ReconcileNeedRequeue

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

func NewReconcileNeedRequeue

func NewReconcileNeedRequeue(reason string) *ReconcileNeedRequeue

func (*ReconcileNeedRequeue) Error

func (r *ReconcileNeedRequeue) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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