landb_sync

package
v0.0.0-...-b9059b1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(s []string, e string) bool

Contains will find if substring exists in []string

func DropStringFromSlice

func DropStringFromSlice(s string, ss []string) []string

DropStringFromSlice drops string (s) from a string slice (ss)

func ExtractHostnamesFromKubernetesIngresses

func ExtractHostnamesFromKubernetesIngresses(ingresses []networking.Ingress) (aliases []string)

ExtractHostnamesFromKubernetesIngresses will get a []string list with all the aliases defined by the ingress input

func ExtractUserDefinedAliasesFromNode

func ExtractUserDefinedAliasesFromNode(nodeCurrentAliases []string, clusterDefinedAliases []string) (userAliases []string)

ExtractUserDefinedAliasesFromNode will get all the user defined aliases from the node

func FilterMasterNodes

func FilterMasterNodes(nodesList []v1Type.Node) (filtered []v1Type.Node)

FilterMasterNodes will filter out all the master nodes from the slice

func FilterNodesByConditionTypeValue

func FilterNodesByConditionTypeValue(nodesList []v1Type.Node, key string, values []string) (filtered []v1Type.Node)

FilterNodesByConditionTypeValue will filter the specified []Node by the defined key:value Node.Condition. It will return a []Node with the corresponding Nodes filtered in this way

func GenerateFQDNAliasString

func GenerateFQDNAliasString(aliases []string, postfix string) string

GenerateFQDNAliasString will append and then concatenate the hostnames for landb commit

func GetKubernetesClientset

func GetKubernetesClientset() (*kubernetes.Clientset, error)

GetKubernetesClientset get kubernetes configuration and generates client handle

func RemoveDuplicatesFromSlice

func RemoveDuplicatesFromSlice(s []string) []string

RemoveDuplicatesFromSlice Deduplicates strings on a slice

func SetWebhookCABundle

func SetWebhookCABundle(webhookName string, clientset *kubernetes.Clientset, certPEM []byte) error

SetWebhookCABundle updates a validating webhook configuration, setting the client config CABundle with the contents of certPEM.

func ShuffleSlice

func ShuffleSlice(sliceP []v1Type.Node)

ShuffleSlice Shuffles the elements of the slice len(slice) number of times

Types

type BlockStorageOpts

type BlockStorageOpts struct {
	BSVersion             string `gcfg:"bs-version"`        // overrides autodetection. v1 or v2. Defaults to auto
	TrustDevicePath       bool   `gcfg:"trust-device-path"` // See Issue #33128
	IgnoreVolumeAZ        bool   `gcfg:"ignore-volume-az"`
	NodeVolumeAttachLimit int    `gcfg:"node-volume-attach-limit"` // override volume attach limit for Cinder. Default is : 256
}

BlockStorageOpts is used to talk to Cinder service

type Config

type Config struct {
	Global struct {
		AuthURL         string `gcfg:"auth-url"`
		Username        string
		UserID          string `gcfg:"user-id"`
		Password        string
		TenantID        string `gcfg:"tenant-id"`
		TenantName      string `gcfg:"tenant-name"`
		TrustID         string `gcfg:"trust-id"`
		DomainID        string `gcfg:"domain-id"`
		DomainName      string `gcfg:"domain-name"`
		Region          string
		CAFile          string `gcfg:"ca-file"`
		SecretName      string `gcfg:"secret-name"`
		SecretNamespace string `gcfg:"secret-namespace"`
		KubeconfigPath  string `gcfg:"kubeconfig-path"`
	}
	LoadBalancer LoadBalancerOpts
	BlockStorage BlockStorageOpts
	Route        RouterOpts
	Metadata     MetadataOpts
}

Config is used to read and store information from the cloud configuration file

type LandbSync

type LandbSync struct {
	// LandbAliasEnabled defines if landb-sync should manage registration of alias
	LandbAliasEnabled bool
	// LandbSetEnabled defines if landb-sync should manage registration of ingress nodes into the landb-set
	LandbSetEnabled bool
	// LandbSetName defines the name to be used for the landb-set when managing this property
	LandbSetName string
	// NumIngressNodes is the number of ingress instances to be kept active
	NumIngressNodes int
	// Allow ingress to be created if the existent landb-alias references self
	ServerBypassCernDNS bool
	// StateCheckPeriod is the interval between syncs
	StateCheckPeriod time.Duration
	// CloudConfig is the location of the openstack cloud config
	CloudConfig string
	// contains filtered or unexported fields
}

LandbSync stores the OS and Kubernetes conn handles and options

func (*LandbSync) AddLabelToNode

func (d *LandbSync) AddLabelToNode(node v1Type.Node, key string, value string) (err error)

AddLabelToNode will add the specified key:value to the Node.metadata.Labels

func (*LandbSync) DeleteLabelFromNode

func (d *LandbSync) DeleteLabelFromNode(node v1Type.Node, key string) (err error)

DeleteLabelFromNode will delete the specified key from Node.metadata.Labels

func (*LandbSync) DeleteOpenstackPropertyByNodeUUID

func (d *LandbSync) DeleteOpenstackPropertyByNodeUUID(property string, nodeUUID string) (err error)

DeleteOpenstackPropertyByNodeUUID will delete the property from the node metadata using node uuid

func (*LandbSync) DismissIngressNode

