Documentation ¶
Index ¶
- Constants
- 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) GetCiliumNode(ctx context.Context, nodeName string) (*cilium_v2.CiliumNode, 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) K8sServiceEventProcessed(action string, startTime time.Time)
- func (k *K8sWatcher) RunK8sServiceHandler()
- func (k *K8sWatcher) StopK8sServiceHandler()
- func (k *K8sWatcher) WaitForCRDsToRegister(ctx context.Context) error
- func (k *K8sWatcher) WaitForCacheSync(resourceNames ...string)
- type WatcherConfiguration
Constants ¶
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, k8sResourceSynced *synced.Resources, k8sAPIGroups *synced.APIGroups, endpointManager endpointManager, nodeManager nodeManager, policyManager policyManager, svcManager svcManager, redirectPolicyManager redirectPolicyManager, bgpSpeakerManager bgpSpeakerManager, cfg WatcherConfiguration, ipcache ipcacheManager, cgroupManager cgroupManager, resources agentK8s.Resources, serviceCache *k8s.ServiceCache, bandwidthManager datapath.BandwidthManager, db *statedb.DB, nodeAddrs statedb.Table[datapathTables.NodeAddress], ) *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.
func (*K8sWatcher) GetCiliumNode ¶
func (k *K8sWatcher) 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.
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) K8sServiceEventProcessed ¶
func (k *K8sWatcher) K8sServiceEventProcessed(action string, startTime time.Time)
K8sServiceEventProcessed is called to do metrics accounting the duration to program the service.
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.
type WatcherConfiguration ¶
type WatcherConfiguration interface { // K8sNetworkPolicyEnabled returns true if cilium agent needs to support K8s NetworkPolicy K8sNetworkPolicyEnabled() 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. |