common

package
v1.15.5 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClusterIDChanged    = errors.New("etcd cluster ID has changed")
	ErrEtcdInvalidResponse = errors.New("received an invalid etcd response")
)

Functions

func MetricsProvider

func MetricsProvider(subsystem string) func() Metrics

Types

type ClusterMesh

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

ClusterMesh is a cache of multiple remote clusters

func NewClusterMesh

func NewClusterMesh(c Configuration) ClusterMesh

NewClusterMesh creates a new remote cluster cache based on the provided configuration

func (*ClusterMesh) ForEachRemoteCluster

func (cm *ClusterMesh) ForEachRemoteCluster(fn func(RemoteCluster) error) error

func (*ClusterMesh) NumReadyClusters

func (cm *ClusterMesh) NumReadyClusters() int

NumReadyClusters returns the number of remote clusters to which a connection has been established

func (*ClusterMesh) Start

func (cm *ClusterMesh) Start(cell.HookContext) error

func (*ClusterMesh) Stop

func (cm *ClusterMesh) Stop(cell.HookContext) error

Close stops watching for remote cluster configuration files to appear and will close all connections to remote clusters

type Config

type Config struct {
	// ClusterMeshConfig is the path to the clustermesh configuration directory.
	ClusterMeshConfig string
}

func (Config) Flags

func (def Config) Flags(flags *pflag.FlagSet)

type Configuration

type Configuration struct {
	Config

	// ClusterInfo is the id/name of the local cluster. This is used for logging and metrics
	ClusterInfo types.ClusterInfo

	// NewRemoteCluster is a function returning a new implementation of the remote cluster business logic.
	NewRemoteCluster RemoteClusterCreatorFunc

	// nodeName is the name of the local node. This is used for logging and metrics
	NodeName string

	// ClusterSizeDependantInterval allows to calculate intervals based on cluster size.
	ClusterSizeDependantInterval kvstore.ClusterSizeDependantIntervalFunc

	// ServiceIPGetter, if not nil, is used to create a custom dialer for service resolution.
	ServiceIPGetter k8s.ServiceIPGetter

	// Metrics holds the different clustermesh metrics.
	Metrics Metrics
}

Configuration is the configuration that must be provided to NewClusterMesh()

type Metrics

type Metrics struct {
	// TotalRemoteClusters tracks the total number of remote clusters.
	TotalRemoteClusters metric.Vec[metric.Gauge]
	// LastFailureTimestamp tracks the last failure timestamp.
	LastFailureTimestamp metric.Vec[metric.Gauge]
	// ReadinessStatus tracks the readiness status of remote clusters.
	ReadinessStatus metric.Vec[metric.Gauge]
	// TotalFailure tracks the number of failures when connecting to remote clusters.
	TotalFailures metric.Vec[metric.Gauge]
}

type RemoteCluster

type RemoteCluster interface {
	// Run implements the actual business logic once the connection to the remote cluster has been established.
	// The ready channel shall be closed when the initialization tasks completed, possibly returning an error.
	Run(ctx context.Context, backend kvstore.BackendOperations, config *types.CiliumClusterConfig, ready chan<- error)

	// ClusterConfigRequired returns whether the CiliumClusterConfig is always
	// expected to be exposed by remote clusters.
	ClusterConfigRequired() bool

	Stop()
	Remove()
}

type RemoteClusterCreatorFunc

type RemoteClusterCreatorFunc func(name string, status StatusFunc) RemoteCluster

type StatusFunc

type StatusFunc func() *models.RemoteCluster

Jump to

Keyboard shortcuts

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