utils

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateApiserverClient

func CreateApiserverClient(apiserverHost string, kubeConfig string) (*kubernetes.Clientset, error)

create k8s client from config file

func FilterByNodeLabel added in v0.2.6

func FilterByNodeLabel(nodes []*corev1.Node, nodeLabels map[string]string) []*corev1.Node

FilterByNodeLabel filters the given list of nodes by the given node labels.

func GenerateHashName

func GenerateHashName(clusterID, namespace, resourceName, resourceType string) string

func GenerateLBName

func GenerateLBName(clusterID, namespace, resourceName, resourceType string) string

func GeneratePolicyName

func GeneratePolicyName(clusterID, namespace, resourceName, resourceType string, mode bool, ruleIndex, pathIndex int) string

func GeneratePoolName

func GeneratePoolName(clusterID, namespace, resourceName, resourceType, serviceName string, port int) string

func GetIngress

func GetIngress(ingressLister nwlisters.IngressLister, key string) (*nwv1.Ingress, error)

func GetIntFromServiceAnnotation

func GetIntFromServiceAnnotation(service *corev1.Service, annotationKey string, defaultSetting int) int

func GetListProviderID

func GetListProviderID(pnodes []*corev1.Node) []string

func GetNodeMembersAddr

func GetNodeMembersAddr(nodeObjs []*corev1.Node) []string

func GetService

func GetService(serviceLister corelisters.ServiceLister, key string) (*corev1.Service, error)

func GetServiceNodePort

func GetServiceNodePort(serviceLister corelisters.ServiceLister, name string, serviceBackend *nwv1.IngressServiceBackend) (int, int, error)

func GetStringFromServiceAnnotation

func GetStringFromServiceAnnotation(pService *corev1.Service, annotationKey string, defaultSetting string) string

func HashString

func HashString(str string) string

HashString hash a string to a string have 10 char

func IsPoolProtocolValid

func IsPoolProtocolValid(pPool *lObjects.Pool, pPort corev1.ServicePort, pPoolName string) bool

func ListNodeWithPredicate

func ListNodeWithPredicate(nodeLister corelisters.NodeLister, nodeLabels map[string]string) ([]*corev1.Node, error)

func ListServiceWithPredicate

func ListServiceWithPredicate(serviceLister corelisters.ServiceLister) ([]*corev1.Service, error)

func ListWorkerNodes

func ListWorkerNodes(pNodes []*corev1.Node, pOnlyReadyNode bool) []*corev1.Node

func MapIDExpander

func MapIDExpander(old, cur *IngressInspect)

func MergeStringArray

func MergeStringArray(current, remove, add []string) ([]string, bool)

func MinInt

func MinInt(a, b int) int

func NodeNames

func NodeNames(nodes []*corev1.Node) []string

NodeNames get all the node names.

func NodeSlicesEqual

func NodeSlicesEqual(x, y []*corev1.Node) bool

NodeSlicesEqual check if two nodes equals to each other.

func ParseBoolAnnotation

func ParseBoolAnnotation(s, annotation string, defaultValue bool) bool

func ParseIntAnnotation

func ParseIntAnnotation(s, annotation string, defaultValue int) int

func ParseLoadBalancerScheme

func ParseLoadBalancerScheme(pInternal bool) lLoadBalancerV2.CreateOptsSchemeOpt

func ParseMonitorHealthCheckMethod

func ParseMonitorHealthCheckMethod(pMethod string) *lPoolV2.CreateOptsHealthCheckMethodOpt

func ParseMonitorHttpVersion

func ParseMonitorHttpVersion(pVersion string) *lPoolV2.CreateOptsHealthCheckHttpVersionOpt

func ParseMonitorProtocol

func ParseMonitorProtocol(
	pPoolProtocol corev1.Protocol, pMonitorProtocol string) lPoolV2.CreateOptsHealthCheckProtocolOpt

func ParsePoolAlgorithm

