Skip to content

Commit 6108e5c

Browse files
authored
Merge pull request aws-samples#561 from CharlyF/datadog-workshop
Datadog workshop. Thanks for this awesome PR @CharlyF !!!
2 parents b23103f + 92a88ed commit 6108e5c

File tree

94 files changed

+1183
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1183
-0
lines changed

02-path-working-with-clusters/207-cluster-monitoring-with-datadog/readme.adoc

Lines changed: 402 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
apiVersion: extensions/v1beta1
2+
kind: DaemonSet
3+
metadata:
4+
name: dd-agent
5+
spec:
6+
template:
7+
metadata:
8+
labels:
9+
app: dd-agent
10+
name: dd-agent
11+
spec:
12+
containers:
13+
- image: datadog/agent:latest
14+
imagePullPolicy: Always
15+
name: dd-agent
16+
ports:
17+
- containerPort: 8125
18+
hostPort: 8125
19+
name: dogstatsdport
20+
protocol: UDP
21+
- containerPort: 8126
22+
name: traceport
23+
protocol: TCP
24+
env:
25+
- name: DD_API_KEY
26+
value: <DD_API_KEY>
27+
- name: KUBERNETES
28+
value: "yes"
29+
- name: DD_APM_ENABLED
30+
value: "true"
31+
- name: DD_PROCESS_AGENT_ENABLED
32+
value: "true"
33+
- name: DD_LOGS_ENABLED
34+
value: "true"
35+
- name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
36+
value: "true"
37+
- name: HOST_PROC
38+
value: /host/proc
39+
- name: HOST_SYS
40+
value: /host/sys
41+
volumeMounts:
42+
- name: dockersocket
43+
mountPath: /var/run/docker.sock
44+
- name: procdir
45+
mountPath: /host/proc
46+
readOnly: true
47+
- name: cgroups
48+
mountPath: /host/sys/fs/cgroup
49+
readOnly: true
50+
- name: passwd
51+
mountPath: /etc/passwd
52+
readOnly: true
53+
- name: pointerdir
54+
mountPath: /opt/datadog-agent/run
55+
volumes:
56+
- hostPath:
57+
path: /run/docker.sock
58+
name: dockersocket
59+
- hostPath:
60+
path: /proc
61+
name: procdir
62+
- hostPath:
63+
path: /sys/fs/cgroup
64+
name: cgroups
65+
- hostPath:
66+
path: /etc/passwd
67+
name: passwd
68+
- hostPath:
69+
path: /opt/datadog-agent/run
70+
name: pointerdir
71+
---
72+
apiVersion: v1
73+
kind: Service
74+
metadata:
75+
name: dd-agent
76+
labels:
77+
run: dd-agent
78+
spec:
79+
ports:
80+
- name: dogstatsdport
81+
port: 8125
82+
targetPort: 8125
83+
protocol: UDP
84+
- name: traceport
85+
port: 8126
86+
targetPort: 8126
87+
protocol: TCP
88+
targetPort: 8126
89+
protocol: TCP
90+
selector:
91+
app: dd-agent
92+
type: ClusterIP
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: datadog-agent
5+
rules:
6+
- apiGroups: # This is required by the agent to query the Kubelet API.
7+
- ""
8+
resources:
9+
- nodes/metrics
10+
- nodes/spec
11+
- nodes/proxy # Required to get /pods
12+
verbs:
13+
- get
14+
---
15+
kind: ServiceAccount
16+
apiVersion: v1
17+
metadata:
18+
name: datadog-agent
19+
namespace: default
20+
---
21+
apiVersion: rbac.authorization.k8s.io/v1
22+
kind: ClusterRoleBinding
23+
metadata:
24+
name: datadog-agent
25+
roleRef:
26+
apiGroup: rbac.authorization.k8s.io
27+
kind: ClusterRole
28+
name: datadog-agent
29+
subjects:
30+
- kind: ServiceAccount
31+
name: datadog-agent
32+
namespace: default
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: mongo
6+
labels:
7+
name: mongo
8+
spec:
9+
ports:
10+
- port: 27017
11+
targetPort: 27017
12+
clusterIP: None
13+
selector:
14+
role: mongo
15+
---
16+
apiVersion: apps/v1beta1
17+
kind: StatefulSet
18+
metadata:
19+
name: mongo
20+
spec:
21+
serviceName: "mongo"
22+
replicas: 3
23+
template:
24+
metadata:
25+
annotations:
26+
ad.datadoghq.com/mongo.check_names: '["mongo"]'
27+
ad.datadoghq.com/mongo.init_configs: '[{}]'
28+
ad.datadoghq.com/mongo.instances: '[{"server": "mongodb://datadog:tndPhL3wrMEDuj4wLEHmbxbV@%%host%%:%%port%%"}]'
29+
labels:
30+
role: mongo
31+
environment: test
32+
spec:
33+
serviceAccountName: mongorbac
34+
terminationGracePeriodSeconds: 10
35+
containers:
36+
- name: mongo
37+
image: mongo
38+
command:
39+
- mongod
40+
- "--replSet"
41+
- rs0
42+
- "--bind_ip"
43+
- 0.0.0.0
44+
- "--smallfiles"
45+
- "--noprealloc"
46+
ports:
47+
- containerPort: 27017
48+
volumeMounts:
49+
- name: mongo-persistent-storage
50+
mountPath: /data/db
51+
- name: mongo-sidecar
52+
image: cvallance/mongo-k8s-sidecar
53+
env:
54+
- name: MONGO_SIDECAR_POD_LABELS
55+
value: "role=mongo,environment=test"
56+
volumeClaimTemplates:
57+
- metadata:
58+
name: mongo-persistent-storage
59+
annotations:
60+
volume.beta.kubernetes.io/storage-class: "fast"
61+
spec:
62+
accessModes: [ "ReadWriteOnce" ]
63+
resources:
64+
requests:
65+
storage: 1Gi
66+
---
67+
kind: ClusterRole
68+
apiVersion: rbac.authorization.k8s.io/v1
69+
metadata:
70+
name: mongorbac
71+
rules:
72+
- apiGroups:
73+
- ""
74+
resources:
75+
- pods
76+
verbs:
77+
- get
78+
- list
79+
---
80+
apiVersion: rbac.authorization.k8s.io/v1
81+
kind: ClusterRoleBinding
82+
metadata:
83+
name: mongorbac
84+
roleRef:
85+
apiGroup: rbac.authorization.k8s.io
86+
kind: ClusterRole
87+
name: mongorbac
88+
subjects:
89+
- kind: ServiceAccount
90+
name: mongorbac
91+
namespace: default
92+
---
93+
kind: ServiceAccount
94+
apiVersion: v1
95+
metadata:
96+
name: mongorbac
97+
namespace: default
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kind: StorageClass
2+
apiVersion: storage.k8s.io/v1beta1
3+
metadata:
4+
name: fast
5+
provisioner: kubernetes.io/aws-ebs
6+
parameters:
7+
type: gp2
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: nginx
5+
spec:
6+
replicas: 1
7+
template: # create pods using pod definition in this template
8+
metadata:
9+
annotations:
10+
ad.datadoghq.com/nginx.check_names: '["nginx"]'
11+
ad.datadoghq.com/nginx.init_configs: '[{}]'
12+
ad.datadoghq.com/nginx.instances: '[{"nginx_status_url": "http://%%host%%/nginx_status"}]'
13+
labels:
14+
role: nginx
15+
spec:
16+
containers:
17+
- name: nginx
18+
image: charlyyfon/nodeapp:nginx
19+
imagePullPolicy: Always
20+
ports:
21+
- containerPort: 80
22+
volumeMounts:
23+
- name: "config"
24+
mountPath: "/etc/nginx/nginx.conf"
25+
subPath: "nginx.conf"
26+
volumes:
27+
- name: "config"
28+
configMap:
29+
name: "nginxconfig"
30+
---
31+
apiVersion: v1
32+
kind: Service
33+
metadata:
34+
name: nginx-deployment
35+
spec:
36+
ports:
37+
- name: nginx
38+
port: 80
39+
targetPort: 80
40+
protocol: TCP
41+
selector:
42+
role: nginx
43+
type: LoadBalancer
44+
---
45+
apiVersion: v1
46+
data:
47+
nginx.conf: |+
48+
worker_processes 5;
49+
events {
50+
worker_connections 4096;
51+
}
52+
http {
53+
server {
54+
location /nginx_status {
55+
stub_status on;
56+
access_log /dev/stdout;
57+
allow all;
58+
}
59+
location / {
60+
proxy_pass http://fan:5000;
61+
proxy_set_header Host $host;
62+
proxy_set_header X-Real-IP $remote_addr;
63+
proxy_redirect off;
64+
}
65+
}
66+
}
67+
kind: ConfigMap
68+
metadata:
69+
name: nginxconfig
70+
namespace: default
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: redis
5+
spec:
6+
replicas: 1 # tells deployment to run 2 pods matching the template
7+
template: # create pods using pod definition in this template
8+
metadata:
9+
annotations:
10+
ad.datadoghq.com/redis.check_names: '["redisdb"]'
11+
ad.datadoghq.com/redis.init_configs: '[{}]'
12+
ad.datadoghq.com/redis.instances: '[{"host": "%%host%%","port":"6379"}]'
13+
labels:
14+
role: redis
15+
spec:
16+
containers:
17+
- name: redis
18+
image: charlyyfon/nodeapp:redis
19+
imagePullPolicy: Always
20+
ports:
21+
- name: redis
22+
containerPort: 6379
23+
---
24+
apiVersion: v1
25+
kind: Service
26+
metadata:
27+
name: redis
28+
labels:
29+
role: redis
30+
spec:
31+
ports:
32+
- port: 6379
33+
targetPort: 6379
34+
selector:
35+
role: redis
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: apps/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: fan
5+
spec:
6+
replicas: 1 # tells deployment to run 2 pods matching the template
7+
template: # create pods using pod definition in this template
8+
metadata:
9+
labels:
10+
role: fan
11+
spec:
12+
containers:
13+
- name: fan
14+
image: charlyyfon/nodeapp:fetch
15+
imagePullPolicy: Always
16+
ports:
17+
- name: fan
18+
containerPort: 5000
19+
env:
20+
- name: API_KEY
21+
value: DD_API_KEY
22+
---
23+
apiVersion: v1
24+
kind: Service
25+
metadata:
26+
name: fan
27+
labels:
28+
role: fan
29+
spec:
30+
ports:
31+
- port: 5000
32+
targetPort: 5000
33+
protocol: TCP
34+
selector:
35+
role: fan
36+
type: ClusterIP

0 commit comments

Comments
 (0)