Skip to content

Instantly share code, notes, and snippets.

@marceloboeira
Created April 5, 2018 18:08
Show Gist options
  • Save marceloboeira/53a0b6d8c32c203b23d6d6621f7a9825 to your computer and use it in GitHub Desktop.
Save marceloboeira/53a0b6d8c32c203b23d6d6621f7a9825 to your computer and use it in GitHub Desktop.
DataDog Kubernetes Daemonset with APM Agent, Logs enabled and a custom config.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: datadog
namespace: kube-system
data:
default-config: |-
# Autodiscovery
listeners:
- name: kubelet
config_providers:
# The kubelet provider handles templates embedded in pod annotations, see
# https://docs.datadoghq.com/guides/autodiscovery/#template-source-kubernetes-pod-annotations
- name: kubelet
polling: true
# https://app.datadoghq.com/logs/onboarding/container
logs:
- type: docker
service: docker
tags: environment:{{environment}}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: datadog-agent
namespace: kube-system
spec:
template:
metadata:
labels:
app: datadog-agent
name: datadog-agent
spec:
containers:
- image: datadog/agent:latest
imagePullPolicy: Always
name: datadog-agent
ports:
- containerPort: 8125
name: dogstatsdport
protocol: UDP
- containerPort: 8126
name: dogapmport
protocol: TCP
env:
- name: DD_API_KEY
valueFrom:
secretKeyRef:
name: datadog
key: api_key
- name: DD_COLLECT_KUBERNETES_EVENTS
value: "true"
- name: DD_APM_ENABLED
value: "true"
- name: DD_LOGS_ENABLED
value: "true"
- name: KUBERNETES
value: "yes"
- name: SD_BACKEND
value: docker
- name: TAGS
value: environment={{environment}}
volumeMounts:
- name: dockersocket
mountPath: /var/run/docker.sock
- name: procdir
mountPath: /host/proc
readOnly: true
- name: cgroups
mountPath: /host/sys/fs/cgroup
readOnly: true
- name: pointdir
mountPath: /opt/datadog-agent/run
readOnly: true
- name: datadog-agent-config
mountPath: /conf.d
readOnly: true
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
volumes:
- name: dockersocket
hostPath:
path: /var/run/docker.sock
- name: procdir
hostPath:
path: /proc
- name: cgroups
hostPath:
path: /sys/fs/cgroup
- name: pointdir
hostPath:
path: /opt/datadog-agent/run
- name: datadog-agent-config
configMap:
name: datadog
items:
- key: default-config
path: default.yaml
---
apiVersion: v1
kind: Service
metadata:
labels:
app: datadog-statsd
name: datadog-statsd
namespace: kube-system
spec:
ports:
- name: dogstatsd
port: 8125
targetPort: dogstatsdport
protocol: UDP
selector:
app: datadog-agent
---
apiVersion: v1
kind: Service
metadata:
labels:
app: datadog-apm
name: datadog-apm
namespace: kube-system
spec:
ports:
- name: dogapmport
port: 8126
targetPort: dogapmport
protocol: TCP
selector:
app: dadadog-agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment