types

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 4 Imported by: 29

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EventString

func EventString(i interface{}) string

func Init

func Init(nodeName string)

func MustAddVirtualL3EndpointColumn added in v0.18.0

func MustAddVirtualL3EndpointColumn[Event any](
	cols *columns.Columns[Event],
	attr columns.Attributes,
	getEndpoint func(*Event) L3Endpoint,
)

func MustAddVirtualL4EndpointColumn added in v0.18.0

func MustAddVirtualL4EndpointColumn[Event any](
	cols *columns.Columns[Event],
	attr columns.Attributes,
	getEndpoint func(*Event) L4Endpoint,
)

Types

type BasicK8sMetadata added in v0.19.0

type BasicK8sMetadata struct {
	Namespace     string            `json:"namespace,omitempty" column:"namespace,template:namespace"`
	PodName       string            `json:"podName,omitempty" column:"podName,template:pod"`
	PodLabels     map[string]string `json:"podLabels,omitempty" column:"labels,hide"`
	ContainerName string            `json:"containerName,omitempty" column:"containerName,template:container"`
}

func (*BasicK8sMetadata) IsEnriched added in v0.19.0

func (b *BasicK8sMetadata) IsEnriched() bool

type BasicRuntimeMetadata added in v0.19.0

type BasicRuntimeMetadata struct {
	// RuntimeName is the name of the container runtime. It is useful to distinguish
	// who is the "owner" of each container in a list of containers collected
	// from multiple runtimes.
	RuntimeName RuntimeName `json:"runtimeName,omitempty" column:"runtimeName,width:19,fixed,hide"`

	// ContainerID is the container ContainerID without the container runtime prefix. For
	// instance, without the "cri-o://" for CRI-O.
	ContainerID string `json:"containerId,omitempty" column:"containerId,width:13,maxWidth:64,hide"`

	// ContainerName is the container name. In the case the container runtime
	// response with multiple containers, ContainerName contains only the first element.
	ContainerName string `json:"containerName,omitempty" column:"containerName,template:container"`

	// ContainerImageName is the name of the container image where the event comes from
	// i.e. docker.io/library/busybox:latest
	// Sometimes the image name is not provided by the runtime (i.e. Docker), then ContainerImageName
	// is the imageID
	// i.e. sha256:6e38f40d628db3002f5617342c8872c935de530d867d0f709a2fbda1a302a562
	// OR
	// i.e. 6e38f40d628d, when truncated
	ContainerImageName string `json:"containerImageName,omitempty" column:"containerImageName,hide"`

	// ContainerImageDigest is the (repo) digest of the container image where the event comes from
	// containerd: events from both initial and new containers are enriched
	// crio: events from initial containers are enriched
	ContainerImageDigest string `json:"containerImageDigest,omitempty" column:"containerImageDigest,hide"`
}

func (*BasicRuntimeMetadata) IsEnriched added in v0.19.0

func (b *BasicRuntimeMetadata) IsEnriched() bool

type CommonData

type CommonData struct {
	// Runtime contains the container runtime metadata of the container
	// that generated the event
	Runtime BasicRuntimeMetadata `json:"runtime,omitempty" column:"runtime" columnTags:"runtime"`

	// K8s contains the Kubernetes metadata of the object that generated the
	// event
	K8s K8sMetadata `json:"k8s,omitempty" column:"k8s" columnTags:"kubernetes"`
}

func (*CommonData) GetContainer added in v0.15.0

func (c *CommonData) GetContainer() string

func (*CommonData) GetContainerImageName added in v0.19.0

func (c *CommonData) GetContainerImageName() string

func (*CommonData) GetNamespace added in v0.15.0

func (c *CommonData) GetNamespace() string

func (*CommonData) GetNode added in v0.15.0

func (c *CommonData) GetNode() string

func (*CommonData) GetPod added in v0.15.0

func (c *CommonData) GetPod() string

func (*CommonData) SetContainerMetadata added in v0.19.0

func (c *CommonData) SetContainerMetadata(container Container)

func (*CommonData) SetNode added in v0.14.0

func (c *CommonData) SetNode(node string)

func (*CommonData) SetPodMetadata added in v0.19.0

func (c *CommonData) SetPodMetadata(container Container)

type Container added in v0.28.0

type Container interface {
	K8sMetadata() *BasicK8sMetadata
	RuntimeMetadata() *BasicRuntimeMetadata
	UsesHostNetwork() bool
}

type EndpointKind added in v0.18.0

