controller

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_PORTAL_NAME_LENGTH = 50
	ACTIVE_LOADBALANCER_STATUS = "ACTIVE"
)
View Source
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
	DeleteEvent EventType = "DELETE"

	// IngressKey picks a specific "class" for the Ingress.
	// The controller only processes Ingresses with this annotation either
	// unset, or set to either the configured value or the empty string.
	IngressKey = "kubernetes.io/ingress.class"

	// IngressClass specifies which Ingress class we accept
	IngressClass = "vngcloud"

	// LabelNodeExcludeLB specifies that a node should not be used to create a Loadbalancer on
	// https://github.com/kubernetes/cloud-provider/blob/25867882d509131a6fdeaf812ceebfd0f19015dd/controllers/service/controller.go#L673
	LabelNodeExcludeLB = "node.kubernetes.io/exclude-from-external-load-balancers"

	// DeprecatedLabelNodeRoleMaster specifies that a node is a master
	// It's copied over to kubeadm until it's merged in core: https://github.com/kubernetes/kubernetes/pull/39112
	// Deprecated in favor of LabelNodeExcludeLB
	DeprecatedLabelNodeRoleMaster = "node-role.kubernetes.io/master"

	// IngressSecretCertName is certificate key name defined in the secret data.
	IngressSecretCertName = "tls.crt"
	// IngressSecretKeyName is private key name defined in the secret data.
	IngressSecretKeyName = "tls.key"
)
View Source
const (
	ServiceAnnotationLoadBalancerID = "vks.vngcloud.vn/load-balancer-id"
	ServiceAnnotationPackageID      = "vks.vngcloud.vn/package-id"
)

Variables

This section is empty.

Functions

func CheckIfPoolMemberExist

func CheckIfPoolMemberExist(mems []*pool.Member, mem *pool.Member) bool

func CheckIfPoolMemberExist2

func CheckIfPoolMemberExist2(mems []*lObjects.Member, mem *pool.Member) bool

func ComparePoolMembers

func ComparePoolMembers(p1, p2 []*pool.Member) bool

func ConvertObjectToPoolMember

func ConvertObjectToPoolMember(obj *lObjects.Member) *pool.Member

func ConvertObjectToPoolMemberArray

func ConvertObjectToPoolMemberArray(obj []*lObjects.Member) []*pool.Member

func DecodeFromValidName

func DecodeFromValidName(str string) string

func EncodeToValidName

func EncodeToValidName(str string) string

func GetCertificateName

func GetCertificateName(clusterID, namespace, name string) string

func GetPolicyName

func GetPolicyName(prefix string, mode bool, ruleIndex, pathIndex int) string

func GetPoolName

func GetPoolName(prefix, serviceName string, port int) string

func GetResourceHashName

func GetResourceHashName(ing *nwv1.Ingress, clusterID string) string

func GetResourceName

func GetResourceName(ing *nwv1.Ingress, clusterID string) string

GetResourceName get Ingress related resource name.

func HashString

func HashString(str string) string

hash a string to a string have 10 char

func IsLoadBalancerNotReady

func IsLoadBalancerNotReady(err error) bool

func IsValid

func IsValid(ing *nwv1.Ingress) bool

IsValid returns true if the given Ingress either doesn't specify the ingress.class annotation, or it's set to the configured in the ingress controller.

func MapIDExpander

func MapIDExpander(old, cur *IngressInspect)

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 Sleep

func Sleep(t int)

func TrimString

func TrimString(str string, length int) string

Types

type API

type API struct {
	VLBSC     *client.ServiceClient
	VServerSC *client.ServiceClient
	ProjectID string
}

func (*API) CreateLB

func (c *API) CreateLB(name, packageId, subnetID string,
	scheme loadbalancer.CreateOptsSchemeOpt,
	typeLB loadbalancer.CreateOptsTypeOpt,
) (*lObjects.LoadBalancer, error)

func (*API) CreateListener

func (c *API) CreateListener(lbID string, opt *listener.CreateOpts) (*lObjects.Listener, error)

LISTENER

func (*API) CreatePolicy

func (c *API) CreatePolicy(lbID, listenerID string, opt *policy.CreateOptsBuilder) (*lObjects.Policy, error)

POLICY

func (*API) CreatePool

func (c *API) CreatePool(lbID string, opt *pool.CreateOpts) (*lObjects.Pool, error)

POOL

func (*API) DeleteCertificate

func (c *API) DeleteCertificate(certificateID string) error

func (*API) DeleteLB

func (c *API) DeleteLB(lbID string) error

func (*API) DeleteListener

func (c *API) DeleteListener(lbID, listenerID string) error

func (*API) DeletePolicy

func (c *API) DeletePolicy(lbID, listenerID, policyID string) error

func (*API) DeletePool

func (c *API) DeletePool(lbID, poolID string) error

func (*API) FindListenerByName

func (c *API) FindListenerByName(lbID, name string) (*lObjects.Listener, error)

func (*API) FindListenerByPort

func (c *API) FindListenerByPort(lbID string, port int) (*lObjects.Listener, error)

func (*API) FindPolicyByName

func (c *API) FindPolicyByName(lbID, listenerID, name string) (*lObjects.Policy, error)

func (*API) FindPoolByName

func (c *API) FindPoolByName(lbID, name string) (*lObjects.Pool, error)

func (*API) GetCertificate

func (c *API) GetCertificate(certificateID string) (*lObjects.Certificate, error)

func (*API) GetClusterInfo

func (c *API) GetClusterInfo(clusterID string) (*lObjects.Cluster, error)

