Skip to content

[BUG] datadog-cluster-agent sidecar injection could prevent CreateContainerConfigError related to datadog-agent secret missing #52899

Description

@frimik

Agent version

7.80.0

Bug Report

TL;DR - It would be helpful, for the cluster-agent to check the configuration conditions, including existence of datadog-agent Secret best as possible before injecting ...

When a pod has labels:

agent.datadoghq.com/sidecar: fargate

It will inject a datadog-agent-injected sidecar.

Some of the related things are fine if they are missing or misconfigured. It will only make the sidecar complain about permissions issues. These involved RBAC-related issues.

But if the Secret called datadog-agent isn't there, there will be a "fatal" CreateContainerConfigError and the entire Pod will not come up at all. Big oopsie if we're talking about for example coredns or similar.

Related to security in the cluster I think it wouldn't be a big issue either, as it would be a simple rbac permission:

- apiGroups: [""]
  resources: ["secrets"]
  resourceNames: ["datadog-secret"]
  verbs: ["get"]

Anyway. It's just a sanitary, helpful thing as usually secrets come from external sources or processes (external-secrets operator for example) ... and sometimes unfavourable things happen.

Reproduction Steps

No response

Agent configuration

values:

clusterAgent:
  admissionController:
    agentSidecarInjection:
      profiles:
        - env:
            - name: DD_DISABLE_CLUSTER_NAME_TAG_KEY
              value: "true"
          resources:
            limits:
              cpu: "2"
              memory: 1024Mi
            requests:
              cpu: "1"
              memory: 512Mi
    configMode: hostip
    mutateUnlabelled: true
  tokenExistingSecret: datadog-secret

Operating System

No response

Other environment details

Amazon EKS with some Fargate Pods

Metadata

Metadata

Assignees

No one assigned

    Labels

    oss/0External contributions priority 0pendingLabel for issues waiting a Datadog member's response.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions