Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datadog): RBAC for resources labels/annotations as tags #1685

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jscaltreto
Copy link

What this PR does / why we need it:

This fixes two issues with how the chart it rendered when datadog.kubernetesResourcesAnnotationsAsTags and/or datadog.kubernetesResourcesLabelsAsTags are used:

  • Keys with more than 1 . were incorrectly rendered, as is frequently used with CRDs.
  • When both labels and annotations are specified, the labels map is merged into DD_KUBERNETES_RESOURCES_ANNOTATIONS_AS_TAGS

Which issue this PR fixes

Special notes for your reviewer:

I verified the fix using helm template and the following values:

datadog:
  kubernetesResourcesAnnotationsAsTags:
    pods:
      some-annotation: "some-value"
    deployments.apps:
      another-annotation: "another-value"
    customs.example.com:
      custom-annotation: "custom-value"
  kubernetesResourcesLabelsAsTags:
    services:
      some-label: "some-value"
    statefulsets.apps:
      another-label: "another-value"
    anotercustoms.example.com:
      custom-label: "custom-value"

The RBAC rules were correctly rendered as:

rules:

# Iterate through the apiGroups and create rules for each resource
- apiGroups:
  - ""
  resources:
  - pods
  - services
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - "apps"
  resources:
  - deployments
  - statefulsets
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - "example.com"
  resources:
  - anotercustoms
  - customs
  verbs:
  - get
  - list
  - watch

And the cluster-agent env vars are correct:

- name: DD_KUBERNETES_RESOURCES_LABELS_AS_TAGS
  value: '{"anotercustoms.example.com":{"custom-label":"custom-value"},"services":{"some-label":"some-value"},"statefulsets.apps":{"another-label":"another-value"}}'
- name: DD_KUBERNETES_RESOURCES_ANNOTATIONS_AS_TAGS
  value: '{"customs.example.com":{"custom-annotation":"custom-value"},"deployments.apps":{"another-annotation":"another-value"},"pods":{"some-annotation":"some-value"}}'

Checklist

  • Chart Version bumped
  • Documentation has been updated with helm-docs (run: .github/helm-docs.sh)
  • CHANGELOG.md has been updated

@jscaltreto jscaltreto requested a review from a team as a code owner February 2, 2025 14:43
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.

Resources labels/annotations as tags renders invalid RBAC rules
1 participant