discovery

package
v0.6.40 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServiceMeshResourcePriorityIstio ServiceMeshResourcePriority = iota
	ServiceMeshResourcePriorityCilium
	ServiceMeshResourcePriorityLinkerd
	ServiceMeshResourcePriorityNone = 255

	ServiceMeshUpdateTypeAdded   ServiceMeshUpdateType = 0
	ServiceMeshUpdateTypeDeleted ServiceMeshUpdateType = 1

	// ServiceMeshResourceGroupIstio is a base group name used by Istio
	// Ref: https://github.com/istio/istio/blob/6186a80cb220ecbd7e1cc82044fe3a6fc2876c63/operator/pkg/apis/register.go#L27-L31
	ServiceMeshResourceGroupIstio ServiceMeshResourceGroup = "istio.io"

	// ServiceMeshResourceGroupCilium is a base group name used by Cilium
	// Ref: https://github.com/cilium/cilium/blob/99b4bc0d0b628f22c024f3ea74ef21007a831f52/pkg/k8s/apis/cilium.io/register.go#L7-L8
	ServiceMeshResourceGroupCilium ServiceMeshResourceGroup = "cilium.io"

	// ServiceMeshResourceGroupLinkerd is a base group name used by Linkerd
	// Ref: https://github.com/linkerd/linkerd2/blob/e055c32f31ae7618281fed1eb5c304b0d1389a52/controller/gen/apis/serviceprofile/register.go#L3-L4
	ServiceMeshResourceGroupLinkerd ServiceMeshResourceGroup = "linkerd.io"

	// ServiceMeshResourceGroupNone represents an empty or unknown service mesh
	ServiceMeshResourceGroupNone ServiceMeshResourceGroup = ""
)

Variables

This section is empty.

Functions

func InitGlobalDiscoveryCache

func InitGlobalDiscoveryCache(client discovery.DiscoveryInterface, mapper meta.RESTMapper, option ...CacheOption)

func IsEBPFDaemonSet

func IsEBPFDaemonSet(ds appsv1.DaemonSet) bool

func ServiceMesh

func ServiceMesh(hasEBPFDaemonSet bool) *client.ServiceMesh

func UpdateServiceMesh

func UpdateServiceMesh(group string, updateType ServiceMeshUpdateType)

Types

type Cache

type Cache interface {
	// Add adds the provided GroupVersionKinds to the cache and
	// the corresponding GroupVersionResource as well as the APIVersion.
	Add(...schema.GroupVersionKind)

	// Delete removes the provided GroupVersionKinds from the cache and
	// the corresponding GroupVersionResource as well as the APIVersion.
	Delete(...schema.GroupVersionKind)

	// Refresh force refreshes the cache.
	Refresh() error

	// MaybeResetRESTMapper resets the RESTMapper if the provided GVKs are CustomResourceDefinitions.
	MaybeResetRESTMapper(...schema.GroupVersionKind)

	// GroupVersionKind returns the set of GroupVersionKinds in the cache.
	GroupVersionKind() containers.Set[schema.GroupVersionKind]

	// GroupVersionResource returns the set of GroupVersionResources in the cache.
	GroupVersionResource() containers.Set[schema.GroupVersionResource]

	// GroupVersion returns the set of GroupVersions in the cache.
	GroupVersion() containers.Set[schema.GroupVersion]

	// ServerVersion returns the Kubernetes server version.
	ServerVersion() *version.Info

	// KindFor returns GVK for provided GVR.
	KindFor(gvr schema.GroupVersionResource) (schema.GroupVersionKind, error)

	// RestMapping returns the RESTMapping for the provided GVK.
	RestMapping(gvk schema.GroupVersionKind) (*meta.RESTMapping, error)

	// OnGroupVersionAdded registers a callback function to be called when a new API group is added to the cache.
	OnGroupVersionAdded(f GroupVersionUpdateFunc)

	// OnGroupVersionDeleted registers a callback function to be called when an API group is deleted from the cache.
	OnGroupVersionDeleted(f GroupVersionUpdateFunc)

	// OnGroupVersionKindAdded registers a callback function to be called when a new GroupVersionKind is added to the cache.
	OnGroupVersionKindAdded(f GroupVersionKindUpdateFunc)

	// OnGroupVersionKindDeleted registers a callback function to be called when a GroupVersionKind is deleted from the cache.
	OnGroupVersionKindDeleted(f GroupVersionKindUpdateFunc)

	// OnGroupVersionResourceAdded registers a callback function to be called when a new GroupVersionResource is added to the cache.
	OnGroupVersionResourceAdded(f GroupVersionResourceUpdateFunc)

	// OnGroupVersionResourceDeleted registers a callback function to be called when a GroupVersionResource is deleted from the cache.
	OnGroupVersionResourceDeleted(f GroupVersionResourceUpdateFunc)
}

func GlobalCache

func GlobalCache() Cache

func NewCache

func NewCache(client discovery.DiscoveryInterface, mapper meta.RESTMapper, option ...CacheOption) Cache

type CacheOption

type CacheOption func(*cache)

func WithOnGroupVersionAdded

func WithOnGroupVersionAdded(f ...GroupVersionUpdateFunc) CacheOption

func WithOnGroupVersionDeleted

func WithOnGroupVersionDeleted(f ...GroupVersionUpdateFunc) CacheOption

func WithOnGroupVersionKindAdded

func WithOnGroupVersionKindAdded(f ...GroupVersionKindUpdateFunc) CacheOption

func WithOnGroupVersionKindDeleted

func WithOnGroupVersionKindDeleted(f ...GroupVersionKindUpdateFunc) CacheOption

func WithOnGroupVersionResourceAdded

func WithOnGroupVersionResourceAdded(f ...GroupVersionResourceUpdateFunc) CacheOption

func WithOnGroupVersionResourceDeleted

func WithOnGroupVersionResourceDeleted(f ...GroupVersionResourceUpdateFunc) CacheOption

type GroupVersionKindUpdateFunc

type GroupVersionKindUpdateFunc func(schema.GroupVersionKind)

type GroupVersionResourceUpdateFunc

type GroupVersionResourceUpdateFunc func(schema.GroupVersionResource)

type GroupVersionUpdateFunc

type GroupVersionUpdateFunc func(schema.GroupVersion)

type Manager

type Manager interface {
	// Start starts the discovery cache manager. The first run is synchronous,
	// meaning that it will block until the first refresh is completed.
	Start(context.Context) error

	// Stop stops the discovery cache manager.
	Stop()
}

Manager is a discovery cache manager. It is responsible for refreshing the cache periodically.

func NewDiscoveryManager

func NewDiscoveryManager(option ...ManagerOption) Manager

type ManagerOption

type ManagerOption func(*manager)

func WithCache

func WithCache(cache Cache) ManagerOption

WithCache sets the cache to use for the discovery manager. If not provided, the global cache is used.

func WithRefreshInterval

func WithRefreshInterval(refreshInterval time.Duration) ManagerOption

WithRefreshInterval sets the refresh interval for the discovery manager.

type ServiceMeshResourceGroup

type ServiceMeshResourceGroup string

ServiceMeshResourceGroup represents a group name used by a service mesh.

func (ServiceMeshResourceGroup) Priority

func (ServiceMeshResourceGroup) String

func (in ServiceMeshResourceGroup) String() string

type ServiceMeshResourcePriority

type ServiceMeshResourcePriority uint8

ServiceMeshResourcePriority determines the order in which the ServiceMeshResourceGroup is assigned. Lower number means higher priority.

type ServiceMeshUpdateType

type ServiceMeshUpdateType uint8

ServiceMeshUpdateType represents the type of update that happened to the service mesh.

Jump to

Keyboard shortcuts

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