watchers

package
v1.15.4 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 82 Imported by: 1

Documentation

Index

Constants

View Source
const (
	K8sAPIGroupServiceV1Core = "core/v1::Service"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type K8sWatcher

type K8sWatcher struct {

	// K8sSvcCache is a cache of all Kubernetes services and endpoints
	K8sSvcCache *k8s.ServiceCache
	// contains filtered or unexported fields
}

func NewK8sWatcher

func NewK8sWatcher(
	clientset client.Clientset,
	endpointManager endpointManager,
	nodeDiscoverManager nodeDiscoverManager,
	policyManager policyManager,
	policyRepository policyRepository,
	svcManager svcManager,
	datapath datapath.Datapath,
	redirectPolicyManager redirectPolicyManager,
	bgpSpeakerManager bgpSpeakerManager,
	envoyConfigManager envoyConfigManager,
	cfg WatcherConfiguration,
	ipcache ipcacheManager,
	cgroupManager cgroupManager,
	resources agentK8s.Resources,
	serviceCache *k8s.ServiceCache,
	bandwidthManager bandwidth.Manager,
) *K8sWatcher

func (*K8sWatcher) GetAPIGroups

func (k *K8sWatcher) GetAPIGroups() []string

func (*K8sWatcher) GetCachedNamespace

func (k *K8sWatcher) GetCachedNamespace(namespace string) (*slim_corev1.Namespace, error)

GetCachedNamespace returns a namespace from the local store.

func (*K8sWatcher) GetCachedPod

func (k *K8sWatcher) GetCachedPod(namespace, name string) (*slim_corev1.Pod, error)

GetCachedPod returns a pod from the local store. Depending if the Cilium agent flag `option.Config.K8sEventHandover` this function might only return local pods. If `option.Config.K8sEventHandover` is:

  • true: returns only local pods received by the pod watcher.
  • false: returns any pod in the cluster received by the pod watcher.

func (*K8sWatcher) GetCiliumNode

func (k *K8sWatcher) GetCiliumNode(ctx context.Context, nodeName string) (*cilium_v2.CiliumNode, error)

GetCiliumNode returns the CiliumNode "nodeName" from the local store. If the local store is not initialized then it will fallback retrieving the node from kube-apiserver.

func (*K8sWatcher) GetStore

func (k *K8sWatcher) GetStore(name string) cache.Store

GetStore returns the k8s cache store for the given resource name. It's possible for valid resource names to return nil stores if that watcher is not in use. Objects gotten using returned stores should *not* be mutated as they are references to internal k8s watcher store state.

func (*K8sWatcher) InitK8sSubsystem

func (k *K8sWatcher) InitK8sSubsystem(ctx context.Context, cachesSynced chan struct{})

InitK8sSubsystem takes a channel for which it will be closed when all caches essential for daemon are synchronized. To be called after WaitForCRDsToRegister() so that all needed CRDs have already been registered.

func (*K8sWatcher) K8sEventProcessed

func (k *K8sWatcher) K8sEventProcessed(scope, action string, status bool)

K8sEventProcessed is called to do metrics accounting for each processed Kubernetes event

func (*K8sWatcher) K8sEventReceived

func (k *K8sWatcher) K8sEventReceived(apiResourceName, scope, action string, valid, equal bool)

K8sEventReceived does metric accounting for each received Kubernetes event, as well as notifying of events for k8s resources synced.

func (*K8sWatcher) NetworkPoliciesInit

func (k *K8sWatcher) NetworkPoliciesInit()

func (*K8sWatcher) RunK8sServiceHandler

func (k *K8sWatcher) RunK8sServiceHandler()

func (*K8sWatcher) StopK8sServiceHandler

func (k *K8sWatcher) StopK8sServiceHandler()

func (*K8sWatcher) WaitForCRDsToRegister

func (k *K8sWatcher) WaitForCRDsToRegister(ctx context.Context) error

WaitForCRDsToRegister will wait for the Cilium Operator to register the CRDs with the apiserver. This step is required before launching the full K8s watcher, as those resource controllers need the resources to be registered with K8s first.

func (*K8sWatcher) WaitForCacheSync

func (k *K8sWatcher) WaitForCacheSync(resourceNames ...string)

WaitForCacheSync blocks until the given resources have been synchronized from k8s. Note that if the controller for a resource has not been started, the wait for that resource returns immediately. If it is required that the resource exists and is actually synchronized, the caller must ensure the controller for that resource has been started before calling WaitForCacheSync. For most resources this can be done by receiving from controllersStarted channel (<-k.controllersStarted), which is closed after most watchers have been started.

func (*K8sWatcher) WaitForCacheSyncWithTimeout

func (k *K8sWatcher) WaitForCacheSyncWithTimeout(timeout time.Duration, resourceNames ...string) error

WaitForCacheSyncWithTimeout calls WaitForCacheSync to block until given resources have had their caches synced from K8s. This will wait up to the timeout duration after starting or since the last K8s registered watcher event (i.e. each event causes the timeout to be pushed back). Events are recorded using K8sResourcesSynced.Event function. If the timeout is exceeded, an error is returned.

type WatcherConfiguration

WatcherConfiguration is the required configuration for enableK8sWatchers

Directories

Path Synopsis
This package contains exported resource identifiers and metric resource labels related to K8s watchers.
This package contains exported resource identifiers and metric resource labels related to K8s watchers.
Package subscriber implements a mechanism to represent K8s watcher subscribers and allows K8s events to objects / resources to notify their respective subscribers.
Package subscriber implements a mechanism to represent K8s watcher subscribers and allows K8s events to objects / resources to notify their respective subscribers.

Jump to

Keyboard shortcuts

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