Documentation
¶
Index ¶
- func AddPodInformer(w *K8sWatcher, local bool) error
- func GetK8sClients(waitCRDs func(*rest.Config) error) (*kubernetes.Clientset, *versioned.Clientset, error)
- type FakeK8sWatcher
- func (watcher *FakeK8sWatcher) AddInformer(_ string, _ cache.SharedIndexInformer, _ cache.Indexers) error
- func (watcher *FakeK8sWatcher) AddPod(pod *corev1.Pod)
- func (watcher *FakeK8sWatcher) AddService(service *corev1.Service)
- func (watcher *FakeK8sWatcher) ClearAllPods()
- func (watcher *FakeK8sWatcher) ClearAllServices()
- func (watcher *FakeK8sWatcher) FindContainer(containerID string) (*corev1.Pod, *corev1.ContainerStatus, bool)
- func (watcher *FakeK8sWatcher) FindMirrorPod(_ string) (*corev1.Pod, error)
- func (watcher *FakeK8sWatcher) FindPod(podID string) (*corev1.Pod, error)
- func (watcher *FakeK8sWatcher) GetCRDInformerFactory() externalversions.SharedInformerFactory
- func (watcher *FakeK8sWatcher) GetInformer(_ string) cache.SharedIndexInformer
- func (watcher *FakeK8sWatcher) GetK8sInformerFactory() informers.SharedInformerFactory
- func (watcher *FakeK8sWatcher) GetLocalK8sInformerFactory() informers.SharedInformerFactory
- func (watcher *FakeK8sWatcher) Start()
- type K8sResourceWatcher
- type K8sWatcher
- func (w *K8sWatcher) AddInformer(name string, informer cache.SharedIndexInformer, indexers cache.Indexers) error
- func (watcher *K8sWatcher) FindContainer(containerID string) (*corev1.Pod, *corev1.ContainerStatus, bool)
- func (watcher *K8sWatcher) FindMirrorPod(hash string) (*corev1.Pod, error)
- func (watcher *K8sWatcher) FindPod(podID string) (*corev1.Pod, error)
- func (w *K8sWatcher) GetCRDInformerFactory() externalversions.SharedInformerFactory
- func (w *K8sWatcher) GetInformer(name string) cache.SharedIndexInformer
- func (w *K8sWatcher) GetK8sInformerFactory() informers.SharedInformerFactory
- func (w *K8sWatcher) GetLocalK8sInformerFactory() informers.SharedInformerFactory
- func (w *K8sWatcher) Start()
- type PodAccessor
- type Watcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPodInformer ¶ added in v1.4.0
func AddPodInformer(w *K8sWatcher, local bool) error
func GetK8sClients ¶ added in v1.4.0
Types ¶
type FakeK8sWatcher ¶
type FakeK8sWatcher struct {
// contains filtered or unexported fields
}
FakeK8sWatcher is used as an "empty" PodAccessor when --enable-k8s-api flag is not set. It is also used for testing, allowing users to specify a static list of pods.
func NewFakeK8sWatcher ¶
func NewFakeK8sWatcher(pods []interface{}) *FakeK8sWatcher
NewFakeK8sWatcher returns a pointer to an initialized FakeK8sWatcher struct.
func NewFakeK8sWatcherWithPodsAndServices ¶ added in v0.11.0
func NewFakeK8sWatcherWithPodsAndServices(pods []interface{}, services []interface{}) *FakeK8sWatcher
NewFakeK8sWatcherWithPodsAndServices returns a pointer to an initialized FakeK8sWatcher struct
func (*FakeK8sWatcher) AddInformer ¶ added in v1.4.0
func (watcher *FakeK8sWatcher) AddInformer(_ string, _ cache.SharedIndexInformer, _ cache.Indexers) error
func (*FakeK8sWatcher) AddPod ¶ added in v0.9.0
func (watcher *FakeK8sWatcher) AddPod(pod *corev1.Pod)
AddPod adds a pod to the fake k8s watcher. This is intended for testing.
func (*FakeK8sWatcher) AddService ¶ added in v0.11.0
func (watcher *FakeK8sWatcher) AddService(service *corev1.Service)
AddService adds a service to the fake k8s watcher.
func (*FakeK8sWatcher) ClearAllPods ¶ added in v0.9.0
func (watcher *FakeK8sWatcher) ClearAllPods()
ClearPods() removes all pods from the fake watcher. This is intended for testing.
func (*FakeK8sWatcher) ClearAllServices ¶ added in v0.11.0
func (watcher *FakeK8sWatcher) ClearAllServices()
ClearAllServices removes all services from the fake watcher.
func (*FakeK8sWatcher) FindContainer ¶ added in v0.9.0
func (watcher *FakeK8sWatcher) FindContainer(containerID string) (*corev1.Pod, *corev1.ContainerStatus, bool)
FindContainer implements PodAccessor.FindContainer
func (*FakeK8sWatcher) FindMirrorPod ¶ added in v1.2.0
func (watcher *FakeK8sWatcher) FindMirrorPod(_ string) (*corev1.Pod, error)
func (*FakeK8sWatcher) FindPod ¶
func (watcher *FakeK8sWatcher) FindPod(podID string) (*corev1.Pod, error)
func (*FakeK8sWatcher) GetCRDInformerFactory ¶ added in v1.4.0
func (watcher *FakeK8sWatcher) GetCRDInformerFactory() externalversions.SharedInformerFactory
func (*FakeK8sWatcher) GetInformer ¶ added in v1.0.3
func (watcher *FakeK8sWatcher) GetInformer(_ string) cache.SharedIndexInformer
func (*FakeK8sWatcher) GetK8sInformerFactory ¶ added in v1.4.0
func (watcher *FakeK8sWatcher) GetK8sInformerFactory() informers.SharedInformerFactory
func (*FakeK8sWatcher) GetLocalK8sInformerFactory ¶ added in v1.4.0
func (watcher *FakeK8sWatcher) GetLocalK8sInformerFactory() informers.SharedInformerFactory
func (*FakeK8sWatcher) Start ¶ added in v1.0.3
func (watcher *FakeK8sWatcher) Start()
type K8sResourceWatcher ¶
type K8sResourceWatcher interface {
Watcher
PodAccessor
}
type K8sWatcher ¶
type K8sWatcher struct {
// contains filtered or unexported fields
}
NB(anna): localK8sInformerFactory and deletedPodCache are relevant only when watching pods. If a K8sWatcher instance is e.g. watching only policies, they are unused. If needed, they can be factored out to make the K8sWatcher struct more generic.
func NewK8sWatcher ¶
func NewK8sWatcher( k8sClient kubernetes.Interface, crdClient versioned.Interface, stateSyncInterval time.Duration, ) *K8sWatcher
NewK8sWatcher creates a new K8sWatcher with initialized informer factories.
func (*K8sWatcher) AddInformer ¶ added in v1.4.0
func (w *K8sWatcher) AddInformer(name string, informer cache.SharedIndexInformer, indexers cache.Indexers) error
func (*K8sWatcher) FindContainer ¶ added in v0.9.0
func (watcher *K8sWatcher) FindContainer(containerID string) (*corev1.Pod, *corev1.ContainerStatus, bool)
FindContainer implements PodAccessor.FindContainer.
func (*K8sWatcher) FindMirrorPod ¶ added in v1.2.0
func (watcher *K8sWatcher) FindMirrorPod(hash string) (*corev1.Pod, error)
FindMirrorPod finds the mirror pod of a static pod based on the hash see: https://kubernetes.io/docs/reference/labels-annotations-taints/#kubernetes-io-config-hash, https://kubernetes.io/docs/reference/labels-annotations-taints/#kubernetes-io-config-mirror, https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/
func (*K8sWatcher) GetCRDInformerFactory ¶ added in v1.4.0
func (w *K8sWatcher) GetCRDInformerFactory() externalversions.SharedInformerFactory
func (*K8sWatcher) GetInformer ¶ added in v1.0.3
func (w *K8sWatcher) GetInformer(name string) cache.SharedIndexInformer
func (*K8sWatcher) GetK8sInformerFactory ¶ added in v1.4.0
func (w *K8sWatcher) GetK8sInformerFactory() informers.SharedInformerFactory
func (*K8sWatcher) GetLocalK8sInformerFactory ¶ added in v1.4.0
func (w *K8sWatcher) GetLocalK8sInformerFactory() informers.SharedInformerFactory
func (*K8sWatcher) Start ¶ added in v1.0.3
func (w *K8sWatcher) Start()
type PodAccessor ¶ added in v1.4.0
type PodAccessor interface {
// Find a pod/container pair for the given container ID.
FindContainer(containerID string) (*corev1.Pod, *corev1.ContainerStatus, bool)
// Find a pod given the podID
FindPod(podID string) (*corev1.Pod, error)
// Find a mirror pod for a static pod
FindMirrorPod(hash string) (*corev1.Pod, error)
}
PodAccessor defines an interface for accessing pods from Kubernetes API.
type Watcher ¶ added in v1.4.0
type Watcher interface {
AddInformer(name string, informer cache.SharedIndexInformer, indexers cache.Indexers) error
GetInformer(name string) cache.SharedIndexInformer
Start()
GetK8sInformerFactory() informers.SharedInformerFactory
GetLocalK8sInformerFactory() informers.SharedInformerFactory
GetCRDInformerFactory() externalversions.SharedInformerFactory
}