Documentation
¶
Index ¶
- Variables
- func ConfigFiles(cfgdir string) (configs map[string]string, err error)
- func ConvertHostAliasesToPlainMap(hostAliases []HostAlias) map[string][]netip.Addr
- func MetricsProvider(subsystem string) func() Metrics
- func NewSharedServicesObserver(log *slog.Logger, cache *GlobalServiceCache, ...) store.Observer
- type CiliumEtcdConfig
- type ClusterMesh
- type Config
- type Configuration
- type GlobalService
- type GlobalServiceCache
- func (c *GlobalServiceCache) GetGlobalService(serviceNN types.NamespacedName) *GlobalService
- func (c *GlobalServiceCache) GetService(serviceNN types.NamespacedName, clusterName string) *serviceStore.ClusterService
- func (c *GlobalServiceCache) Has(svc *serviceStore.ClusterService) bool
- func (c *GlobalServiceCache) OnDelete(svc *serviceStore.ClusterService) bool
- func (c *GlobalServiceCache) OnUpdate(svc *serviceStore.ClusterService)
- func (c *GlobalServiceCache) Size() (num int)
- type HostAlias
- type Metrics
- type RemoteClientFactoryFn
- type RemoteCluster
- type RemoteClusterCreatorFunc
- type StatusFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrClusterIDChanged = errors.New("etcd cluster ID has changed") ErrEtcdInvalidResponse = errors.New("received an invalid etcd response") )
var DefaultConfig = Config{
ClusterMeshConfig: "",
ClusterMeshCacheTTL: 0,
}
Functions ¶
func ConfigFiles ¶ added in v1.15.6
ConfigFiles returns the list of configuration files in the given path. It shall be used by CLI tools only, as it doesn't handle subsequent updates.
func ConvertHostAliasesToPlainMap ¶ added in v1.20.0
func MetricsProvider ¶
func NewSharedServicesObserver ¶ added in v1.16.0
func NewSharedServicesObserver( log *slog.Logger, cache *GlobalServiceCache, onUpdate, onDelete func(*serviceStore.ClusterService), ) store.Observer
NewSharedServicesObserver returns an observer implementing the logic to convert and filter shared services notifications, update the global service cache and call the upstream handlers when appropriate.
Types ¶
type CiliumEtcdConfig ¶ added in v1.20.0
type CiliumEtcdConfig struct {
HostAliases []HostAlias `json:"cilium-host-aliases" yaml:"cilium-host-aliases"`
}
CiliumEtcdConfig represents Cilium extensions to the etcd client config. These fields are ignored by etcd but we are conveniently embedding those in the etcd client config so that our config watcher can help retriggering the connection if this change too.
func ParseCiliumConfig ¶ added in v1.20.0
func ParseCiliumConfig(path string) (CiliumEtcdConfig, error)
ParseCiliumConfig reads Cilium specific fields from the etcd client config.
type ClusterMesh ¶
type ClusterMesh interface {
cell.HookInterface
// ForEachRemoteCluster calls the provided function for each remote cluster
// in the ClusterMesh.
ForEachRemoteCluster(fn func(RemoteCluster) error) error
// NumReadyClusters returns the number of remote clusters to which a connection
// has been established
NumReadyClusters() int
}
func NewClusterMesh ¶
func NewClusterMesh(c Configuration) ClusterMesh
NewClusterMesh creates a new remote cluster cache based on the provided configuration
type Config ¶
type Config struct {
// ClusterMeshConfig is the path to the clustermesh configuration directory.
ClusterMeshConfig string
// ClusterMeshCacheTTL is the time to live for the cache of a remote cluster after connectivity
// is lost. If the connection is not re-established within this duration, the cached data is
// revoked to prevent stale state. If not specified or set to 0s, the cache is never revoked.
ClusterMeshCacheTTL time.Duration
}
type Configuration ¶
type Configuration struct {
Logger *slog.Logger
Config
// ClusterInfo is the id/name of the local cluster.
ClusterInfo types.ClusterInfo
// RemoteClientFactory is the factory to create new backend instances.
RemoteClientFactory RemoteClientFactoryFn
// NewRemoteCluster is a function returning a new implementation of the remote cluster business logic.
NewRemoteCluster RemoteClusterCreatorFunc
// ClusterSizeDependantInterval allows to calculate intervals based on cluster size.
ClusterSizeDependantInterval kvstore.ClusterSizeDependantIntervalFunc
// Resolvers, if provided, are used to create a custom dialer to connect to etcd.
Resolvers []dial.Resolver
// Metrics holds the different clustermesh metrics.
Metrics Metrics
}
Configuration is the configuration that must be provided to NewClusterMesh()
type GlobalService ¶ added in v1.16.0
type GlobalService struct {
ClusterServices map[string]*serviceStore.ClusterService
}
type GlobalServiceCache ¶ added in v1.16.0
type GlobalServiceCache struct {
// contains filtered or unexported fields
}
func NewGlobalServiceCache ¶ added in v1.16.0
func NewGlobalServiceCache(logger *slog.Logger) *GlobalServiceCache
func (*GlobalServiceCache) GetGlobalService ¶ added in v1.16.0
func (c *GlobalServiceCache) GetGlobalService(serviceNN types.NamespacedName) *GlobalService
GetGlobalService returns a global service object. This function returns a shallow copy of the GlobalService object, thus the ClusterService objects should not be mutated.
func (*GlobalServiceCache) GetService ¶ added in v1.16.0
func (c *GlobalServiceCache) GetService(serviceNN types.NamespacedName, clusterName string) *serviceStore.ClusterService
GetService returns the service for a specific cluster. This function does not make a copy of the cluster service object and should not be mutated.
func (*GlobalServiceCache) Has ¶ added in v1.16.0
func (c *GlobalServiceCache) Has(svc *serviceStore.ClusterService) bool
Has returns whether a given service is present in the cache.
func (*GlobalServiceCache) OnDelete ¶ added in v1.16.0
func (c *GlobalServiceCache) OnDelete(svc *serviceStore.ClusterService) bool
func (*GlobalServiceCache) OnUpdate ¶ added in v1.16.0
func (c *GlobalServiceCache) OnUpdate(svc *serviceStore.ClusterService)
func (*GlobalServiceCache) Size ¶ added in v1.16.0
func (c *GlobalServiceCache) Size() (num int)
Size returns the number of global services in the cache
type Metrics ¶
type Metrics struct {
// TotalRemoteClusters tracks the total number of remote clusters.
TotalRemoteClusters 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]
// TotalCacheRevocations tracks the number of cache revocations for a remote cluster.
TotalCacheRevocations metric.Vec[metric.Gauge]
}
type RemoteClientFactoryFn ¶ added in v1.18.0
type RemoteClientFactoryFn func(ctx context.Context, logger *slog.Logger, cfgpath string, extra kvstore.ExtraOptions) (kvstore.BackendOperations, chan error)
RemoteClientFactoryFn is the type of the function to create the etcd client for clustermesh.
func DefaultRemoteClientFactory ¶ added in v1.18.0
func DefaultRemoteClientFactory(cfg kvstore.Config) RemoteClientFactoryFn
DefaultRemoteClientFactory returns the default RemoteClientFactoryFn, configured with the parameters from the global kvstore configuration.
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)
Stop()
Remove(ctx context.Context)
RevokeCache(ctx context.Context)
}
type RemoteClusterCreatorFunc ¶
type RemoteClusterCreatorFunc func(name string, status StatusFunc) RemoteCluster
type StatusFunc ¶
type StatusFunc func() *models.RemoteCluster