type EndpointKind string
const (
	EndpointKindPod     EndpointKind = "pod"
	EndpointKindService EndpointKind = "svc"
	EndpointKindRaw     EndpointKind = "raw"
)

type Event

type Event struct {
	CommonData

	// Timestamp in nanoseconds since January 1, 1970 UTC. An int64 is big
	// enough to represent time between the year 1678 and 2262.
	Timestamp Time `json:"timestamp,omitempty" column:"timestamp,template:timestamp,stringer"`

	// Type indicates the kind of this event
	Type EventType `json:"type"`

	// Message when Type is ERR, WARN, DEBUG or INFO
	Message string `json:"message,omitempty"`
}

func Debug

func Debug(msg string) Event

func Err

func Err(msg string) Event

func Info

func Info(msg string) Event

func Warn

func Warn(msg string) Event

func (Event) GetBaseEvent added in v0.11.0

func (e Event) GetBaseEvent() *Event

GetBaseEvent is needed to implement commonutils.BaseElement and snapshot.SnapshotEvent interfaces.

func (*Event) GetMessage added in v0.15.0

func (e *Event) GetMessage() string

func (*Event) GetType added in v0.15.0

func (e *Event) GetType() EventType

type EventType

type EventType string
const (
	// Indicates a generic event produced by a gadget. Gadgets extend
	// the base event to contain the specific data the gadget provides
	NORMAL EventType = "normal"

	// Event is an error message
	ERR EventType = "err"

	// Event is a warning message
	WARN EventType = "warn"

	// Event is a debug message
	DEBUG EventType = "debug"

	// Event is a info message
	INFO EventType = "info"

	// Indicates the tracer in the node is now is able to produce events
	READY EventType = "ready"
)

type K8sMetadata added in v0.19.0

type K8sMetadata struct {
	Node string `json:"node,omitempty" column:"node,template:node"`

	BasicK8sMetadata `json:",inline"`

	// HostNetwork is true if the container uses the host network namespace
	HostNetwork bool `json:"hostNetwork,omitempty" column:"hostnetwork,hide"`
}

type L3Endpoint added in v0.18.0

type L3Endpoint struct {
	// Addr is filled by the gadget
	Addr    string `json:"addr,omitempty" column:"addr,hide,template:ipaddr"`
	Version uint8  `json:"version,omitempty" column:"v,hide,template:ipversion"`

	// Namespace, Name, Kind and PodLabels get populated by the KubeIPResolver operator
	Namespace string            `json:"namespace,omitempty" column:"ns,template:namespace,hide"`
	Name      string            `json:"podname,omitempty" column:"name,hide"`
	Kind      EndpointKind      `json:"kind,omitempty" column:"kind,hide"`
	PodLabels map[string]string `json:"podlabels,omitempty" column:"podLabels,hide"`
}

func (*L3Endpoint) String added in v0.18.0

func (e *L3Endpoint) String() string

type L4Endpoint added in v0.18.0

type L4Endpoint struct {
	L3Endpoint
	// Port and Proto are filled by the gadget
	Port  uint16 `json:"port" column:"port,hide,template:ipport"`
	Proto uint16 `json:"proto,omitempty" column:"proto,hide,width:4"`
}

func (*L4Endpoint) String added in v0.18.0

func (e *L4Endpoint) String() string

type RuntimeName added in v0.19.0

type RuntimeName string
const (
	RuntimeNameDocker     RuntimeName = "docker"
	RuntimeNameContainerd RuntimeName = "containerd"
	RuntimeNameCrio       RuntimeName = "cri-o"
	RuntimeNamePodman     RuntimeName = "podman"
	RuntimeNameUnknown    RuntimeName = "unknown"
)

func String2RuntimeName added in v0.19.0

func String2RuntimeName(name string) RuntimeName

func (RuntimeName) String added in v0.19.0

func (r RuntimeName) String() string

type Time added in v0.13.0

type Time int64

func (Time) String added in v0.13.0

func (t Time) String() string

type WithMountNsID added in v0.14.0

type WithMountNsID struct {
	MountNsID uint64 `json:"mountnsid,omitempty" column:"mntns,template:ns"`
}

func (*WithMountNsID) GetMountNSID added in v0.14.0

func (e *WithMountNsID) GetMountNSID() uint64

type WithNetNsID added in v0.14.0

type WithNetNsID struct {
	NetNsID uint64 `json:"netnsid,omitempty" column:"netns,template:ns"`
}

func (*WithNetNsID) GetNetNSID added in v0.14.0

func (e *WithNetNsID) GetNetNSID() uint64

Jump to

Keyboard shortcuts

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