Documentation
¶
Overview ¶
Package feature provide the framework to manage Feature in a generic way.
Index ¶
- Constants
- func ApplyDDASharedDependencies(dda metav1.Object, ddaSpec *v2alpha1.DatadogAgentSpec, ddai metav1.Object, ...) error
- func ApplyProfileSharedConfigOverlays(dst, base, profile *v2alpha1.DatadogAgentSpec) error
- func BuildFeatures(dda metav1.Object, ddaSpec *v2alpha1.DatadogAgentSpec, ...) ([]Feature, []Feature, RequiredComponents, []ProviderSupportResult)
- func Register(id IDType, buildFunc BuildFunc) error
- func RegisterDDASharedDependencies(id IDType, dependency DDASharedDependenciesFunc) error
- func RegisterProfileSharedConfigOverlay(id IDType, overlay ProfileSharedConfigOverlayFunc) error
- type BuildFunc
- type ClusterAgentProviderAwareFeature
- type DDASharedDependenciesFunc
- type Feature
- type IDType
- type Options
- type PodTemplateManagers
- type ProfileSharedConfigOverlayFunc
- type ProviderAwareFeature
- type ProviderSupportResult
- type RequiredComponent
- type RequiredComponents
- type ResourceManagers
- type SupportLevel
Constants ¶
const ( // DefaultIDType enable default component feature. DefaultIDType IDType = "default" // DogstatsdIDType Dogstatsd feature. DogstatsdIDType = "dogstatsd" // EventCollectionIDType Event Collection feature. EventCollectionIDType = "event_collection" // ExternalMetricsIDType External metrics feature. ExternalMetricsIDType = "external_metrics" // AutoscalingIDType Autoscaling feature. AutoscalingIDType = "autoscaling" // KubernetesStateCoreIDType Kubernetes state core check feature. KubernetesStateCoreIDType = "ksm" // LiveContainerIDType Live Container feature. LiveContainerIDType = "live_container" // LiveProcessIDType Live Process feature. LiveProcessIDType = "live_process" // OtelAgentIDType Otel Agent feature. OtelAgentIDType = "otel_agent" // OtelAgentGatewayIDType OTel Agent Gateway feature. OtelAgentGatewayIDType = "otel_agent_gateway" // HostProfilerIDType Host Profiler feature. HostProfilerIDType = "host_profiler" // ProcessDiscoveryIDType Process Discovery feature. ProcessDiscoveryIDType = "process_discovery" // KubernetesAPIServerIDType Kube APIServer feature. KubernetesAPIServerIDType = "kubernetes_apiserver" // OrchestratorExplorerIDType Orchestrator Explorer feature. OrchestratorExplorerIDType = "orchestrator_explorer" // LogCollectionIDType Log Collection feature. LogCollectionIDType = "log_collection" // NPMIDType NPM feature. NPMIDType = "npm" // CSPMIDType CSPM feature. CSPMIDType = "cspm" // CWSIDType CWS feature. CWSIDType = "cws" // USMIDType USM feature. USMIDType = "usm" // OOMKillIDType OOM Kill check feature OOMKillIDType = "oom_kill" // EBPFCheckIDType eBPF check feature EBPFCheckIDType = "ebpf_check" // PrometheusScrapeIDType Prometheus Scrape feature PrometheusScrapeIDType = "prometheus_scrape" // TCPQueueLengthIDType TCP Queue length check feature TCPQueueLengthIDType = "tcp_queue_length" // ClusterChecksIDType Cluster checks feature ClusterChecksIDType = "cluster_checks" // APMIDType APM feature APMIDType = "apm" // ASMIDType ASM feature ASMIDType = "asm" // AppsecIDType AppSec feature AppsecIDType = "appsec" // AdmissionControllerIDType Admission controller feature AdmissionControllerIDType = "admission_controller" // OTLPIDType OTLP ingest feature OTLPIDType = "otlp" // RemoteConfigurationIDType Remote Config feature RemoteConfigurationIDType = "remote_config" // SBOMIDType SBOM collection feature SBOMIDType = "sbom" // HelmCheckIDType Helm Check feature. HelmCheckIDType = "helm_check" // InstrumentationCRDIDType Instrumentation CRD feature. InstrumentationCRDIDType = "instrumentation_crd" // DummyIDType Dummy feature. DummyIDType = "dummy" // ServiceDiscoveryType service discovery feature. ServiceDiscoveryType = "service_discovery" // GPUIDType GPU monitoring feature. GPUIDType = "gpu" // ControlPlaneMonitoringIDType Control Plane Monitoring feature. ControlPlaneMonitoringIDType = "control_plane_monitoring" // PrivateActionRunnerIDType Private Action Runner feature. PrivateActionRunnerIDType = "private_action_runner" // DataPlaneIDType Data Plane feature. DataPlaneIDType = "data_plane" // FlightRecorderIDType Flight Recorder feature. FlightRecorderIDType = "flightrecorder" // KubernetesActionsIDType Kubernetes Actions feature. KubernetesActionsIDType = "kubernetes_actions" // DynamicInstrumentationIDType Dynamic Instrumentation feature. DynamicInstrumentationIDType = "dynamic_instrumentation" // CheckRunnerIDType Agent Check Runner feature. CheckRunnerIDType = "check_runner" )
Variables ¶
This section is empty.
Functions ¶
func ApplyDDASharedDependencies ¶ added in v1.29.0
func ApplyDDASharedDependencies(dda metav1.Object, ddaSpec *v2alpha1.DatadogAgentSpec, ddai metav1.Object, ddaiSpec *v2alpha1.DatadogAgentSpec, managers ResourceManagers) error
ApplyDDASharedDependencies applies all registered DDA shared dependency hooks for one rendered DDAI spec.
func ApplyProfileSharedConfigOverlays ¶ added in v1.29.0
func ApplyProfileSharedConfigOverlays(dst, base, profile *v2alpha1.DatadogAgentSpec) error
ApplyProfileSharedConfigOverlays applies all registered profile shared-component overlays to dst. The base spec is the original default DDAI spec before any profile overlays were applied; profile is the DatadogAgentProfile config.
func BuildFeatures ¶
func BuildFeatures(dda metav1.Object, ddaSpec *v2alpha1.DatadogAgentSpec, ddaRCStatus *v2alpha1.RemoteConfigConfiguration, options *Options) ([]Feature, []Feature, RequiredComponents, []ProviderSupportResult)
BuildFeatures use to build a list features depending of the v2alpha1.DatadogAgent instance. It also returns support level of each enabled feature for a given provider. The caller enforces it (block on Rejected, warn on Degraded); this function stays side-effect-free.
func RegisterDDASharedDependencies ¶ added in v1.29.0
func RegisterDDASharedDependencies(id IDType, dependency DDASharedDependenciesFunc) error
RegisterDDASharedDependencies registers DDA shared dependency logic for a feature.
func RegisterProfileSharedConfigOverlay ¶ added in v1.29.0
func RegisterProfileSharedConfigOverlay(id IDType, overlay ProfileSharedConfigOverlayFunc) error
RegisterProfileSharedConfigOverlay registers profile shared-component merge logic for a feature.
Types ¶
type BuildFunc ¶
BuildFunc function type used by each Feature during its factory registration. It returns the Feature interface.
type ClusterAgentProviderAwareFeature ¶ added in v1.29.0
type ClusterAgentProviderAwareFeature interface {
Feature
ClusterAgentProviderCapabilities() providercaps.ProviderCapabilityMap
}
ClusterAgentProviderAwareFeature is an optional interface for features that vary cluster agent behaviour by provider. The reconciler applies the returned capabilities by calling providercaps.ApplyProviderCapabilities after the feature's ManageClusterAgent runs.
type DDASharedDependenciesFunc ¶ added in v1.29.0
type DDASharedDependenciesFunc func(dda metav1.Object, ddaSpec *v2alpha1.DatadogAgentSpec, ddai metav1.Object, ddaiSpec *v2alpha1.DatadogAgentSpec, managers ResourceManagers) error
DDASharedDependenciesFunc lets a feature contribute DDA-owned dependencies that have one desired instance shared by all rendered DDAIs. The ddai/ddaiSpec arguments are read-only inputs.
type Feature ¶
type Feature interface {
// ID returns the ID of the Feature
ID() IDType
// Configure use to configure the internal of a Feature
// It should return `true` if the feature is enabled, else `false`.
Configure(ddaMetaObj metav1.Object, ddaSpec *v2alpha1.DatadogAgentSpec, ddaRCStatus *v2alpha1.RemoteConfigConfiguration) RequiredComponents
// ManageDependencies allows a feature to manage its dependencies.
// Feature's dependencies should be added in the store.
ManageDependencies(managers ResourceManagers) error
// ManageClusterAgent allows a feature to configure the ClusterAgent's corev1.PodTemplateSpec
// It should do nothing if the feature doesn't need to configure it.
ManageClusterAgent(managers PodTemplateManagers) error
// ManageNodeAgent allows a feature to configure the Node Agent's corev1.PodTemplateSpec
// It should do nothing if the feature doesn't need to configure it.
ManageNodeAgent(managers PodTemplateManagers) error
// ManageSingleContainerNodeAgent allows a feature to configure the Agent container for the Node Agent's corev1.PodTemplateSpec
// if SingleContainerStrategy is enabled and can be used with the configured feature set.
// It should do nothing if the feature doesn't need to configure it.
ManageSingleContainerNodeAgent(managers PodTemplateManagers) error
// ManageClusterChecksRunner allows a feature to configure the ClusterChecksRunnerAgent's corev1.PodTemplateSpec
// It should do nothing if the feature doesn't need to configure it.
ManageClusterChecksRunner(managers PodTemplateManagers) error
// ManageOtelAgentGateway allows a feature to configure the OtelAgentGateway's corev1.PodTemplateSpec
// It should do nothing if the feature doesn't need to configure it.
ManageOtelAgentGateway(managers PodTemplateManagers) error
}
Feature interface
Provider awareness: features that need the cluster provider should read it once in Configure (from the DDA/DDAI metadata annotation providercaps.ProviderAnnotationKey) and stash it on a feature struct field. Per-component declarative provider mutations should go through NodeAgentProviderCapabilities, applied by the reconciler.
type Options ¶
type Options struct {
Logger logr.Logger
// Client is a read-only Kubernetes client for feature code that needs live
// cluster state while building dependencies. Callers should pass an uncached
// reader when the feature may read outside the controller cache scope.
Client client.Reader
// PlatformInfo contains Kubernetes version and API discovery data for feature
// code that needs cluster capabilities while configuring pod templates.
PlatformInfo kubernetes.PlatformInfo
DefaultDataPlaneEnabled bool
}
Options option that can be pass to the Interface.Configure function
type PodTemplateManagers ¶
type PodTemplateManagers interface {
// PodTemplateSpec used to access directly the PodTemplateSpec.
PodTemplateSpec() *corev1.PodTemplateSpec
// EnvVar used to access the EnvVarManager to manage the Environment variable defined in the PodTemplateSpec.
EnvVar() merger.EnvVarManager
// EnvVarFrom used to access the EnvVarFromManager to manage the Environment variable defined in the PodTemplateSpec.
EnvFromVar() merger.EnvFromVarManager
// Volume used to access the VolumeManager to manage the Volume defined in the PodTemplateSpec.
Volume() merger.VolumeManager
// VolumeMount used to access the VolumeMountManager to manage the VolumeMount defined in the PodTemplateSpec.
VolumeMount() merger.VolumeMountManager
// SecurityContext is used to access the SecurityContextManager to manage container Security Context defined in the PodTemplateSpec.
SecurityContext() merger.SecurityContextManager
// Annotation is used access the AnnotationManager to manage PodTemplateSpec annotations.
Annotation() merger.AnnotationManager
// Ports used to access PortManager that allows to manage the Ports defined in the PodTemplateSpec.
Port() merger.PortManager
}
PodTemplateManagers used to access the different PodTemplateSpec manager.
func NewPodTemplateManagers ¶
func NewPodTemplateManagers(podTmpl *corev1.PodTemplateSpec) PodTemplateManagers
NewPodTemplateManagers use to create a new instance of PodTemplateManagers from a corev1.PodTemplateSpec argument
type ProfileSharedConfigOverlayFunc ¶ added in v1.29.0
type ProfileSharedConfigOverlayFunc func(dst, base, profile *v2alpha1.DatadogAgentSpec) error
ProfileSharedConfigOverlayFunc lets a feature lift profile config into shared components owned by the default DDAI, such as the Cluster Agent or Cluster Checks Runner.
dst is the accumulated default DDAI spec for the current reconcile and may be mutated by the overlay. base is the original default DDAI spec before any profile overlays were applied, so overlays can distinguish base config from profile-contributed config when needed. profile is the current DatadogAgentProfile config being considered.
Example: a profile can enable APM SSI for one node group, but SSI is configured on the Cluster Agent. The APM overlay merges that profile SSI config into dst while leaving the profile-specific node Agent config on the profile DDAI.
type ProviderAwareFeature ¶ added in v1.28.0
type ProviderAwareFeature interface {
Feature
NodeAgentProviderCapabilities() providercaps.ProviderCapabilityMap
}
ProviderAwareFeature is an optional interface for features that vary behaviour by provider. Features that have no provider-specific variation do not need to implement it. The reconciler applies the returned capabilities by calling providercaps.ApplyProviderCapabilities after the feature's ManageNodeAgent runs.
type ProviderSupportResult ¶ added in v1.30.0
type ProviderSupportResult struct {
ID IDType
Level SupportLevel
}
ProviderSupportResult is one feature's non-default support level on the active provider, carrying the feature ID for diagnostics.
func EvaluateProviderSupport ¶ added in v1.30.0
func EvaluateProviderSupport(features []Feature, provider string) []ProviderSupportResult
EvaluateProviderSupport returns one result per feature whose support level on the given provider is not Supported. Features that are Supported (or a nil/empty provider) yield no results.
type RequiredComponent ¶
type RequiredComponent struct {
IsRequired *bool
Containers []common.AgentContainerName
}
RequiredComponent is used to know if a component is required and which containers are required. If isRequired is set to:
- nil: the feature doesn't need the corresponding component. If the feature is disabled, isRequired should be nil.
- true: the feature needs the corresponding component.
- false: the component is disabled (only set in overrides).
If a feature is not enabled but needs to be configured, require at least one container.
func (*RequiredComponent) IsConfigured ¶
func (rc *RequiredComponent) IsConfigured() bool
IsConfigured returns true if the Feature does not require the RequiredComponent, but if it runs it needs to be configured appropriately.
func (*RequiredComponent) IsEnabled ¶
func (rc *RequiredComponent) IsEnabled() bool
IsEnabled returns true if the Feature needs the current RequiredComponent
func (*RequiredComponent) IsPrivileged ¶
func (rc *RequiredComponent) IsPrivileged() bool
IsPrivileged checks whether component requires privileged access.
func (*RequiredComponent) Merge ¶
func (rc *RequiredComponent) Merge(in *RequiredComponent) *RequiredComponent
Merge use to merge 2 RequiredComponents merge priority: false > true > nil *
func (*RequiredComponent) SingleContainerStrategyEnabled ¶
func (rc *RequiredComponent) SingleContainerStrategyEnabled() bool
type RequiredComponents ¶
type RequiredComponents struct {
ClusterAgent RequiredComponent
Agent RequiredComponent
ClusterChecksRunner RequiredComponent
OtelAgentGateway RequiredComponent
}
RequiredComponents use to know which component need to be enabled for the feature
func (*RequiredComponents) IsConfigured ¶
func (rc *RequiredComponents) IsConfigured() bool
IsConfigured returns true if any of the components need to be configured even if not enabled Can be used for features that may require configuration even when disabled Example: setting an env var to false to disable the feature
func (*RequiredComponents) IsEnabled ¶
func (rc *RequiredComponents) IsEnabled() bool
IsEnabled returns true if any of the components need to be enabled
func (*RequiredComponents) Merge ¶
func (rc *RequiredComponents) Merge(in *RequiredComponents) *RequiredComponents
Merge use to merge 2 RequiredComponents merge priority: false > true > nil *
type ResourceManagers ¶
type ResourceManagers interface {
Store() store.StoreClient
RBACManager() merger.RBACManager
SecretManager() merger.SecretManager
NetworkPolicyManager() merger.NetworkPolicyManager
ServiceManager() merger.ServiceManager
CiliumPolicyManager() merger.CiliumPolicyManager
ConfigMapManager() merger.ConfigMapManager
APIServiceManager() merger.APIServiceManager
}
ResourceManagers used to access the different resources manager.
func NewResourceManagers ¶
func NewResourceManagers(store store.StoreClient) ResourceManagers
NewResourceManagers return new instance of the ResourceManagers interface
type SupportLevel ¶ added in v1.30.0
type SupportLevel int
SupportLevel is the operator's response to a feature on a given provider.
const ( // Supported runs the feature normally. It is the zero value, so any provider // or feature absent from the matrix is Supported by default. Supported SupportLevel = iota // Degraded runs the feature but surfaces a warning: the provider does not // fully support it (mirrors a Helm warn-only notice). Degraded // Rejected blocks reconciliation: the feature cannot run on the provider // (mirrors a Helm hard-fail). Rejected // Excluded builds the agent WITHOUT the feature (its ManageNodeAgent hook is // skipped) while reconciliation continues. Used by providers that run a reduced // feature set on a subset of nodes, e.g. Windows (a shared spec still runs the // full set on Linux). Excluded )
func FeatureSupportLevel ¶ added in v1.30.0
func FeatureSupportLevel(provider string, id IDType) SupportLevel
FeatureSupportLevel returns the operator's response to feature id on the given provider: a per-feature override if present, otherwise the provider's default, otherwise Supported for providers with no policy.
Directories
¶
| Path | Synopsis |
|---|---|
|
Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. |
|
defaultconfig
package defaultconfig exposes the otel-agent default config in gateway
|
package defaultconfig exposes the otel-agent default config in gateway |
|
defaultconfig
package defaultconfig exposes the otel-agent default config
|
package defaultconfig exposes the otel-agent default config |