client

package
v0.0.0-...-c4606bf Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

package client contains the data types and functions Liqo Agent exploits to perform cluster operations.

Index

Constants

View Source
const (
	//EnvLiqoKConfig defines the env var containing the path of the kubeconfig file of the
	//cluster associated to Liqo Agent.
	EnvLiqoKConfig = "LIQO_KCONFIG"
	//EnvLiqoPath defines the env var containing the path of the root directory of the Liqo Agent on the local file system.
	EnvLiqoPath = "LIQO_PATH"
)
View Source
const (

	//EnvLiqoDashHost defines the env var for the HOST part of the LiqoDash address.
	EnvLiqoDashHost = "LIQODASH_HOST"
	//EnvLiqoDashPort defines the env var for the PORT part of the LiqoDash address.
	EnvLiqoDashPort = "LIQODASH_PORT"
)
View Source
const ConfigFileName = "agent_conf.yaml"

ConfigFileName is the basename of the Agent configuration file.

Variables

This section is empty.

Functions

func DestroyMockedAgentController

func DestroyMockedAgentController()

DestroyMockedAgentController destroys the AgentController singleton for testing purposes. It works only after calling UseMockedAgentController().

func LoadLocalConfig

func LoadLocalConfig()

LoadLocalConfig loads configuration data from a config file ConfigFileName on the local filesystem (if present and valid). The config file structure is mapped on the LocalConfig type.

func SaveLocalConfig

func SaveLocalConfig() error

SaveLocalConfig saves the configuration data in the internal LocalConfiguration to a config file on the local file system named after ConfigFileName.

func UseMockedAgentController

func UseMockedAgentController()

UseMockedAgentController enables a mocked AgentController that does not interacts with the kubernetes cluster.

Function MUST be called before GetAgentController in order to be effective.

Types

type AgentController

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

AgentController is the data structure that manages Tray Agent interaction with the cluster.

func GetAgentController

func GetAgentController() *AgentController

GetAgentController returns an initialized AgentController singleton.

func (*AgentController) AcquireDashboardConfig

func (ctrl *AgentController) AcquireDashboardConfig() error

AcquireDashboardConfig tries to retrieve required data to access the LiqoDash service.

If a valid configuration is found, the EnvLiqoDashHost and EnvLiqoDashPort env vars are set.

func (*AgentController) Connected

func (ctrl *AgentController) Connected() bool

Connected returns if the Controller client is actually connected to the cluster.

func (*AgentController) ConnectionTest

func (ctrl *AgentController) ConnectionTest() bool

ConnectionTest checks the validity of the provided kubernetes configuration via kubeconfig file by trying to establish a connection to the API server.

func (AgentController) Controller

func (m AgentController) Controller(resource CustomResource) *CRDController

Controller returns (if present) the CRDController for a specific CRD.

func (*AgentController) GetLiqoDashSecret

func (ctrl *AgentController) GetLiqoDashSecret() (*string, error)

GetLiqoDashSecret returns the access token for the LiqoDash service.

func (*AgentController) Mocked

func (ctrl *AgentController) Mocked() bool

Mocked returns if the AgentController is mocked (true).

func (*AgentController) NotifyChannel

func (ctrl *AgentController) NotifyChannel(channelType NotifyChannel) chan NotifyDataGeneric

NotifyChannel returns the NotifyChannel of type 'channelType'.

func (*AgentController) StartCaches

func (ctrl *AgentController) StartCaches() error

StartCaches starts each available AgentController cache.

func (*AgentController) StartStopOutPeering

func (ctrl *AgentController) StartStopOutPeering(foreignCluster string, start bool) error

StartStopOutPeering interacts with a ForeignCluster to trigger the procedure to establish a peering towards a peer (start = true) or to stop it if already active.

func (*AgentController) StopCaches

func (ctrl *AgentController) StopCaches()

StopCaches stops all the CR caches running for the AgentController.

func (*AgentController) ValidConfiguration

func (ctrl *AgentController) ValidConfiguration() bool

ValidConfiguration returns whether AgentController configuration data have been correctly initialized.

type CRDController

type CRDController struct {
	//CRDClient to perform CRUD operations on the CRD.
	*crdClient.CRDClient
	// contains filtered or unexported fields
}

CRDController handles the Agent interaction with the cluster for a specific CRD.

func (*CRDController) Running

func (c *CRDController) Running() bool

Running returns whether the controller cache is running.

func (*CRDController) StartCache

func (c *CRDController) StartCache() error

StartCache starts the CRD cache and the sending of signals on the Controller notifyChannels.

func (*CRDController) StopCache

func (c *CRDController) StopCache()

StopCache stops (if running) the cache associated for the CRD.

type CustomResource

type CustomResource string

CustomResource defines the CRD managed by Liqo Agent.

const (
	//CRClusterConfig is the resource id for the ClusterConfig CRD.
	CRClusterConfig CustomResource = "clusterconfigs"
	//CRAdvertisement is the resource id for the Advertisement CRD.
	CRAdvertisement CustomResource = "advertisements"
	//CRForeignCluster is the resource id for the ForeignCluster CRD.
	CRForeignCluster CustomResource = "foreignclusters"
)

type LocalConfig

type LocalConfig struct {
	//Kubeconfig contains the path of the kubeconfig file.
	Kubeconfig string `yaml:"kubeconfig,omitempty"`
}

LocalConfig maps the information of a Liqo Agent configuration file, containing persistent settings data.

type LocalConfiguration

type LocalConfiguration struct {
	//Content maps the content of the config file.
	Content *LocalConfig
	//Valid specifies whether LocalConfiguration contains a valid Content to read.
	Valid bool
	sync.RWMutex
}

LocalConfiguration stores the LocalConfig configuration acquired from a local config file and a validity flag.

func GetLocalConfig

func GetLocalConfig() (config *LocalConfiguration, valid bool)

GetLocalConfig returns configuration data acquired from a config file on the local file system.

func NewLocalConfig

func NewLocalConfig() *LocalConfiguration

NewLocalConfig clears Agent internal copy of the ConfigFileName config file.

func (*LocalConfiguration) GetKubeconfig

func (lc *LocalConfiguration) GetKubeconfig() string

GetKubeconfig returns the 'kubeconfig' field for the local configuration.

func (*LocalConfiguration) SetKubeconfig

func (lc *LocalConfiguration) SetKubeconfig(path string)

SetKubeconfig sets the 'kubeconfig' field for the local configuration. Use SaveLocalConfig to write the updated configuration to the ConfigFileName file.

type NotifyChannel

type NotifyChannel int

NotifyChannel identifies a notification channel for a specific event.

const (
	//Notification channel id for an update of an available peer.
	ChanPeerAddedOrUpdated NotifyChannel = iota
	//Notification channel id for the removal of an available peer.
	ChanPeerDeleted
	//ChanClusterName os the NotifyChannel used to transmit the current ClusterName of the Liqo cluster the Agent is
	//connected to.
	ChanClusterName
)

NotifyChannel identifiers.

type NotifyDataForeignCluster

type NotifyDataForeignCluster struct {
	//Name of the ForeignCluster CR (to enable further its further retrieval).
	Name        string
	ClusterID   string
	ClusterName string
	//LocalDiscovered identifies whether the peer has been discovered inside the home cluster LAN.
	LocalDiscovered bool
	//Trusted identifies whether the ForeignCluster has a valid certificate.
	Trusted discovery2.TrustMode
	//AuthStatus determines if the home cluster has been correctly authenticated on the foreign cluster.
	//This property determines the possibility to perform an outgoing peering.
	AuthStatus discovery2.AuthStatus
	//OutPeering contains information about the current status of the outgoing peering towards this foreign cluster.
	OutPeering struct {
		//Connected  determines whether the outgoing peering is established and running.
		Connected bool
		//CpuQuota is the literal representation of the CPU quota shared by the foreign cluster in the currently
		//active outgoing peering.
		CpuQuota string
		//MemQuota is the literal representation of the CPU quota shared by the foreign cluster in the currently
		//active outgoing peering.
		MemQuota string
	}
	//InPeering contains information about the current status of the incoming peering from this foreign cluster.
	InPeering struct {
		//Connected determines whether the incoming peering is established and running.
		Connected bool
	}
}

NotifyDataForeignCluster is a NotifyDataGeneric sub-type used to exchange data concerning ForeignClusters events.

type NotifyDataGeneric

type NotifyDataGeneric interface{}

NotifyChan is the wrapper type for generic data sent over a NotifyChannel. After receiving such element from a chan, it is then possible to try its conversion into a specific type.

Jump to

Keyboard shortcuts

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