Documentation ¶
Index ¶
- Constants
- func CreateResourceController(client kubecache.Getter, resource string, namespace string, ...) (kubecache.Store, kubecache.Controller)
- func NewKubeClient(kubeconfig string) (*kubernetes.Clientset, error)
- type Config
- type KubernetesMonitor
- func (m *KubernetesMonitor) CreateLocalPodController(namespace string, addFunc func(addedApiStruct *api.Pod) error, ...) (kubecache.Store, kubecache.Controller)
- func (m *KubernetesMonitor) HandlePUEvent(ctx context.Context, puID string, event common.Event, ...) error
- func (m *KubernetesMonitor) Pod(podName string, namespace string) (*api.Pod, error)
- func (m *KubernetesMonitor) RefreshPUs(ctx context.Context, pod *api.Pod) error
- func (m *KubernetesMonitor) Resync(ctx context.Context) error
- func (m *KubernetesMonitor) Run(ctx context.Context) error
- func (m *KubernetesMonitor) SetupConfig(registerer registerer.Registerer, cfg interface{}) error
- func (m *KubernetesMonitor) SetupHandlers(c *config.ProcessorConfig)
Constants ¶
const KubernetesContainerNameIdentifier = "@usr:io.kubernetes.container.name"
KubernetesContainerNameIdentifier is the label used by Docker for the K8S container name.
const KubernetesInfraContainerName = "POD"
KubernetesInfraContainerName is the name of the infra POD.
const KubernetesPodNameIdentifier = "@usr:io.kubernetes.pod.name"
KubernetesPodNameIdentifier is the label used by Docker for the K8S pod name.
const KubernetesPodNamespaceIdentifier = "@usr:io.kubernetes.pod.namespace"
KubernetesPodNamespaceIdentifier is the label used by Docker for the K8S namespace.
const UpstreamNameIdentifier = "k8s:name"
UpstreamNameIdentifier is the identifier used to identify the nane on the resulting PU
const UpstreamNamespaceIdentifier = "k8s:namespace"
UpstreamNamespaceIdentifier is the identifier used to identify the nanespace on the resulting PU
Variables ¶
This section is empty.
Functions ¶
func CreateResourceController ¶
func CreateResourceController(client kubecache.Getter, resource string, namespace string, apiStruct runtime.Object, selector fields.Selector, addFunc func(addedApiStruct interface{}), deleteFunc func(deletedApiStruct interface{}), updateFunc func(oldApiStruct, updatedApiStruct interface{})) (kubecache.Store, kubecache.Controller)
CreateResourceController creates a controller for a specific ressource and namespace. The parameter function will be called on Add/Delete/Update events
func NewKubeClient ¶
func NewKubeClient(kubeconfig string) (*kubernetes.Clientset, error)
NewKubeClient Generate and initialize a Kubernetes client based on the parameter kubeconfig
Types ¶
type Config ¶
type Config struct { DockerConfig dockerMonitor.Config Kubeconfig string Nodename string EnableHostPods bool KubernetesExtractor extractors.KubernetesMetadataExtractorType DockerExtractor extractors.DockerMetadataExtractor }
Config is the config for the Kubernetes monitor
func SetupDefaultConfig ¶
SetupDefaultConfig adds defaults to a partial configuration
type KubernetesMonitor ¶
type KubernetesMonitor struct {
// contains filtered or unexported fields
}
KubernetesMonitor implements a monitor that sends pod events upstream It is implemented as a filter on the standard DockerMonitor. It gets all the PU events from the DockerMonitor and if the container is the POD container from Kubernetes, It connects to the Kubernetes API and adds the tags that are coming from Kuberntes that cannot be found
func (*KubernetesMonitor) CreateLocalPodController ¶
func (m *KubernetesMonitor) CreateLocalPodController(namespace string, addFunc func(addedApiStruct *api.Pod) error, deleteFunc func(deletedApiStruct *api.Pod) error, updateFunc func(oldApiStruct, updatedApiStruct *api.Pod) error) (kubecache.Store, kubecache.Controller)
CreateLocalPodController creates a controller specifically for Pods.
func (*KubernetesMonitor) HandlePUEvent ¶
func (m *KubernetesMonitor) HandlePUEvent(ctx context.Context, puID string, event common.Event, dockerRuntime policy.RuntimeReader) error
HandlePUEvent is called by all monitors when a PU event is generated. The implementer is responsible to update all components by explicitly adding a new PU. Specifically for Kubernetes, The monitor handles the downstream events from Docker.
func (*KubernetesMonitor) RefreshPUs ¶
RefreshPUs is used to resend an update event to the Upstream Policy Resolver in case of an update is needed.
func (*KubernetesMonitor) Resync ¶
func (m *KubernetesMonitor) Resync(ctx context.Context) error
Resync requests to the monitor to do a resync.
func (*KubernetesMonitor) Run ¶
func (m *KubernetesMonitor) Run(ctx context.Context) error
Run starts the monitor.
func (*KubernetesMonitor) SetupConfig ¶
func (m *KubernetesMonitor) SetupConfig(registerer registerer.Registerer, cfg interface{}) error
SetupConfig provides a configuration to implmentations. Every implmentation can have its own config type.
func (*KubernetesMonitor) SetupHandlers ¶
func (m *KubernetesMonitor) SetupHandlers(c *config.ProcessorConfig)
SetupHandlers sets up handlers for monitors to invoke for various events such as processing unit events and synchronization events. This will be called before Start() by the consumer of the monitor