helper

package
v0.0.0-...-894910e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	FailedAddFinalizer     = "FailedAddFinalizer"
	FailedRemoveFinalizer  = "FailedRemoveFinalizer"
	FailedAddHash          = "FailedAddHash"
	FailedRemoveHash       = "FailedRemoveHash"
	FailedUpdateStatus     = "FailedUpdateStatus"
	UnAvailableBackends    = "UnAvailableLoadBalancer"
	SkipSyncBackends       = "SkipSyncBackends"
	FailedSyncLB           = "SyncLoadBalancerFailed"
	SucceedCleanLB         = "CleanLoadBalancer"
	FailedCleanLB          = "CleanLoadBalancerFailed"
	SucceedSyncLB          = "EnsuredLoadBalancer"
	AnnoChanged            = "AnnotationChanged"
	TypeChanged            = "TypeChanged"
	SpecChanged            = "ServiceSpecChanged"
	DeleteTimestampChanged = "DeleteTimestampChanged"
)

ServiceEventReason

View Source
const (
	FailedDeleteNode  = "DeleteNodeFailed"
	FailedAddNode     = "AddNodeFailed"
	FailedSyncNode    = "SyncNodeFailed"
	SucceedDeleteNode = "DeletedNode"
	InitializedNode   = "InitializedNode"
)

NodeEventReason

View Source
const (
	FailedCreateRoute  = "CreateRouteFailed"
	FailedSyncRoute    = "SyncRouteFailed"
	SucceedCreateRoute = "CreatedRoute"
)

RouteEventReason

View Source
const (
	// Ingress events
	IngressEventReasonFailedAddFinalizer     = "FailedAddFinalizer"
	IngressEventReasonFailedRemoveFinalizer  = "FailedRemoveFinalizer"
	IngressEventReasonFailedUpdateStatus     = "FailedUpdateStatus"
	IngressEventReasonFailedBuildModel       = "FailedBuildModel"
	IngressEventReasonFailedApplyModel       = "FailedApplyModel"
	IngressEventReasonSuccessfullyReconciled = "SuccessfullyReconciled"
)
View Source
const (
	PatchAll    = "all"
	PatchSpec   = "spec"
	PatchStatus = "status"
)
View Source
const (
	LabelNodeRoleMaster = "node-role.kubernetes.io/master"
	LabelNodeTypeVK     = "virtual-kubelet"
	// LabelNodeExcludeBalancer specifies that the node should be
	// exclude from loadbalancers created by a cloud provider.
	LabelNodeExcludeBalancerDeprecated = "alpha.service-controller.kubernetes.io/exclude-balancer"
	LabelNodeExcludeBalancer           = v1.LabelNodeExcludeBalancers
	// ToBeDeletedTaint is a taint used by the CLuster Autoscaler before marking a node for deletion.
	// Details in https://github.com/kubernetes/cloud-provider/blob/5bb9b27442bcb2613a9ca4046c89109de4435824/controllers/service/controller.go#L58
	ToBeDeletedTaint = "ToBeDeletedByClusterAutoscaler"

	// LabelNodeExcludeNodeDeprecated specifies that the node should be exclude from CCM
	LabelNodeExcludeNodeDeprecated = "service.beta.kubernetes.io/exclude-node"
	LabelNodeExcludeNode           = "service.alibabacloud.com/exclude-node"
)
View Source
const (
	ServiceFinalizer = "service.k8s.alibaba/resources"
	NLBFinalizer     = "service.k8s.alibaba/nlb"
)

Finalizer

View Source
const (
	BackendType       = "service.beta.kubernetes.io/backend-type"
	LoadBalancerClass = "service.beta.kubernetes.io/class"
)

annotation

View Source
const (
	LabelServiceHash    = "service.beta.kubernetes.io/hash"
	LabelLoadBalancerId = "service.k8s.alibaba/loadbalancer-id"
)

label

View Source
const (
	TAGKEY   = "kubernetes.do.not.delete"
	REUSEKEY = "kubernetes.reused.by.user"
)
View Source
const (
	// LocalTrafficPolicy externalTrafficPolicy=Local
	LocalTrafficPolicy = TrafficPolicy("Local")
	// ClusterTrafficPolicy externalTrafficPolicy=Cluster
	ClusterTrafficPolicy = TrafficPolicy("Cluster")
	// ENITrafficPolicy is forwarded to pod directly
	ENITrafficPolicy = TrafficPolicy("ENI")
)
View Source
const NLBClass = "alibabacloud.com/nlb"

load balancer class

View Source
const TRY_AGAIN = "try again"
View Source
const TargetHealthPodConditionTypePrefix = "target-health.alb.k8s.alicloud"

Prefix for TargetHealth pod condition type.

Variables

This section is empty.

Functions

func BuildReadinessGatePodConditionType

func BuildReadinessGatePodConditionType() corev1.PodConditionType

BuildTargetHealthPodConditionType constructs the condition type for TargetHealth pod condition.

func FindCondition

func FindCondition(conds []v1.NodeCondition, conditionType v1.NodeConditionType) (*v1.NodeCondition, bool)

func FindNodeByNodeName

func FindNodeByNodeName(nodes []v1.Node, nodeName string) *v1.Node

func GetLogMessage

func GetLogMessage(err error) string

func GetNodeCondition

func GetNodeCondition(node *v1.Node, conditionType v1.NodeConditionType) *v1.NodeCondition

GetNodeCondition will get pointer to Node's existing condition. returns nil if no matching condition found.

func GetNodeInternalIP

func GetNodeInternalIP(node *v1.Node) (string, error)

func GetPodCondition

func GetPodCondition(pod *corev1.Pod, conditionType corev1.PodConditionType) *corev1.PodCondition

GetPodCondition will get pointer to Pod's existing condition. returns nil if no matching condition found.

func GetServiceHash

func GetServiceHash(svc *v1.Service) string

func HasExcludeLabel

func HasExcludeLabel(node *v1.Node) bool

func HasFinalizer

func HasFinalizer(obj metav1.Object, finalizer string) bool

HasFinalizer tests whether k8s object has specified finalizer

func Is4LayerProtocol

func Is4LayerProtocol(protocol string) bool

func Is7LayerProtocol

func Is7LayerProtocol(protocol string) bool

func IsClusterIPService

func IsClusterIPService(svc *v1.Service) bool

func IsENIBackendType

func IsENIBackendType(svc *v1.Service) bool

func IsIPv4

func IsIPv4(address string) bool

func IsIPv6

func IsIPv6(address string) bool

func IsLocalModeService

func IsLocalModeService(svc *v1.Service) bool

func IsMasterNode

func IsMasterNode(node *v1.Node) bool

func IsNodeExcludeFromLoadBalancer

func IsNodeExcludeFromLoadBalancer(node *v1.Node) bool

func IsPodContainersReady

func IsPodContainersReady(pod *corev1.Pod) bool

IsPodContainersReady returns whether pod is containersReady.

func IsPodHasReadinessGate

func IsPodHasReadinessGate(pod *corev1.Pod) bool

func IsServiceHashChanged

func IsServiceHashChanged(service *v1.Service) bool

func IsServiceOwnIngress

func IsServiceOwnIngress(service *v1.Service) bool

check if the service exists in service definition

func LogEndpointSlice

func LogEndpointSlice(es *discovery.EndpointSlice) string

func LogEndpointSliceList

func LogEndpointSliceList(esList []discovery.EndpointSlice) string

func LogEndpoints

func LogEndpoints(eps *v1.Endpoints) string

func NeedCLB

func NeedCLB(service *v1.Service) bool

func NeedDeleteLoadBalancer

func NeedDeleteLoadBalancer(svc *v1.Service) bool

func NeedNLB

func NeedNLB(service *v1.Service) bool

func NewDefaultFinalizerManager

func NewDefaultFinalizerManager(kclient client.Client) *defaultFinalizerManager

func NewDefaultReferenceIndexer

func NewDefaultReferenceIndexer() *defaultReferenceIndexer

func NodeFromProviderID

func NodeFromProviderID(providerID string) (string, string, error)

providerID 1) the id of the instance in the alicloud API. Use '.' to separate providerID which looks like 'cn-hangzhou.i-v98dklsmnxkkgiiil7'. The format of "REGION.NODEID" 2) the id for an instance in the kubernetes API, which has 'alicloud://' prefix. e.g. alicloud://cn-hangzhou.i-v98dklsmnxkkgiiil7

