Integrate datadog APM integration for the online boutique app
for relyance demo.
This commit is contained in:
parent
c4d86703c5
commit
202f987014
25 changed files with 1346 additions and 283 deletions
30
apm/datadog/README.md
Normal file
30
apm/datadog/README.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
## Steps to setup Online Boutique App with Datadog monitoring
|
||||
|
||||
### Steps to install the boutique app on local machine with Kubernetes enabled on docker-desktop
|
||||
|
||||
1. Clone the source code for the online boutique app
|
||||
$ git clone git@github.com:Relyance/microservices-demo.git
|
||||
|
||||
2. Once the source code is cloned, enter the folder containing the source code
|
||||
$ cd microservices-demo/release
|
||||
|
||||
3. Run the kubernetes apply command to run the online boutique app
|
||||
$ kubectl apply -f kubernetes-manifests.yaml
|
||||
(Note: Wait for 10 minutes for the whole app to be downloaded and up and running
|
||||
|
||||
4. Do the port-forwarding to run the application from the browser
|
||||
$ kubectl port-forward service/frontend 8080:80
|
||||
|
||||
|
||||
### Steps to setup Datadog agent for monitoring Online Boutique App (deployed as Kubernetes) [Explained above]
|
||||
|
||||
1. Configure agent permissions
|
||||
$ kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/rbac/clusterrole.yaml"
|
||||
$ kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/rbac/serviceaccount.yaml"
|
||||
$ kubectl apply -f "https://raw.githubusercontent.com/DataDog/datadog-agent/master/Dockerfiles/manifests/rbac/clusterrolebinding.yaml"
|
||||
|
||||
2. Create a secret that contains your Datadog API Key
|
||||
$ kubectl create secret generic datadog-agent --from-literal api-key="77ed0972ca94340f9db3fb78ee5e89cc" --namespace="default"
|
||||
|
||||
1. Enable the datadog agent manifest file
|
||||
$ kubectl apply -f datadog-agent-logs-apm.yaml
|
283
apm/datadog/datadog-agent-logs-apm.yaml
Normal file
283
apm/datadog/datadog-agent-logs-apm.yaml
Normal file
|
@ -0,0 +1,283 @@
|
|||
# Source: datadog/templates/secrets.yaml
|
||||
# api-key: YzMyZGZiN2FhZTAzYTUxMTczN2NlNDQ3NDdmMTEwNTIK # key for rahul.jagad@relyance.ai account
|
||||
# API Key
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: datadog-agent
|
||||
labels: {}
|
||||
type: Opaque
|
||||
data:
|
||||
api-key: NzdlZDA5NzJjYTk0MzQwZjlkYjNmYjc4ZWU1ZTg5Y2MK
|
||||
---
|
||||
# Source: datadog/templates/daemonset.yaml
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: datadog-agent
|
||||
labels: {}
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: datadog-agent
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: datadog-agent
|
||||
name: datadog-agent
|
||||
annotations: {}
|
||||
spec:
|
||||
containers:
|
||||
- name: agent
|
||||
image: "datadog/agent:7.21.1"
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["agent", "run"]
|
||||
resources: {}
|
||||
ports:
|
||||
- containerPort: 8125
|
||||
name: dogstatsdport
|
||||
protocol: UDP
|
||||
env:
|
||||
- name: DD_CRI_SOCKET_PATH
|
||||
value: "unix:///host/var/run/docker.sock"
|
||||
- name: DD_KUBELET_TLS_VERIFY
|
||||
value: "false"
|
||||
# To pick the docker logs directly and submit it to the datadog server.
|
||||
- name: DOCKER_HOST
|
||||
value: "unix:///host/var/run/docker.sock"
|
||||
#TODO : API key needs to be used from the "secrets" container above, but
|
||||
# somehow its not working currently and so putting the secret directly here.
|
||||
# The problem that i am facing is the "secrets" against is somehow adding the newline
|
||||
# character to the key making the key invalid and hence not working.
|
||||
- name: DD_API_KEY
|
||||
value: "77ed0972ca94340f9db3fb78ee5e89cc"
|
||||
# valueFrom:
|
||||
# secretKeyRef:
|
||||
# name: "datadog-agent"
|
||||
# key: api-key
|
||||
- name: DD_KUBERNETES_KUBELET_HOST
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.hostIP
|
||||
- name: KUBERNETES
|
||||
value: "yes"
|
||||
- name: DD_CONTAINER_EXCLUDE
|
||||
value: "image:datadog/agent"
|
||||
- name: DD_AC_EXCLUDE
|
||||
value: "name:datadog-agent"
|
||||
- name: DD_LOG_LEVEL
|
||||
value: "INFO"
|
||||
- name: DD_DOGSTATSD_PORT
|
||||
value: "8125"
|
||||
- name: DD_LEADER_ELECTION
|
||||
value: "true"
|
||||
- name: DD_COLLECT_KUBERNETES_EVENTS
|
||||
value: "true"
|
||||
- name: DD_APM_ENABLED
|
||||
value: "true"
|
||||
- name: DD_LOGS_ENABLED
|
||||
value: "true"
|
||||
- name: DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL
|
||||
value: "true"
|
||||
- name: DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE
|
||||
value: "true"
|
||||
- name: DD_HEALTH_PORT
|
||||
value: "5555"
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/datadog-agent
|
||||
- name: runtimesocketdir
|
||||
mountPath: /host/var/run
|
||||
readOnly: true
|
||||
- name: procdir
|
||||
mountPath: /host/proc
|
||||
readOnly: true
|
||||
- name: cgroups
|
||||
mountPath: /host/sys/fs/cgroup
|
||||
readOnly: true
|
||||
- name: pointerdir
|
||||
mountPath: /opt/datadog-agent/run
|
||||
- name: logpodpath
|
||||
mountPath: /var/log/pods
|
||||
readOnly: true
|
||||
- name: logdockercontainerpath
|
||||
mountPath: /var/lib/docker/containers
|
||||
readOnly: true
|
||||
# - name: dockersocketdir
|
||||
# mountPath: /host/var/run
|
||||
livenessProbe:
|
||||
failureThreshold: 6
|
||||
httpGet:
|
||||
path: /live
|
||||
port: 5555
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
failureThreshold: 6
|
||||
httpGet:
|
||||
path: /ready
|
||||
port: 5555
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 5
|
||||
- name: trace-agent
|
||||
image: "datadog/agent:7.21.1"
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["trace-agent", "-config=/etc/datadog-agent/datadog.yaml"]
|
||||
resources: {}
|
||||
ports:
|
||||
- containerPort: 8126
|
||||
hostPort: 8126
|
||||
name: traceport
|
||||
protocol: TCP
|
||||
env:
|
||||
#TODO : API key needs to be used from the "secrets" container above, but
|
||||
# somehow its not working currently and so putting the secret directly here.
|
||||
# The problem that i am facing is the "secrets" against is somehow adding the newline
|
||||
# character to the key making the key invalid and hence not working.
|
||||
- name: DD_API_KEY
|
||||
value: "77ed0972ca94340f9db3fb78ee5e89cc"
|
||||
# valueFrom:
|
||||
# secretKeyRef:
|
||||
# name: "datadog-agent"
|
||||
# key: api-key
|
||||
- name: DD_KUBERNETES_KUBELET_HOST
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.hostIP
|
||||
- name: KUBERNETES
|
||||
value: "yes"
|
||||
- name: DD_CONTAINER_EXCLUDE
|
||||
value: "image:datadog/agent"
|
||||
- name: DOCKER_HOST
|
||||
value: "unix:///host/var/run/docker.sock"
|
||||
- name: DD_LOG_LEVEL
|
||||
value: "debug"
|
||||
- name: DD_APM_ENABLED
|
||||
value: "true"
|
||||
- name: DD_APM_NON_LOCAL_TRAFFIC
|
||||
value: "true"
|
||||
- name: DD_APM_RECEIVER_PORT
|
||||
value: "8126"
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/datadog-agent
|
||||
- name: runtimesocketdir
|
||||
mountPath: /host/var/run
|
||||
readOnly: true
|
||||
livenessProbe:
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
tcpSocket:
|
||||
port: 8126
|
||||
timeoutSeconds: 5
|
||||
initContainers:
|
||||
- name: init-volume
|
||||
image: "datadog/agent:7.21.1"
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["bash", "-c"]
|
||||
args:
|
||||
- cp -r /etc/datadog-agent /opt
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /opt/datadog-agent
|
||||
resources: {}
|
||||
- name: init-config
|
||||
image: "datadog/agent:7.21.1"
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["bash", "-c"]
|
||||
args:
|
||||
- for script in $(find /etc/cont-init.d/ -type f -name '*.sh' | sort) ; do bash $script ; done
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/datadog-agent
|
||||
- name: procdir
|
||||
mountPath: /host/proc
|
||||
readOnly: true
|
||||
- name: runtimesocketdir
|
||||
mountPath: /host/var/run
|
||||
readOnly: true
|
||||
env:
|
||||
#TODO : API key needs to be used from the "secrets" container above, but
|
||||
# somehow its not working currently and so putting the secret directly here.
|
||||
# The problem that i am facing is the "secrets" against is somehow adding the newline
|
||||
# character to the key making the key invalid and hence not working.
|
||||
- name: DD_API_KEY
|
||||
value: "77ed0972ca94340f9db3fb78ee5e89cc"
|
||||
- name: DD_KUBERNETES_KUBELET_HOST
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: status.hostIP
|
||||
- name: KUBERNETES
|
||||
value: "yes"
|
||||
- name: DD_AC_EXCLUDE
|
||||
value: "name:datadog-agent"
|
||||
- name: DOCKER_HOST
|
||||
value: "unix:///host/var/run/docker.sock"
|
||||
- name: DD_LEADER_ELECTION
|
||||
value: "true"
|
||||
resources: {}
|
||||
volumes:
|
||||
- name: config
|
||||
emptyDir: {}
|
||||
- hostPath:
|
||||
path: /var/run
|
||||
name: runtimesocketdir
|
||||
- hostPath:
|
||||
path: /proc
|
||||
name: procdir
|
||||
- hostPath:
|
||||
path: /sys/fs/cgroup
|
||||
name: cgroups
|
||||
- name: s6-run
|
||||
emptyDir: {}
|
||||
- hostPath:
|
||||
path: "/var/lib/datadog-agent/logs"
|
||||
name: pointerdir
|
||||
- hostPath:
|
||||
path: /var/log/pods
|
||||
name: logpodpath
|
||||
- hostPath:
|
||||
path: /var/lib/docker/containers
|
||||
name: logdockercontainerpath
|
||||
- hostPath:
|
||||
path: /var/run
|
||||
name: dockersocketdir
|
||||
tolerations:
|
||||
affinity: {}
|
||||
serviceAccountName: "datadog-agent"
|
||||
nodeSelector:
|
||||
kubernetes.io/os: linux
|
||||
updateStrategy:
|
||||
rollingUpdate:
|
||||
maxUnavailable: 10%
|
||||
type: RollingUpdate
|
||||
|
||||
# Service
|
||||
# We probably dont need to expose the datadog agent as the service,
|
||||
# since the way the "DD_AGENT_HOST" environment variable can be exposed
|
||||
# inside the application is by setting status.hostIP value.
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: datadog-agent
|
||||
spec:
|
||||
selector:
|
||||
app: datadog-agent
|
||||
ports:
|
||||
- name: agent
|
||||
protocol: TCP
|
||||
port: 8125
|
||||
targetPort: 8125
|
||||
- name: trace-agent
|
||||
protocol: TCP
|
||||
port: 8126
|
||||
targetPort: 8126
|
||||
|
||||
# Source: datadog/templates/containers-common-env.yaml
|
||||
# The purpose of this template is to define a minimal set of environment
|
||||
# variables required to operate dedicated containers in the daemonset
|
Loading…
Add table
Add a link
Reference in a new issue