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) RunK8sServiceHandler()
- func (k *K8sWatcher) StopK8sServiceHandler()
- func (k *K8sWatcher) WaitForCRDsToRegister(ctx context.Context) error
- func (k *K8sWatcher) WaitForCacheSync(resourceNames ...string)
- func (k *K8sWatcher) WaitForCacheSyncWithTimeout(timeout time.Duration, resourceNames ...string) error
- 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, nodeDiscoverManager nodeDiscoverManager, policyManager policyManager, policyRepository policyRepository, svcManager svcManager, datapath datapath.Datapath, redirectPolicyManager redirectPolicyManager, bgpSpeakerManager bgpSpeakerManager, cfg WatcherConfiguration, ipcache ipcacheManager, cgroupManager cgroupManager, resources agentK8s.Resources, serviceCache *k8s.ServiceCache, bandwidthManager datapath.BandwidthManager, ) *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 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. 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) 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 ¶
type WatcherConfiguration interface { utils.PolicyConfiguration }
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. |