func ParsePoolAlgorithm(pOpt string) lPoolV2.CreateOptsAlgorithmOpt

func ParsePoolProtocol

func ParsePoolProtocol(pPoolProtocol string) lPoolV2.CreateOptsProtocolOpt

func ParseStringListAnnotation

func ParseStringListAnnotation(s, annotation string) []string

func ParseStringMapAnnotation

func ParseStringMapAnnotation(s, annotation string) map[string]string

func PatchService

func PatchService(ctx context.Context, client clientset.Interface, cur, mod *corev1.Service) error

PatchService makes patch request to the Service object.

func StringListToString

func StringListToString(s []string) string

func TrimString

func TrimString(str string, length int) string

func ValidateName

func ValidateName(newName string) string

Types

type CertificateExpander

type CertificateExpander struct {
	UUID       string
	Name       string
	Version    string
	SecretName string
}

type IngressInspect

type IngressInspect struct {
	DefaultPool *PoolExpander
	Name        string
	Namespace   string
	LbOptions   *loadbalancer.CreateOpts // create options for lb
	SubnetCIDR  string
	SubnetID    string // nodes may have different subnets, so we need to store the subnet id of LB
	NetworkID   string // nodes may have different subnets, so we need to store the subnet id of LB

	PolicyExpander       []*PolicyExpander
	PoolExpander         []*PoolExpander
	ListenerExpander     []*ListenerExpander
	InstanceIDs          []string
	SecGroupRuleExpander []*SecGroupRuleExpander
}

func (*IngressInspect) AddSecgroupRule

func (ing *IngressInspect) AddSecgroupRule(port int, protocol secgroup_rule.CreateOptsProtocolOpt)

func (*IngressInspect) Print

func (ing *IngressInspect) Print()

type ListenerExpander

type ListenerExpander struct {
	UUID            string
	DefaultPoolName string // use for L4 only
	listener.CreateOpts
}

type MyDuration

type MyDuration struct {
	time.Duration
}

type PolicyExpander

type PolicyExpander struct {
	IsInUse         bool
	IsHttpsListener bool
	ListenerID      string

	UUID             string
	Name             string
	RedirectPoolID   string
	RedirectPoolName string
	Action           policy.PolicyOptsActionOpt
	L7Rules          []policy.Rule
}

type PoolExpander

type PoolExpander struct {
	UUID string
	pool.CreateOpts
}

type ResourceDependant added in v0.2.9

type ResourceDependant interface {
	SetService(service *corev1.Service, isAddEndpoint bool)
	SetIngress(ingress *networkv1.Ingress, isAddEndpoint bool)

	GetServiceNeedReconcile(kind, namespace, resource string) []reconcile.Request
	GetIngressNeedReconcile(kind, namespace, resource string) []reconcile.Request

	ClearService(namespace, name string)
	ClearIngress(namespace, name string)
}

func NewResourceDependant added in v0.2.9

func NewResourceDependant() ResourceDependant

type SecGroupRuleExpander

type SecGroupRuleExpander struct {
	UUID string
	secgroup_rule.CreateOpts
}

type StringKeyLock

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

func NewStringKeyLock

func NewStringKeyLock() *StringKeyLock

func (*StringKeyLock) Lock

func (l *StringKeyLock) Lock(key string)

func (*StringKeyLock) Unlock

func (l *StringKeyLock) Unlock(key string)

type UpdateTracker

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

func NewUpdateTracker

func NewUpdateTracker() *UpdateTracker

func (*UpdateTracker) AddUpdateTracker

func (c *UpdateTracker) AddUpdateTracker(lbID, ingressName, updateAt string)

func (*UpdateTracker) GetReapplyIngress

func (c *UpdateTracker) GetReapplyIngress(lbs []*objects.LoadBalancer) []string

func (*UpdateTracker) RemoveUpdateTracker

func (c *UpdateTracker) RemoveUpdateTracker(lbID, ingressName string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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