This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16.9k
/
agent-clusterchecks-deployment.yaml
179 lines (179 loc) · 7.03 KB
/
agent-clusterchecks-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
{{- if and .Values.clusterAgent.enabled .Values.datadog.clusterChecks.enabled .Values.clusterChecksRunner.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "datadog.fullname" . }}-clusterchecks
labels:
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
app.kubernetes.io/name: "{{ template "datadog.fullname" . }}"
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
spec:
replicas: {{ .Values.clusterChecksRunner.replicas }}
strategy:
{{ toYaml .Values.clusterChecksRunner.strategy | indent 4 }}
selector:
matchLabels:
app: {{ template "datadog.fullname" . }}-clusterchecks
template:
metadata:
labels:
app: {{ template "datadog.fullname" . }}-clusterchecks
name: {{ template "datadog.fullname" . }}-clusterchecks
annotations:
{{- if .Values.datadog.checksd }}
checksum/checksd-config: {{ tpl (toYaml .Values.datadog.checksd) . | sha256sum }}
{{- end }}
spec:
{{- if .Values.clusterChecksRunner.rbac.dedicated }}
serviceAccountName: {{ if .Values.clusterChecksRunner.rbac.create }}{{ template "datadog.fullname" . }}-cluster-checks{{ else }}"{{ .Values.clusterChecksRunner.rbac.serviceAccountName }}"{{ end }}
{{- else }}
serviceAccountName: {{ if .Values.clusterChecksRunner.rbac.create }}{{ template "datadog.fullname" . }}{{ else }}"{{ .Values.clusterChecksRunner.rbac.serviceAccountName }}"{{ end }}
{{- end }}
imagePullSecrets:
{{ toYaml .Values.clusterChecksRunner.image.pullSecrets | indent 8 }}
{{- if .Values.clusterChecksRunner.dnsConfig }}
dnsConfig:
{{ toYaml .Values.clusterChecksRunner.dnsConfig | indent 8 }}
{{- end }}
initContainers:
- name: init-volume
image: "{{ .Values.agents.image.repository }}:{{ .Values.agents.image.tag }}"
imagePullPolicy: {{ .Values.agents.image.pullPolicy }}
command: ["bash", "-c"]
args:
- cp -r /etc/datadog-agent /opt
volumeMounts:
- name: config
mountPath: /opt/datadog-agent
resources:
{{ toYaml .Values.agents.containers.initContainers.resources | indent 10 }}
- name: init-config
image: "{{ .Values.agents.image.repository }}:{{ .Values.agents.image.tag }}"
imagePullPolicy: {{ .Values.agents.image.pullPolicy }}
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
{{- if .Values.datadog.checksd }}
- name: checksd
mountPath: /checks.d
readOnly: true
{{- end }}
resources:
{{ toYaml .Values.agents.containers.initContainers.resources | indent 10 }}
containers:
- name: agent
image: "{{ .Values.clusterChecksRunner.image.repository }}:{{ .Values.clusterChecksRunner.image.tag }}"
command: ["bash", "-c"]
args:
- rm -rf /etc/datadog-agent/conf.d && touch /etc/datadog-agent/datadog.yaml && exec agent run
imagePullPolicy: {{ .Values.clusterChecksRunner.image.pullPolicy }}
env:
- name: DD_API_KEY
valueFrom:
secretKeyRef:
name: {{ template "datadog.apiSecretName" . }}
key: api-key
- name: KUBERNETES
value: "yes"
{{- if .Values.datadog.site }}
- name: DD_SITE
value: {{ .Values.datadog.site | quote }}
{{- end }}
{{- if .Values.datadog.dd_url }}
- name: DD_DD_URL
value: {{ .Values.datadog.dd_url | quote }}
{{- end }}
{{- if .Values.datadog.logLevel }}
- name: DD_LOG_LEVEL
value: {{ .Values.datadog.logLevel | quote }}
{{- end }}
- name: DD_EXTRA_CONFIG_PROVIDERS
value: "clusterchecks"
- name: DD_HEALTH_PORT
value: "5555"
# Cluster checks
- name: DD_CLUSTER_AGENT_KUBERNETES_SERVICE_NAME
value: {{ template "datadog.fullname" . }}-cluster-agent
- name: DD_CLUSTER_AGENT_AUTH_TOKEN
valueFrom:
secretKeyRef:
name: {{ template "clusterAgent.tokenSecretName" . }}
key: token
- name: DD_CLUSTER_AGENT_ENABLED
value: {{ .Values.clusterAgent.enabled | quote }}
# Safely run alongside the daemonset
- name: DD_ENABLE_METADATA_COLLECTION
value: "false"
# Expose CLC stats
- name: DD_CLC_RUNNER_ENABLED
value: "true"
- name: DD_CLC_RUNNER_HOST
valueFrom:
fieldRef:
fieldPath: status.podIP
# Remove unused features
- name: DD_USE_DOGSTATSD
value: "false"
- name: DD_PROCESS_AGENT_ENABLED
value: "false"
- name: DD_LOGS_ENABLED
value: "false"
- name: DD_APM_ENABLED
value: "false"
- name: DD_HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- if .Values.clusterChecksRunner.env }}
{{ toYaml .Values.clusterChecksRunner.env | indent 10 }}
{{- end }}
resources:
{{ toYaml .Values.clusterChecksRunner.resources | indent 10 }}
{{- if .Values.clusterChecksRunner.volumeMounts }}
volumeMounts:
- name: config
mountPath: {{ template "datadog.confPath" . }}
{{ toYaml .Values.clusterChecksRunner.volumeMounts | indent 10 }}
{{- end }}
livenessProbe:
{{ toYaml .Values.clusterChecksRunner.livenessProbe | indent 10 }}
readinessProbe:
{{ toYaml .Values.clusterChecksRunner.readinessProbe | indent 10 }}
volumes:
{{- if .Values.clusterChecksRunner.volumes }}
{{ toYaml .Values.clusterChecksRunner.volumes | indent 8 }}
{{- end }}
- name: config
emptyDir: {}
{{- if .Values.datadog.checksd }}
- name: checksd
configMap:
name: {{ template "datadog.fullname" . }}-checksd
{{- end }}
affinity:
{{- if .Values.clusterChecksRunner.affinity }}
{{ toYaml .Values.clusterChecksRunner.affinity | indent 8 }}
{{- else }}
# Ensure we only run one worker per node, to avoid name collisions
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}-clusterchecks
topologyKey: kubernetes.io/hostname
{{- end }}
nodeSelector:
{{ template "label.os" . }}: {{ .Values.targetSystem }}
{{- if .Values.clusterChecksRunner.nodeSelector }}
{{ toYaml .Values.clusterChecksRunner.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.clusterChecksRunner.tolerations }}
tolerations:
{{ toYaml .Values.clusterChecksRunner.tolerations | indent 8 }}
{{- end }}
{{ end }}