How to set up DataDog in Kubernetes with Maestro

  1. Configure our Kubernetes permissions to allow DataDog to access the application
  2. Add the DataDog agent to the application as a DaemonSet
  3. Re-deploy our application

Configure RBAC permissions

sudo su export KUBECONFIG=/etc/kubernetes/admin.conf
namespace: default
namespace: NAME_OF_NAMESPACE
kubectl create -f clusterrole.yaml kubectl create -f serviceaccount.yaml kubectl create -f clusterrolebinding.yaml

Set up a DaemonSet containing the DataDog configuration

service:   datadog:     image: datadog/agent:latest     type: daemon_set     service_account_name: datadog-agent
  • We need to define the ports that DataDog will use
  • We need to add environment variables like the DataDog API key
  • We need to set constraints and health checks
  • We need to mount the volumes that DataDog will be tracking

Defining ports

services:   datadog:       image: datadog/agent:latest       type: daemon_set       service_account_name: datadog-agent       ports:       - container: 8126 tcp: 8126       - container: 8125 udp: 8125

Environment variables

  • DD_API_KEY — can be found in your Datadog account, under IntegrationsAPIsAPI Keys
  • DD_SITE — the Datadog site you use (either datadog.com or datadoghq.eu)
  • DD_COLLECT_KUBERNETES_EVENTS — set to true
  • DD_LEADER_ELECTION — set to true
  • KUBERNETES — set to true
  • DD_HEALTH_PORT — set to 5555
  • DD_APM_ENABLED — set to true
  • DD_LOGS_ENABLED — set to true
  • DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL — set to true
  • DD_AC_EXCLUDE: set to name:datadog-agent - this cuts down on the noise from the DataDog agent itself. If you want to see its activity you can remove it from the exclude list.
  • DD_KUBERNETES_KUBELET_HOST — you can fetch this dynamically using this variable as a value — "$(CLOUD66_HOST_IP)"
  • DD_KUBELET_TLS_VERIFY — set to false
services:   datadog:      image: datadog/agent:latest      type: daemon_set      service_account_name: datadog-agent      ports:      - container: 8126        tcp: 8126      - container: 8125        udp: 8125      env_vars:        DD_API_KEY: 5f86b5d87e41ba1f383a16f60bbd8ea0        DD_SITE: datadoghq.eu        DD_COLLECT_KUBERNETES_EVENTS: 'true'        DD_LEADER_ELECTION: 'true' KUBERNETES: 'true'        DD_HEALTH_PORT: '5555'        DD_APM_ENABLED: 'true'        DD_LOGS_ENABLED: 'true'        DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL: 'true'        DD_AC_EXCLUDE: name:datadog-agent        DD_KUBERNETES_KUBELET_HOST: "$(CLOUD66_HOST_IP)"        DD_KUBELET_TLS_VERIFY: 'false'

Constraints and health checks

services:   datadog:     image: datadog/agent:latest     type: daemon_set     service_account_name: datadog-agent     ports:     - container: 8126       tcp: 8126 

- container: 8125
udp: 8125 env_vars: DD_API_KEY: 5f86b5d87e41ba1f383a16f60bbd8ea0 DD_SITE: datadoghq.eu DD_COLLECT_KUBERNETES_EVENTS: 'true' DD_LEADER_ELECTION: 'true' KUBERNETES: 'true' DD_HEALTH_PORT: '5555' DD_APM_ENABLED: 'true' DD_LOGS_ENABLED: 'true' DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL: 'true' DD_AC_EXCLUDE: name:datadog-agent DD_KUBERNETES_KUBELET_HOST: "$(CLOUD66_HOST_IP)" DD_KUBELET_TLS_VERIFY: 'false' constraints: resources: memory: 256M cpu: 200 health: alive: type: http endpoint: "/health" success_threshold: 1 failure_threshold: 3 timeout: 5 initial_delay: 15 period: 15 port: 5555

Mounting volumes

services:   datadog:     image: datadog/agent:latest     type: daemon_set     service_account_name: datadog-agent     ports:     - container: 8126       tcp: 8126     - container: 8125       udp: 8125     env_vars:        DD_API_KEY: 5f86b5d87e41ba1f383a16f60bbd8ea0        DD_SITE: datadoghq.eu        DD_COLLECT_KUBERNETES_EVENTS: 'true'        DD_LEADER_ELECTION: 'true' KUBERNETES: 'true'        DD_HEALTH_PORT: '5555'        DD_APM_ENABLED: 'true'        DD_LOGS_ENABLED: 'true'        DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL: 'true'        DD_AC_EXCLUDE: name:datadog-agent        DD_KUBERNETES_KUBELET_HOST: "$(CLOUD66_HOST_IP)"          DD_KUBELET_TLS_VERIFY: 'false' 
constraints:
resources: memory: 256M cpu: 200 health: alive: type: http endpoint: "/health" success_threshold: 1 failure_threshold: 3 timeout: 5 initial_delay: 15 period: 15 port: 5555 volumes: - "/proc:/host/proc:ro" - "/var/run/docker.sock:/var/run/docker.sock" - "/sys/fs/cgroup:/host/sys/fs/cgroup:ro" - "/opt/datadog-agent/run:/opt/datadog-agent/run"

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cloud 66

Cloud 66

DevOps-as-a-Service to help developers build, deploy and maintain apps on any Cloud. Sign-up for a free trial by visting: www.cloud66.com