Documentation ¶
Index ¶
- Constants
- Variables
- type CacheAccessK8SWatcher
- type K8sCiliumEndpointsWatcher
- type K8sCiliumLRPWatcher
- type K8sCiliumNodeWatcher
- type K8sEndpointsWatcher
- type K8sEventReporter
- type K8sNamespaceWatcher
- type K8sPodWatcher
- type K8sServiceWatcher
- type K8sWatcher
- func (k *K8sWatcher) GetAPIGroups() []string
- func (k *K8sWatcher) GetCachedNamespace(namespace string) (*slim_corev1.Namespace, error)
- func (k *K8sWatcher) GetCachedPod(namespace, name string) (*slim_corev1.Pod, error)
- func (k *K8sWatcher) InitK8sSubsystem(ctx context.Context, cachesSynced chan struct{})
- func (k *K8sWatcher) K8sEventProcessed(scope, action string, status bool)
- func (k *K8sWatcher) K8sEventReceived(apiResourceName, scope, action string, valid, equal bool)
- func (k *K8sWatcher) RunK8sServiceHandler()
- func (k *K8sWatcher) StopWatcher()
- func (k *K8sWatcher) WaitForCRDsToRegister(ctx context.Context) error
- func (k *K8sWatcher) WaitForCacheSync(resourceNames ...string)
- type WatcherConfiguration
Constants ¶
const (
K8sAPIGroupServiceV1Core = "core/v1::Service"
)
Variables ¶
var Cell = cell.Module( "k8s-watcher", "K8s Watcher", cell.Provide(newK8sWatcher), cell.ProvidePrivate(newK8sPodWatcher), cell.Provide(newK8sCiliumNodeWatcher), cell.ProvidePrivate(newK8sNamespaceWatcher), cell.ProvidePrivate(newK8sServiceWatcher), cell.ProvidePrivate(newK8sEndpointsWatcher), cell.ProvidePrivate(newK8sCiliumLRPWatcher), cell.ProvidePrivate(newK8sCiliumEndpointsWatcher), cell.Provide(newK8sEventReporter), )
Cell provides the global k8s watcher.
Functions ¶
This section is empty.
Types ¶
type CacheAccessK8SWatcher ¶ added in v1.16.0
type CacheAccessK8SWatcher interface { GetCachedNamespace(namespace string) (*slim_corev1.Namespace, error) GetCachedPod(namespace, name string) (*slim_corev1.Pod, error) }
type K8sCiliumEndpointsWatcher ¶ added in v1.16.0
type K8sCiliumEndpointsWatcher struct {
// contains filtered or unexported fields
}
type K8sCiliumLRPWatcher ¶ added in v1.16.0
type K8sCiliumLRPWatcher struct {
// contains filtered or unexported fields
}
type K8sCiliumNodeWatcher ¶ added in v1.16.0
type K8sCiliumNodeWatcher struct {
// contains filtered or unexported fields
}
func (*K8sCiliumNodeWatcher) GetCiliumNode ¶ added in v1.16.0
func (k *K8sCiliumNodeWatcher) GetCiliumNode(ctx context.Context, nodeName string) (*cilium_v2.CiliumNode, error)
GetCiliumNode returns the CiliumNode "nodeName" from the local Resource[T] store. If the local Resource[T] store is not initialized or the key value store is connected, then it will retrieve the node from kube-apiserver. Note that it may be possible (although rare) that the requested nodeName is not yet in the store if the local cache is falling behind due to the high amount of CiliumNode events received from the k8s API server. To mitigate this, the caller should retry GetCiliumNode for a given interval to be sure that a CiliumNode with that name has not actually been created.
type K8sEndpointsWatcher ¶ added in v1.16.0
type K8sEndpointsWatcher struct {
// contains filtered or unexported fields
}
type K8sEventReporter ¶ added in v1.16.0
type K8sEventReporter struct {
// contains filtered or unexported fields
}
func (*K8sEventReporter) K8sEventProcessed ¶ added in v1.16.0
func (k *K8sEventReporter) K8sEventProcessed(scope, action string, status bool)
K8sEventProcessed is called to do metrics accounting for each processed Kubernetes event
func (*K8sEventReporter) K8sEventReceived ¶ added in v1.16.0
func (k *K8sEventReporter) 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.
type K8sNamespaceWatcher ¶ added in v1.16.0
type K8sNamespaceWatcher struct {
// contains filtered or unexported fields
}
func (*K8sNamespaceWatcher) GetCachedNamespace ¶ added in v1.16.0
func (k *K8sNamespaceWatcher) GetCachedNamespace(namespace string) (*slim_corev1.Namespace, error)
GetCachedNamespace returns a namespace from the local store.
type K8sPodWatcher ¶ added in v1.16.0
type K8sPodWatcher struct {
// contains filtered or unexported fields
}
func (*K8sPodWatcher) GetCachedPod ¶ added in v1.16.0
func (k *K8sPodWatcher) GetCachedPod(namespace, name string) (*slim_corev1.Pod, error)
GetCachedPod returns a pod from the local store.
type K8sServiceWatcher ¶ added in v1.16.0
type K8sServiceWatcher struct {
// contains filtered or unexported fields
}
func (*K8sServiceWatcher) RunK8sServiceHandler ¶ added in v1.16.0
func (k *K8sServiceWatcher) RunK8sServiceHandler()
type K8sWatcher ¶
type K8sWatcher struct {
// contains filtered or unexported fields
}
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.
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. It initializes the K8s subsystem and starts the watchers for the resources that the daemon is interested in. The cachesSynced channel is closed when all caches 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) RunK8sServiceHandler ¶
func (k *K8sWatcher) RunK8sServiceHandler()
func (*K8sWatcher) StopWatcher ¶ added in v1.16.0
func (k *K8sWatcher) StopWatcher()
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.
type WatcherConfiguration ¶
type WatcherConfiguration interface { // K8sNetworkPolicyEnabled returns true if cilium agent needs to support K8s NetworkPolicy K8sNetworkPolicyEnabled() bool // KVstoreEnabledWithoutPodNetworkSupport returns whether Cilium is configured to connect // to an external KVStore, and the support for running it in pod network is disabled. // In this case, we don't need to start the CiliumNode and CiliumEndpoint watchers at // all, given that the CRD to kvstore handover logic is not required. KVstoreEnabledWithoutPodNetworkSupport() bool }
WatcherConfiguration is the required configuration for enableK8sWatchers
Source Files ¶
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. |