metadata

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateMap

func GenerateMap(input map[string]string, dedot bool) mapstr.M

Types

type AddResourceMetadataConfig

type AddResourceMetadataConfig struct {
	Node       *config.C `config:"node"`
	Namespace  *config.C `config:"namespace"`
	Deployment bool      `config:"deployment"`
	CronJob    bool      `config:"cronjob"`
}

AddResourceMetadataConfig allows adding config for enriching additional resources

func GetDefaultResourceMetadataConfig

func GetDefaultResourceMetadataConfig() *AddResourceMetadataConfig

type ClusterConfiguration

type ClusterConfiguration struct {
	ControlPlaneEndpoint string `yaml:"controlPlaneEndpoint"`
	ClusterName          string `yaml:"clusterName"`
}

type ClusterInfo

type ClusterInfo struct {
	URL  string
	Name string
}

func GetKubernetesClusterIdentifier

func GetKubernetesClusterIdentifier(cfg *config.C, client k8sclient.Interface) (ClusterInfo, error)

GetKubernetesClusterIdentifier returns ClusterInfo for k8s if available

type Config

type Config struct {
	KubeConfig string `config:"kube_config"`

	UseRegexInclude    bool     `config:"use_regex_include"`
	UseRegexExclude    bool     `config:"use_regex_exclude"`
	IncludeLabels      []string `config:"include_labels"`
	ExcludeLabels      []string `config:"exclude_labels"`
	IncludeAnnotations []string `config:"include_annotations"`

	LabelsDedot      bool `config:"labels.dedot"`
	AnnotationsDedot bool `config:"annotations.dedot"`
}

Config declares supported configuration for metadata generation

func (*Config) InitDefaults

func (c *Config) InitDefaults()

InitDefaults initializes the defaults for the config.

func (*Config) Unmarshal

func (c *Config) Unmarshal(cfg *config.C) error

Unmarshal unpacks a Config into the metagen Config

type FieldOptions

type FieldOptions func(mapstr.M)

FieldOptions allows additional enrichment to be done on top of existing metadata

func WithFields

func WithFields(key string, value interface{}) FieldOptions

WithFields FieldOption allows adding specific fields into the generated metadata

func WithMetadata

func WithMetadata(kind string) FieldOptions

WithMetadata FieldOption allows adding labels and annotations under sub-resource(kind) example if kind=namespace namespace.labels key will be added

type MetaGen

type MetaGen interface {
	// Generate generates metadata for a given resource.
	// Metadata map is formed in the following format:
	// {
	//    "kubernetes": GenerateK8s(),
	//    "some.ecs.field": "asdf, // populated by GenerateECS()
	// }
	// This method is called in top level and returns the complete map of metadata.
	Generate(kubernetes.Resource, ...FieldOptions) mapstr.M
	// GenerateFromName generates metadata for a given resource based on it's name
	GenerateFromName(string, ...FieldOptions) mapstr.M
	// GenerateK8s generates kubernetes metadata for a given resource
	GenerateK8s(kubernetes.Resource, ...FieldOptions) mapstr.M
	// GenerateECS generates ECS metadata for a given resource
	GenerateECS(kubernetes.Resource) mapstr.M
}

MetaGen allows creation of metadata from either Kubernetes resources or their Resource names.

func GetPodMetaGen

func GetPodMetaGen(
	cfg *config.C,
	podWatcher kubernetes.Watcher,
	nodeWatcher kubernetes.Watcher,
	namespaceWatcher kubernetes.Watcher,
	replicasetWatcher kubernetes.Watcher,
	jobWatcher kubernetes.Watcher,
	metaConf *AddResourceMetadataConfig) MetaGen

GetPodMetaGen is a wrapper function that creates a metaGen for pod resource and has embeeded nodeMetaGen and namespaceMetaGen

func NewJobMetadataGenerator added in v0.6.1

func NewJobMetadataGenerator(cfg *config.C, jobs cache.Store, client k8s.Interface) MetaGen

NewJobMetadataGenerator creates a metagen for job resources

func NewNamespaceMetadataGenerator

func NewNamespaceMetadataGenerator(cfg *config.C, namespaces cache.Store, client k8s.Interface) MetaGen

NewNamespaceMetadataGenerator creates a metagen for namespace resources

func NewNodeMetadataGenerator

func NewNodeMetadataGenerator(cfg *config.C, nodes cache.Store, client k8s.Interface) MetaGen

NewNodeMetadataGenerator creates a metagen for service resources

func NewPodMetadataGenerator

func NewPodMetadataGenerator(
	cfg *config.C,
	pods cache.Store,
	client k8s.Interface,
	node MetaGen,
	namespace MetaGen,
	replicaset MetaGen,
	job MetaGen,
	addResourceMetadata *AddResourceMetadataConfig) MetaGen

NewPodMetadataGenerator creates a metagen for pod resources

func NewReplicasetMetadataGenerator added in v0.6.1

func NewReplicasetMetadataGenerator(cfg *config.C, replicasets cache.Store, client k8s.Interface) MetaGen

NewReplicasetMetadataGenerator creates a metagen for replicaset resources

func NewServiceMetadataGenerator

func NewServiceMetadataGenerator(cfg *config.C, services cache.Store, namespace MetaGen, client k8s.Interface) MetaGen

NewServiceMetadataGenerator creates a metagen for service resources

type Resource

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

Resource generates metadata for any kubernetes resource

func NewNamespaceAwareResourceMetadataGenerator added in v0.5.0

func NewNamespaceAwareResourceMetadataGenerator(cfg *config.C, client k8s.Interface, namespace MetaGen) *Resource

NewNamespaceAwareResourceMetadataGenerator creates a metadata generator with informatuon about namespace

func NewResourceMetadataGenerator

func NewResourceMetadataGenerator(cfg *config.C, client k8s.Interface) *Resource

NewResourceMetadataGenerator creates a metadata generator for a generic resource

func (*Resource) Generate

func (r *Resource) Generate(kind string, obj kubernetes.Resource, opts ...FieldOptions) mapstr.M

Generate generates metadata from a resource object Generate method returns metadata in the following form:

{
	  "kubernetes": {},
   "ecs.a.field": 42,
}

This method should be called in top level and not as part of other metadata generators. For retrieving metadata without 'kubernetes.' prefix one should call GenerateK8s instead.

func (*Resource) GenerateECS

func (r *Resource) GenerateECS(obj kubernetes.Resource) mapstr.M

GenerateECS generates ECS metadata from a resource object

func (*Resource) GenerateK8s

func (r *Resource) GenerateK8s(kind string, obj kubernetes.Resource, options ...FieldOptions) mapstr.M

GenerateK8s takes a kind and an object and creates metadata for the same

Jump to

Keyboard shortcuts

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