Implement metadata injection inside operator#556
Open
ramkrishankumarN wants to merge 1 commit intomainfrom
Open
Implement metadata injection inside operator#556ramkrishankumarN wants to merge 1 commit intomainfrom
ramkrishankumarN wants to merge 1 commit intomainfrom
Conversation
|
Thank you for opening this pull request. We require pull request titles to follow the Conventional Commits specification. Your proposed title needs to be adjusted: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #556 +/- ##
==========================================
- Coverage 68.74% 66.11% -2.64%
==========================================
Files 53 55 +2
Lines 3513 3665 +152
==========================================
+ Hits 2415 2423 +8
- Misses 863 1002 +139
- Partials 235 240 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
(https://newrelic.atlassian.net/wiki/spaces/KOT/pages/5428150500/Using+k8s+agent+operator+for+Metadata+Injection)
Problem Statement
New Relic currently maintains two separate Kubernetes operators:
k8s-metadata-injection: Injects Kubernetes metadata (cluster, node, namespace, pod, container names) as environment variables to enable APM-to-infrastructure correlation
k8s-agents-operator: Auto-instruments pods with New Relic APM agents via init containers
Maintaining two separate webhooks creates operational complexity, potential conflicts, and duplicated effort. Especially with trivy tickets and other update related to go packages.
This project consolidates both functionalities into the k8s-agents-operator, allowing customers to use a single operator for both metadata injection and agent instrumentation.
User Requirements
Opt-in model: Metadata injection disabled by default, explicitly enabled via environment variable
Environment variable configuration: Cluster name configured via K8S_CLUSTER_NAME environment variable
Complete replacement: k8s-metadata-injection repository will be deprecated after this implementation
Backward compatibility: Existing agent injection functionality must remain unchanged
Namespace filtering: Support ignore lists and label-based filtering
Independent operation: Metadata injection should work with or without agent injection
Metadata Environment Variables
The following 7 environment variables will be injected (matching k8s-metadata-injection):
NEW_RELIC_METADATA_KUBERNETES_CLUSTER_NAME (from config)
NEW_RELIC_METADATA_KUBERNETES_NODE_NAME (downward API: spec.nodeName)
NEW_RELIC_METADATA_KUBERNETES_NAMESPACE_NAME (downward API: metadata.namespace)
NEW_RELIC_METADATA_KUBERNETES_POD_NAME (downward API: metadata.name)
NEW_RELIC_METADATA_KUBERNETES_DEPLOYMENT_NAME (derived from generateName)
NEW_RELIC_METADATA_KUBERNETES_CONTAINER_NAME (static: container name)
NEW_RELIC_METADATA_KUBERNETES_CONTAINER_IMAGE_NAME (static: container image)
Architecture Approach
New PodMutator Implementation
Create a separate MetadataInjectionPodMutator that implements the existing PodMutator interface. This provides:
Clean separation of concerns (metadata vs agent injection)
Ability to enable/disable independently
Runs first in the mutator chain (before agent injection)
No CRD dependencies (configuration via environment variables only)
Type of change
Checklist: