kube

package
v2.0.4-alloy-test Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceAttributesPrefix   = "resource.opentelemetry.io/"
	ServiceNameAnnotation      = ResourceAttributesPrefix + serviceNameKey
	ServiceNamespaceAnnotation = ResourceAttributesPrefix + serviceNamespaceKey

	EnvResourceAttributes = "OTEL_RESOURCE_ATTRIBUTES"
	EnvServiceName        = "OTEL_SERVICE_NAME"
	EnvServiceNamespace   = "OTEL_SERVICE_NAMESPACE"
)

Variables

View Source
var DefaultResourceLabels = ResourceLabels{

	"service.name":      []string{"app.kubernetes.io/name"},
	"service.namespace": []string{"app.kubernetes.io/part-of"},
}
View Source
var InfoForPID = container.InfoForPID

InfoForPID is an injectable dependency for system-independent testing

Functions

func TopOwner

func TopOwner(pod *informer.PodInfo) *informer.Owner

TopOwner assumes that the owners slice as returned by the informers' cache library, is sorted from lower-level to upper-level, so the last owner will be the top owner (e.g. the Deployment that owns the ReplicaSet that owns a Pod).

Types

type CachedObjMeta

type CachedObjMeta struct {
	Meta             *informer.ObjectMeta
	ServiceName      string
	ServiceNamespace string
	OTELResourceMeta map[attr.Name]string
}

type MetaSourceLabels

type MetaSourceLabels struct {
	ServiceName      string `yaml:"service_name" env:"BEYLA_KUBE_META_SOURCE_LABEL_SERVICE_NAME"`
	ServiceNamespace string `yaml:"service_namespace" env:"BEYLA_KUBE_META_SOURCE_LABEL_SERVICE_NAMESPACE"`
}

MetaSourceLabels allow overriding some metadata from kubernetes labels Deprecated. Left here for backwards-compatibility.

type MetadataConfig

type MetadataConfig struct {
	Enable            kubeflags.EnableFlag
	DisabledInformers []string
	KubeConfigPath    string
	SyncTimeout       time.Duration
	ResyncPeriod      time.Duration
	MetaCacheAddr     string
	ResourceLabels    ResourceLabels
	RestrictLocalNode bool
}

type MetadataProvider

type MetadataProvider struct {
	// contains filtered or unexported fields
}

func NewMetadataProvider

func NewMetadataProvider(config MetadataConfig) *MetadataProvider

func (*MetadataProvider) CurrentNodeName

func (mp *MetadataProvider) CurrentNodeName(ctx context.Context) (string, error)

func (*MetadataProvider) ForceDisable

func (mp *MetadataProvider) ForceDisable()

func (*MetadataProvider) Get

func (mp *MetadataProvider) Get(ctx context.Context) (*Store, error)

func (*MetadataProvider) IsKubeEnabled

func (mp *MetadataProvider) IsKubeEnabled() bool

func (*MetadataProvider) KubeClient

func (mp *MetadataProvider) KubeClient() (kubernetes.Interface, error)

type OTelServiceNamePair

type OTelServiceNamePair struct {
	Name      string
	Namespace string
}

type ResourceLabels

type ResourceLabels map[string][]string

type Store

type Store struct {

	// Instead of subscribing to the informer directly, the rest of components
	// will subscribe to this store, to make sure that any "new object" notification
	// they receive is already present in the store
	meta.BaseNotifier
	// contains filtered or unexported fields
}

Store aggregates Kubernetes information from multiple sources: - the informer that keep an indexed copy of the existing pods and replicasets. - the inspected container.Info objects, indexed either by container ID and PID namespace - a cache of decorated PodInfo that would avoid reconstructing them on each trace decoration

func NewStore

func NewStore(kubeMetadata meta.Notifier, resourceLabels ResourceLabels) *Store

func (*Store) AddProcess

func (s *Store) AddProcess(pid uint32)

func (*Store) DeleteProcess

func (s *Store) DeleteProcess(pid uint32)

func (*Store) ID

func (s *Store) ID() string

func (*Store) ObjectMetaByIP

func (s *Store) ObjectMetaByIP(ip string) *CachedObjMeta

func (*Store) On

func (s *Store) On(event *informer.Event) error

On is invoked by the informer when a new Kube object is created, updated or deleted. It will forward the notification to all the Store subscribers

func (*Store) PodByContainerID

func (s *Store) PodByContainerID(cid string) *CachedObjMeta

func (*Store) PodContainerByPIDNs

func (s *Store) PodContainerByPIDNs(pidns uint32) (*CachedObjMeta, string)

PodContainerByPIDNs second return value: container Name

func (*Store) ServiceNameNamespaceForIP

func (s *Store) ServiceNameNamespaceForIP(ip string) (string, string)

ServiceNameNamespaceForIP returns the service name and namespace for a given IP address This means that, for a given Pod, we will not return the Pod Name, but the Pod Owner Name

func (*Store) ServiceNameNamespaceForMetadata

func (s *Store) ServiceNameNamespaceForMetadata(om *informer.ObjectMeta) (string, string)

func (*Store) Subscribe

func (s *Store) Subscribe(observer meta.Observer)

Subscribe overrides BaseNotifier to send a "welcome message" to each new observer containing the whole metadata store

Jump to

Keyboard shortcuts

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