utils

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 33 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 []*apiv1.Node, nodeLabels map[string]string) []*apiv1.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 *apiv1.Service, annotationKey string, defaultSetting int) int

func GetListProviderID

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

func GetNodeMembersAddr

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

func GetService

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

func GetServiceNodePort

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

func GetStringFromServiceAnnotation

func GetStringFromServiceAnnotation(pService *apiv1.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 apiv1.ServicePort, pPoolName string) bool

func ListNodeWithPredicate

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

func ListServiceWithPredicate

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

func ListWorkerNodes

func ListWorkerNodes(pNodes []*apiv1.Node, pOnlyReadyNode bool) []*apiv1.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 []*apiv1.Node) []string

NodeNames get all the node names.

func NodeSlicesEqual

func NodeSlicesEqual(x, y []*apiv1.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 apiv1.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 *apiv1.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

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