agent

package
v0.18.0 Latest Latest
Warning

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

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

Documentation

Overview

Package agent implements injection of infrastructure-agent container into given Pod.

Index

Constants

View Source
const (
	// DisableInjectionLabel is the name of the label to prevent agent sidecar injection.
	DisableInjectionLabel = "infra-operator.newrelic.com/disable-injection"

	// InjectedLabel is the name of the label injected in pod.
	InjectedLabel = "infra-operator.newrelic.com/agent-injected"

	// ClusterRoleBindingSuffix is the expected suffix on pre-created ClusterRoleBinding. It will be combined
	// with configured resource prefix.
	ClusterRoleBindingSuffix = "-infra-agent"

	// LicenseSecretSuffix is the suffix which will be added to created license Secret objects, combined with
	// configured resource prefix.
	LicenseSecretSuffix = "-config"

	// LicenseSecretKey is the key which under the license key is placed in license Secret object.
	LicenseSecretKey = "license"

	// AgentSidecarName is the name of the container injected.
	AgentSidecarName = "newrelic-infrastructure-sidecar"
)
View Source
const (
	// OperatorCreatedLabel is the name of the label injected to the secrets created by the operator.
	OperatorCreatedLabel = "infra-operator.newrelic.com/created"
	// OperatorCreatedLabelValue is the value of the label injected to the secrets created by the operator.
	OperatorCreatedLabelValue = "true"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigSelector added in v0.2.0

type ConfigSelector struct {
	ResourceRequirements *corev1.ResourceRequirements `json:"resourceRequirements"`
	ExtraEnvVars         map[string]string            `json:"extraEnvVars"`
	LabelSelector        metav1.LabelSelector         `json:"labelSelector"`
	// contains filtered or unexported fields
}

ConfigSelector allows you to set resourceRequirements and extraEnvVars based on labels.

type CustomAttribute added in v0.2.0

type CustomAttribute struct {
	Name         string `json:"name"`
	DefaultValue string `json:"defaultValue"`
	FromLabel    string `json:"fromLabel"`
}

CustomAttribute represents single custom attribute which will be reported by infrastructure-agent.

It's value can be taken from Pod label. If label is not present, default value will be used.

If default value is empty as well, error will be returned.

type CustomAttributes added in v0.2.0

type CustomAttributes []CustomAttribute

CustomAttributes represents collection of custom attributes.

type Image added in v0.2.0

type Image struct {
	Repository string            `json:"repository"`
	Tag        string            `json:"tag"`
	PullPolicy corev1.PullPolicy `json:"pullPolicy"`
}

Image config.

type InfraAgentConfig added in v0.2.0

type InfraAgentConfig struct {
	// Here we can map the whole user configuration from helm chart.
	ConfigSelectors    []ConfigSelector   `json:"configSelectors"`
	Image              Image              `json:"image"`
	PodSecurityContext PodSecurityContext `json:"podSecurityContext"`
	CustomAttributes   CustomAttributes   `json:"customAttributes"`
}

InfraAgentConfig holds the user's configuration for the sidecar to be injected.

type InjectionPolicy added in v0.2.0

type InjectionPolicy struct {
	NamespaceName     string                `json:"namespaceName"`
	NamespaceSelector *metav1.LabelSelector `json:"namespaceSelector"`
	PodSelector       *metav1.LabelSelector `json:"podSelector"`
	// contains filtered or unexported fields
}

InjectionPolicy represents injection policy, which defines if given Pod should have agent injected or not.

type Injector

type Injector interface {
	Mutate(ctx context.Context, pod *corev1.Pod, requestOptions webhook.RequestOptions) error
}

Injector injects New Relic infrastructure-agent into given pod, ensuring that it has all capabilities to run like right permissions and access to the New Relic license key.

type InjectorConfig added in v0.2.0

type InjectorConfig struct {
	AgentConfig    InfraAgentConfig  `json:"agentConfig"`
	ResourcePrefix string            `json:"resourcePrefix"`
	License        string            `json:"-"`
	ClusterName    string            `json:"clusterName"`
	Policies       []InjectionPolicy `json:"policies"`
}

InjectorConfig of the Injector used to pass the required data to build it.

func (InjectorConfig) New added in v0.2.0

func (config InjectorConfig) New(client, noCacheClient client.Client, logger *logrus.Logger) (Injector, error)

New function is the constructor for the injector struct.

type PodSecurityContext added in v0.2.0

type PodSecurityContext struct {
	RunAsUser  int64 `json:"runAsUser"`
	RunAsGroup int64 `json:"runAsGroup"`
}

PodSecurityContext config.

Jump to

Keyboard shortcuts

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