func NodeInfo

func NodeInfo(node *v1.Node) string

func PatchM

func PatchM(mclient client.Client, target client.Object, getter func(runtime.Object) (client.Object, error), resource string,
) error

func PatchNodeStatus

func PatchNodeStatus(mclient client.Client, target *v1.Node, getter func(*v1.Node) (*v1.Node, error)) error

func Retry

func Retry(
	backoff *wait.Backoff,
	fun func(svc *v1.Service) error,
	svc *v1.Service,
) error

func UpdatePodCondition

func UpdatePodCondition(pod *corev1.Pod, condition corev1.PodCondition)

UpdatePodCondition will update Pod to contain specified condition.

Types

type APIObject

type APIObject interface {
	metav1.Object
	runtime.Object
}

type Element

type Element struct {
	Key         interface{}
	Event       Event
	IsSkippable bool
}

Element represents one item of the queue

func (Element) String

func (n Element) String() string

String returns the general purpose string representation

type Event

type Event struct {
	Type EventType
	Obj  interface{}
}

Event holds the context of an event.

type EventType

type EventType string

EventType type of event associated with an informer

const (
	// CreateEvent event associated with new objects in an informer
	CreateEvent EventType = "CREATE"
	// UpdateEvent event associated with an object update in an informer
	UpdateEvent EventType = "UPDATE"
	// DeleteEvent event associated when an object is removed from an informer
	IngressDeleteEvent EventType = "DELETE"
	// ConfigurationEvent event associated when a controller configuration object is created or updated
	ConfigurationEvent EventType = "CONFIGURATION"

	// NodeEvent event associated when a controller configuration object is created or updated
	NodeEvent EventType = "NODE"

	// ServiceEvent event associated when a controller configuration object is created or updated
	ServiceEvent EventType = "SERVICE"

	// EndPointEvent event associated when a controller configuration object is created or updated
	EndPointEvent EventType = "ENDPOINT"

	// IngressEvent event associated when a controller configuration object is created or updated
	IngressEvent EventType = "Ingress"
)

type FinalizerManager

type FinalizerManager interface {
	AddFinalizers(ctx context.Context, obj APIObject, finalizers ...string) error
	RemoveFinalizers(ctx context.Context, obj APIObject, finalizers ...string) error
}

type Queue

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

Queue manages a time work queue through an independent worker that invokes the given sync function for every work item inserted. The queue uses an internal timestamp that allows the removal of certain elements which timestamp is older than the last successful get operation.

func NewCustomTaskQueue

func NewCustomTaskQueue(syncFn func(interface{}) error, fn func(interface{}) (interface{}, error)) *Queue

NewCustomTaskQueue ...

func NewTaskQueue

func NewTaskQueue(syncFn func(interface{}) error) *Queue

NewTaskQueue creates a new task queue with the given sync function. The sync function is called for every element inserted into the queue.

func (*Queue) EnqueueSkippableTask

func (t *Queue) EnqueueSkippableTask(obj interface{})

EnqueueSkippableTask enqueues ns/name of the given api object in the task queue that can be skipped

func (*Queue) EnqueueTask

func (t *Queue) EnqueueTask(obj interface{})

EnqueueTask enqueues ns/name of the given api object in the task queue.

func (*Queue) IsShuttingDown

func (t *Queue) IsShuttingDown() bool

IsShuttingDown returns if the method Shutdown was invoked

func (*Queue) Run

func (t *Queue) Run(maxConcurrentReconciles int, period time.Duration, stopCh <-chan struct{})

Run starts processing elements in the queue

func (*Queue) Shutdown

func (t *Queue) Shutdown()

Shutdown shuts down the work queue and waits for the worker to ACK

type ReferenceIndexer

type ReferenceIndexer interface {
	BuildServiceRefIndexes(ctx context.Context, ing *networking.Ingress) []string
}

type TrafficPolicy

type TrafficPolicy string

func GetServiceTrafficPolicy

func GetServiceTrafficPolicy(svc *v1.Service) (TrafficPolicy, error)

Jump to

Keyboard shortcuts

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