func (d *LandbSync) DismissIngressNode(node v1Type.Node) (err error)

DismissIngressNode will delete label role=ingress and landb-alias property from node

func (*LandbSync) DropUnhealthyNodesFromIngressRole

func (d *LandbSync) DropUnhealthyNodesFromIngressRole(cluster *stateData)

DropUnhealthyNodesFromIngressRole will remove all not healthy nodes from role ingress

func (*LandbSync) GetOpenstackPropertyByNodeUUID

func (d *LandbSync) GetOpenstackPropertyByNodeUUID(property string, nodesUUID []string) (serversMetadatum []map[string]string, err error)

GetOpenstackPropertyByNodeUUID will get OS data from the nodesUUID list and return a Metadatum object list in the same order

func (*LandbSync) Init

func (d *LandbSync) Init()

Init sets all the required clients to talk to openstack

func (*LandbSync) RegisterIngressWatcher

func (d *LandbSync) RegisterIngressWatcher(stop <-chan int)

RegisterIngressWatcher will create the Ingress Watcher and map the functions the triggers of the Create/Update/Delete operations

func (*LandbSync) SetOpenstackPropertyByNodeUUID

func (d *LandbSync) SetOpenstackPropertyByNodeUUID(cluster *stateData, property string, value string, nodeUUID string) (err error)

SetOpenstackPropertyByNodeUUID sets the metadata property:value on the server uuid

func (*LandbSync) UpdateIngressAlias

func (d *LandbSync) UpdateIngressAlias(cluster *stateData) (err error)

UpdateIngressAlias will manage the attribution of the kubernetes cluster defined ingresses to the available Ingress Nodes.

func (*LandbSync) UpdateIngressAliasFromList

func (d *LandbSync) UpdateIngressAliasFromList(cluster *stateData, kubernetesAliases []string, kubernetesDeletedAliases []string) (err error)

UpdateIngressAliasFromList will manage the attribution of the kubernetes cluster defined ingresses to the available Ingress Nodes.

func (*LandbSync) UpdateIngressNodes

func (d *LandbSync) UpdateIngressNodes(cluster *stateData) (err error)

UpdateIngressNodes will add or remove Ingress Nodes to meet the desired capacity

func (*LandbSync) UpdateNodesLandbSet

func (d *LandbSync) UpdateNodesLandbSet(cluster *stateData, setAllNodes bool) (err error)

UpdateNodesLandbSet will update the landb-set of all the cluster nodes

func (*LandbSync) UpdateStateMachine

func (d *LandbSync) UpdateStateMachine() (err error)

UpdateStateMachine refreshes the state machine

type LoadBalancer

type LoadBalancer struct {
}

LoadBalancer is used for creating and maintaining load balancers

type LoadBalancerOpts

type LoadBalancerOpts struct {
	LBVersion            string     `gcfg:"lb-version"`          // overrides autodetection. Only support v2.
	UseOctavia           bool       `gcfg:"use-octavia"`         // uses Octavia V2 service catalog endpoint
	SubnetID             string     `gcfg:"subnet-id"`           // overrides autodetection.
	FloatingNetworkID    string     `gcfg:"floating-network-id"` // If specified, will create floating ip for loadbalancer, or do not create floating ip.
	LBMethod             string     `gcfg:"lb-method"`           // default to ROUND_ROBIN.
	LBProvider           string     `gcfg:"lb-provider"`
	CreateMonitor        bool       `gcfg:"create-monitor"`
	MonitorDelay         MyDuration `gcfg:"monitor-delay"`
	MonitorTimeout       MyDuration `gcfg:"monitor-timeout"`
	MonitorMaxRetries    uint       `gcfg:"monitor-max-retries"`
	ManageSecurityGroups bool       `gcfg:"manage-security-groups"`
	NodeSecurityGroupIDs []string   // Do not specify, get it automatically when enable manage-security-groups. TODO(FengyunPan): move it into cache
}

LoadBalancerOpts have the options to talk to Neutron LBaaSV2 or Octavia

type MetadataOpts

type MetadataOpts struct {
	SearchOrder    string     `gcfg:"search-order"`
	RequestTimeout MyDuration `gcfg:"request-timeout"`
}

MetadataOpts is used for configuring how to talk to metadata service or config drive

type MyDuration

type MyDuration struct {
	time.Duration
}

MyDuration is the encoding.TextUnmarshaler interface for time.Duration

func (*MyDuration) UnmarshalText

func (d *MyDuration) UnmarshalText(text []byte) error

UnmarshalText is used to convert from text to Duration

type NodesL

type NodesL []v1Type.Node

NodesL is a slice of Nodes

func (NodesL) Len

func (s NodesL) Len() int

func (NodesL) Less

func (s NodesL) Less(i, j int) bool

func (NodesL) Swap

func (s NodesL) Swap(i, j int)

type RouterOpts

type RouterOpts struct {
	RouterID string `gcfg:"router-id"` // required
}

RouterOpts is used for Neutron routes

type WebhookServer

type WebhookServer struct {
	Server    *http.Server
	LandbSync LandbSync
}

WebhookServer is the server object where handles are registered into

func (*WebhookServer) Serve

func (whsvr *WebhookServer) Serve(w http.ResponseWriter, r *http.Request)

Serve method for webhook server

Jump to

Keyboard shortcuts

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