For Kubernetes, it’s recommended to run the Agent in a DaemonSet. A Docker image is available with both the Docker and the Kubernetes integrations enabled.
Thanks to Kubernetes, you can take advantage of DaemonSets to automatically deploy the Datadog Agent on all your nodes (or on specific nodes by using nodeSelectors).
If DaemonSets are not an option for your Kubernetes cluster, install the Datadog Agent as a deployment on each Kubernetes node.
Note: This manifest enables the Autodiscovery, auto-configuration feature. To disable it, remove the SD_BACKEND environment variable definition. To learn how to configure Autodiscovery, see the Autodiscovery documentation.
To verify the Datadog Agent is running in your environment as a DaemonSet, execute:
kubectl get daemonset
If the Agent is deployed, a similar output to the text below is displayed, where desired and current are equal to the number of nodes running in your cluster.
NAME DESIRED CURRENT NODE-SELECTOR AGE
dd-agent 3 3 <none> 11h
If you are running Kubernetes >= 1.2.0, you can use the kube-state-metrics project to provide additional metrics (identified by the kubernetes_state prefix in the metrics list below) to Datadog.
To run kube-state-metrics, create a kube-state-metrics.yaml file using the following manifest to deploy the kube-state-metrics service:
The manifest above uses Google’s publicly available kube-state-metrics container, which is also available on Quay. If you want to build it manually, see the official project documentation.
If you configure your Kubernetes State Metrics service to run on a different URL or port, you can configure the Datadog Agent by setting the kube_state_url parameter in conf.d/kubernetes_state.yaml, then restarting the Agent.
For more information, see the kubernetes_state.yaml.example file. If you have enabled Autodiscovery, the kube state URL is configured and managed automatically.
Install the dd-check-kubernetes_state package manually or with your favorite configuration manager (On CentOS/AWS, download the rpm package and see the installation instructions.
Then edit the kubernetes_state.yaml file to point to your server and port and set the masters to monitor. See the example kubernetes_state.yaml for all available configuration options.
To verify the Datadog Agent is running in your environment as a DaemonSet, execute:
kubectl get daemonset
If the Agent is deployed, you receive a similar output to the text below, where desired and current are equal to the number of running nodes in your cluster.
NAME DESIRED CURRENT NODE-SELECTOR AGE
dd-agent 33 <none> 11h
Edit the kube_dns.yaml file to point to your server and port, set the masters to monitor. See the sample kube_dns.yaml for all available configuration options.
If you are using one dd-agent pod per Kubernetes worker node, you could use the following annotations on your kube-dns pod to retrieve the data automatically.
Notice the “dns-pod” tag keeps track of the target DNS pod IP. The other tags are related to the dd-agent that is polling the information using service discovery.
The service discovery annotations need to be applied to the pod. In case of a deployment, add the annotations to the metadata of the template’s spec.