agent

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

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

Agent provides access to configuration stored as custom resources.

Configuration custom resources can be defined per node, per group or as a default resource. These are named 'node.$NODE_NAME', 'group.$GROUP_NAME', and 'default' respectively. If a node-specific configuration exists, it is always used for the node. Otherwise either a group-specific or the default configuration is used depending on whether the node belongs to a group. A node can be assigned to a group by setting the group label on the node. By default this group label is 'config.nri/group'.

func New

func New(cfgIf ConfigInterface, options ...Option) (*Agent, error)

New creates an agent with the given options.

func (*Agent) Start

func (a *Agent) Start(notifyFn NotifyFn) error

func (*Agent) Stop

func (a *Agent) Stop()

func (*Agent) UpdateNrtCR

func (a *Agent) UpdateNrtCR(policy string, zones []*policyapi.TopologyZone) error

UpdateNrtCR updates the node's node resource topology CR using the given data.

type ConfigInterface

type ConfigInterface interface {
	// Set the preferred client and configuration for cluster/apiserver access.
	SetKubeClient(cli *http.Client, cfg *rest.Config) error
	// Create a watch for monitoring the named custom resource.
	CreateWatch(ctx context.Context, namespace, name string) (watch.Interface, error)
	// Patch the status subresource of the named custom resource.
	PatchStatus(ctx context.Context, namespace, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions) error
	// Unmarshal custom resource which was read from the given file.
	Unmarshal(data []byte, file string) (runtime.Object, error)
}

ConfigInterface is used by the agent to access config custom resources.

func BalloonsConfigInterface

func BalloonsConfigInterface() ConfigInterface

BalloonsConfigInterface returns a ConfigInterface for the balloons policy.

func TemplateConfigInterface

func TemplateConfigInterface() ConfigInterface

TemplateConfigInterface returns a ConfigInterface for the template policy.

func TopologyAwareConfigInterface

func TopologyAwareConfigInterface() ConfigInterface

TopologyAwareConfigInterface returns a ConfigInterface for the topology-aware policy.

type NotifyFn

type NotifyFn func(cfg interface{}) error

NotifyFn is a function to call when the effective configuration changes.

type Option

type Option func(*Agent) error

Option is an option for the agent.

func WithConfigFile

func WithConfigFile(file string) Option

WithConfigFile sets up the agent to monitor a configuration file instead of custom resources.

func WithConfigGroupLabel

func WithConfigGroupLabel(label string) Option

WithConfigGroupLabel sets the key used to label nodes into config groups.

func WithConfigNamespace

func WithConfigNamespace(ns string) Option

WithConfigNamespace sets the namespace used for config custom resources.

func WithKubeConfig

func WithKubeConfig(kc string) Option

WithKubeConfig sets the location of the config file to use for K8s cluster access. An unset config file implies in-cluster configuration or lack of need for cluster access.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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