Skip to content

Conversation

@michaelprice232
Copy link

@michaelprice232 michaelprice232 commented Oct 31, 2025

Description

Aims to resolve: #1321

Adds support for generating K8sContainerSample data from K8s sidecars which has been GA since v1.33. Sidecars run for the lifetime of the pod so there will likely be a requirement to monitor them moving forward. The solution ignores standard init containers.

Please let me know if any docs or examples need to be updated.

Also fixed a minor bug in the development env whereby Tilt was unable to dynamically reload the app by copying the binary into the running container as the Helm chart was defaulting to a readonly filesystem:

tar: can't remove old file usr/local/bin/nri-kubernetes: Read-only file system

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • New feature / enhancement (non-breaking change which adds functionality)
  • Security fix
  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • Add changelog entry following the contributing guide
  • Documentation has been updated
  • This change requires changes in testing:
    • unit tests
    • E2E tests

Testing

Tested using the local dev setup and ensuring the K8sContainerSample data was being ingested into New Relic and visible on the default K8s views.

Example deployment with sidecar:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app
  labels:
    app: app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app
  template:
    metadata:
      labels:
        app: app
    spec:
      containers:
        - name: app
          image: alpine:latest
          command: ['sh', '-c', 'while true; do echo "logging" >> /opt/logs.txt; sleep 1; done']
          resources:
            requests:
              cpu: 10m
              memory: 20Mi
            limits:
              cpu: 100m
              memory: 100Mi
          volumeMounts:
            - name: data
              mountPath: /opt
      initContainers:
        - name: logshipper
          image: alpine:latest
          restartPolicy: Always  # sidecar
          command: ['sh', '-c', 'tail -F /opt/logs.txt']
          resources:
            requests:
              cpu: 10m
              memory: 20Mi
            limits:
              cpu: 100m
              memory: 100Mi
          volumeMounts:
            - name: data
              mountPath: /opt
      volumes:
        - name: data
          emptyDir: {}

Data in New Relic:
Screenshot 2025-11-04 at 15 51 13

The Helm chart defaults to RO. This was stopping Tilt from live reloading the binary in the running container:

tar: can't remove old file usr/local/bin/nri-kubernetes: Read-only file system
@michaelprice232 michaelprice232 requested a review from a team as a code owner October 31, 2025 14:44
@CLAassistant
Copy link

CLAassistant commented Oct 31, 2025

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for collecting K8sContainerSample metrics from K8s sidecar containers

2 participants