Installing the agent using Kubernetes on Google Container Engine (GKE)

If you are running Kubernetes >= 1.1.0. You can take advantage of DaemonSets to automatically deploy the Datadog Agent on all your nodes or specific nodes by using nodeSelectors. We provide a manifest to deploy the agent on the Installing on Kubernetes page.

However, Google Container Engine (GKE) does not currently support the Kubernetes Beta API in general, and more specifically does not have support for DaemonSets. You can use the one line install command to run the Agent as a regular docker container on each node you want to monitor.

docker run -d --name dd-agent -h `hostname` -v /var/run/docker.sock:/var/run/docker.sock -v /proc/:/host/proc/:ro -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro -e API_KEY=<your_api_key> datadog/docker-dd-agent:kubernetes

You will only want one agent per node. This can also be accomplished by using a ReplicationController with replicas = number of nodes and specifying the hostPort in the template spec. This prevents two Datadog agents from running on the same node. Here is the full template:

apiVersion: v1
kind: ReplicationController
metadata:
  name: dd-agent
spec:
  replicas: 5
  selector:
    app: dd-agent
  template:
    metadata:
      labels:
        app: dd-agent
      name: dd-agent
    spec:
      containers:
      - image: datadog/docker-dd-agent:kubernetes
        imagePullPolicy: Always
        name: dd-agent
        ports:
          - hostPort: 8125
            name: dogstatsdport
            containerPort: 8125
        env:
          - name: API_KEY
            value: <YOUR API KEY HERE>
        volumeMounts:
          - name: dockersocket
            mountPath: /var/run/docker.sock
          - name: procdir
            mountPath: /host/proc
            readOnly: true
          - name: cgroups
            mountPath: /host/sys/fs/cgroup
            readOnly: true
      volumes:
        - hostPath:
            path: /var/run/docker.sock
          name: dockersocket
        - hostPath:
            path: /proc
          name: procdir
        - hostPath:
            path: /sys/fs/cgroup
          name: cgroups


Special thanks to Andreas Heim for documenting the ReplicationController trick in this blog post!

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk