kubernetesmonitor

package
v10.324.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const KubernetesContainerNameIdentifier = "@usr:io.kubernetes.container.name"

KubernetesContainerNameIdentifier is the label used by Docker for the K8S container name.

View Source
const KubernetesInfraContainerName = "POD"

KubernetesInfraContainerName is the name of the infra POD.

View Source
const KubernetesPodNameIdentifier = "@usr:io.kubernetes.pod.name"

KubernetesPodNameIdentifier is the label used by Docker for the K8S pod name.

View Source
const KubernetesPodNamespaceIdentifier = "@usr:io.kubernetes.pod.namespace"

KubernetesPodNamespaceIdentifier is the label used by Docker for the K8S namespace.

View Source
const UpstreamNameIdentifier = "k8s:name"

UpstreamNameIdentifier is the identifier used to identify the nane on the resulting PU

View Source
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 DefaultConfig

func DefaultConfig() *Config

DefaultConfig provides a default configuration

func SetupDefaultConfig

func SetupDefaultConfig(kubernetesConfig *Config) *Config

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 New

func New() *KubernetesMonitor

New returns a new kubernetes monitor.

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) Pod

func (m *KubernetesMonitor) Pod(podName string, namespace string) (*api.Pod, error)

Pod returns the full pod object.

func (*KubernetesMonitor) RefreshPUs

func (m *KubernetesMonitor) RefreshPUs(ctx context.Context, pod *api.Pod) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL