Last active
April 28, 2019 13:50
-
-
Save rdonkin/b60593c5a5f0cd54db36447290fe9ced to your computer and use it in GitHub Desktop.
datadog agent config as Daemonset delete example for Ansible k8s issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cluster role for Datadog agent | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRole | |
metadata: | |
name: datadog-agent | |
rules: | |
- apiGroups: | |
- "" | |
resources: | |
- services | |
- events | |
- endpoints | |
- pods | |
- nodes | |
- componentstatuses | |
verbs: | |
- get | |
- list | |
- watch | |
- apiGroups: | |
- "" | |
resources: | |
- configmaps | |
resourceNames: | |
- datadogtoken # Kubernetes event collection state | |
- datadog-leader-election # Leader election token | |
verbs: | |
- get | |
- update | |
- apiGroups: # To create the leader election token | |
- "" | |
resources: | |
- configmaps | |
verbs: | |
- create | |
- nonResourceURLs: | |
- "/version" | |
- "/healthz" | |
verbs: | |
- get | |
- apiGroups: # Kubelet connectivity | |
- "" | |
resources: | |
- nodes/metrics | |
- nodes/spec | |
- nodes/proxy | |
verbs: | |
- get | |
--- | |
# Service account for the datadog-agent DaemonSet | |
kind: ServiceAccount | |
apiVersion: v1 | |
metadata: | |
name: datadog-agent | |
namespace: default | |
--- | |
# Admin user needs the same permissions to be able to grant them | |
# Easiest way is to bind the datadog-agent user to the cluster-admin role | |
# See https://cloud.google.com/container-engine/docs/role-based-access-control#setting_up_role-based_access_control | |
apiVersion: rbac.authorization.k8s.io/v1 | |
kind: ClusterRoleBinding | |
metadata: | |
name: datadog-agent | |
roleRef: | |
apiGroup: rbac.authorization.k8s.io | |
kind: ClusterRole | |
name: datadog-agent | |
subjects: | |
- kind: ServiceAccount | |
name: datadog-agent | |
namespace: default | |
--- | |
# DaemonSet for agents | |
apiVersion: extensions/v1beta1 | |
kind: DaemonSet | |
metadata: | |
name: datadog-agent | |
spec: | |
template: | |
metadata: | |
labels: | |
app: datadog-agent | |
name: datadog-agent | |
spec: | |
serviceAccountName: datadog-agent | |
containers: | |
- image: datadog/agent:latest | |
imagePullPolicy: Always | |
name: datadog-agent | |
ports: | |
# Custom metrics via DogStatsD | |
- containerPort: 8125 | |
hostPort: 8125 | |
name: dogstatsdport | |
protocol: UDP | |
# Trace Collection (APM) | |
- containerPort: 8126 | |
hostPort: 8126 | |
name: traceport | |
protocol: TCP | |
env: | |
- name: DD_API_KEY | |
value: XXX | |
- name: DD_SITE | |
value: "datadoghq.com" | |
- name: DD_COLLECT_KUBERNETES_EVENTS | |
value: "true" | |
- name: DD_LEADER_ELECTION | |
value: "true" | |
- name: KUBERNETES | |
value: "true" | |
- name: DD_KUBERNETES_KUBELET_HOST | |
valueFrom: | |
fieldRef: | |
fieldPath: status.hostIP | |
- name: DD_APM_ENABLED | |
value: "true" | |
- name: DD_APM_NON_LOCAL_TRAFFIC | |
value: "true" | |
- name: DD_LOG_LEVEL | |
value: "debug" | |
resources: | |
requests: | |
memory: "256Mi" | |
cpu: "200m" | |
limits: | |
memory: "256Mi" | |
cpu: "200m" | |
volumeMounts: | |
- name: dockersocket | |
mountPath: /var/run/docker.sock | |
- name: procdir | |
mountPath: /host/proc | |
readOnly: true | |
- name: cgroups | |
mountPath: /host/sys/fs/cgroup | |
readOnly: true | |
livenessProbe: | |
exec: | |
command: | |
- ./probe.sh | |
initialDelaySeconds: 15 | |
periodSeconds: 5 | |
volumes: | |
- hostPath: | |
path: /var/run/docker.sock | |
name: dockersocket | |
- hostPath: | |
path: /proc | |
name: procdir | |
- hostPath: | |
path: /sys/fs/cgroup | |
name: cgroups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment