trireme-lib: Index | Files

package kubernetesmonitor

import ""


Package Files

cache.go client.go config.go handler.go kubernetes.go monitor.go


const KubernetesContainerNameIdentifier = ""

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 = ""

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

func CreateResourceController Uses

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 Uses

func NewKubeClient(kubeconfig string) (*kubernetes.Clientset, error)

NewKubeClient Generate and initialize a Kubernetes client based on the parameter kubeconfig

type Config Uses

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 Uses

func DefaultConfig() *Config

DefaultConfig provides a default configuration

func SetupDefaultConfig Uses

func SetupDefaultConfig(kubernetesConfig *Config) *Config

SetupDefaultConfig adds defaults to a partial configuration

type KubernetesMonitor Uses

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 Uses

func New() *KubernetesMonitor

New returns a new kubernetes monitor.

func (*KubernetesMonitor) CreateLocalPodController Uses

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 Uses

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 Uses

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

Pod returns the full pod object.

func (*KubernetesMonitor) RefreshPUs Uses

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 Uses

func (m *KubernetesMonitor) Resync(ctx context.Context) error

Resync requests to the monitor to do a resync.

func (*KubernetesMonitor) Run Uses

func (m *KubernetesMonitor) Run(ctx context.Context) error

Run starts the monitor.

func (*KubernetesMonitor) SetupConfig Uses

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 Uses

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

Package kubernetesmonitor imports 21 packages (graph) and is imported by 2 packages. Updated 2019-10-07. Refresh now. Tools for package owners.