COMMON

func (*API) GetLB

func (c *API) GetLB(lbID string) (*lObjects.LoadBalancer, error)

func (*API) GetMemberPool

func (c *API) GetMemberPool(lbID, poolID string) ([]*lObjects.Member, error)

func (*API) GetPolicy

func (c *API) GetPolicy(lbID, listenerID, policyID string) (*lObjects.Policy, error)

func (*API) GetPool

func (c *API) GetPool(lbID, poolID string) (*lObjects.Pool, error)

func (*API) ImportCertificate

func (c *API) ImportCertificate(opt *certificates.ImportOpts) (*lObjects.Certificate, error)

CERTIFICATE

func (*API) ListCertificate

func (c *API) ListCertificate() ([]*lObjects.Certificate, error)

func (*API) ListLBBySubnetID

func (c *API) ListLBBySubnetID(subnetID string) ([]*lObjects.LoadBalancer, error)

LB

func (*API) ListListenerOfLB

func (c *API) ListListenerOfLB(lbID string) ([]*lObjects.Listener, error)

func (*API) ListPolicyOfListener

func (c *API) ListPolicyOfListener(lbID, listenerID string) ([]*lObjects.Policy, error)

func (*API) ListPoolOfLB

func (c *API) ListPoolOfLB(lbID string) ([]*lObjects.Pool, error)

func (*API) UpdateListener

func (c *API) UpdateListener(lbID, listenerID string, opt *listener.UpdateOpts) error

func (*API) UpdatePolicy

func (c *API) UpdatePolicy(lbID, listenerID, policyID string, opt *policy.UpdateOptsBuilder) error

func (*API) UpdatePoolMember

func (c *API) UpdatePoolMember(lbID, poolID string, mems []*pool.Member) error

func (*API) WaitForLBActive

func (c *API) WaitForLBActive(lbID string) *lObjects.LoadBalancer

type CertificateExpander

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

type Config

type Config struct {
	Global   client.AuthOpts
	VLB      VLBOpts
	Metadata metadata.Opts
}

type Controller

type Controller struct {
	SecretTrackers *SecretTracker
	// contains filtered or unexported fields
}

Controller ...

func NewController

func NewController(conf config.Config) *Controller

NewController creates a new VngCloud Ingress controller.

func (*Controller) DeleteLoadbalancer

func (c *Controller) DeleteLoadbalancer(ing *nwv1.Ingress) error

func (*Controller) GetLoadbalancerIDByIngress

func (c *Controller) GetLoadbalancerIDByIngress(ing *nwv1.Ingress) (string, error)

func (*Controller) Init

func (c *Controller) Init() error

func (*Controller) Start

func (c *Controller) Start()

Start starts the vngcloud ingress controller.

type ErrorRespone

type ErrorRespone struct {
	Message    string `json:"message"`
	ErrorCode  string `json:"errorCode"`
	StatusCode int    `json:"statusCode"`
}

func ParseError

func ParseError(errStr string) *ErrorRespone

type Event

type Event struct {
	Type EventType
	Obj  interface{}
	// contains filtered or unexported fields
}

Event holds the context of an event

type EventType

type EventType string

EventType type of event associated with an informer

type ExtraInfo

type ExtraInfo struct {
	ProjectID string
	UserID    int64
}

type IngressInspect

type IngressInspect struct {
	PolicyExpander      []*PolicyExpander
	PoolExpander        []*PoolExpander
	ListenerExpander    []*ListenerExpander
	CertificateExpander []*CertificateExpander
	// contains filtered or unexported fields
}

func (*IngressInspect) Print

func (ing *IngressInspect) Print()

type ListenerExpander

type ListenerExpander struct {
	UUID string
	listener.CreateOpts
}

type NodeConditionPredicate

type NodeConditionPredicate func(node *apiv1.Node) bool

type PolicyExpander

type PolicyExpander struct {
	UUID             string
	Name             string
	RedirectPoolID   string
	RedirectPoolName string
	Action           policy.PolicyOptsActionOpt
	L7Rules          []policy.Rule
	// contains filtered or unexported fields
}

type PoolExpander

type PoolExpander struct {
	Name string
	UUID string
	// Members []lObjects.Member
	Members []*pool.Member
}

type SecretTracker

type SecretTracker struct {
	SecretTrackers []*secret
}

func NewSecretTracker

func NewSecretTracker() *SecretTracker

func (*SecretTracker) AddSecretTracker

func (c *SecretTracker) AddSecretTracker(namespace, name, uuid, version string)

func (*SecretTracker) CheckSecretTrackerChange

func (c *SecretTracker) CheckSecretTrackerChange(kubeClient kubernetes.Interface) bool

func (*SecretTracker) ClearSecretTracker

func (c *SecretTracker) ClearSecretTracker()

func (*SecretTracker) RemoveSecretTracker

func (c *SecretTracker) RemoveSecretTracker(namespace, name string)

type VLBOpts

type VLBOpts struct {
	Enabled        bool   `gcfg:"enabled"`         // if false, disables the controller
	InternalLB     bool   `gcfg:"internal-lb"`     // default false
	FlavorID       string `gcfg:"flavor-id"`       // flavor id of load balancer
	MaxSharedLB    int    `gcfg:"max-shared-lb"`   //  Number of Services in maximum can share a single load balancer. Default 2
	LBMethod       string `gcfg:"lb-method"`       // default to ROUND_ROBIN.
	EnableVMonitor bool   `gcfg:"enable-vmonitor"` // default to false
}

Jump to

Keyboard shortcuts

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