-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathagent-cilium-network-policy.yaml
195 lines (195 loc) · 6.96 KB
/
agent-cilium-network-policy.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
{{- if and (or $.Values.datadog.networkPolicy.create $.Values.agents.networkPolicy.create) (eq $.Values.datadog.networkPolicy.flavor "cilium") -}}
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: {{ template "datadog.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "datadog.labels" . | indent 4 }}
specs:
- description: "Egress ECS agent port 51678"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
egress:
- toEntities:
- host
toPorts:
- ports:
- port: "51678"
protocol: TCP
- toCIDR:
- 169.254.0.0/16
toPorts:
- ports:
- port: "51678"
protocol: TCP
- description: "Egress to ntp"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
egress:
- toFQDNs:
- matchPattern: "*.datadog.pool.ntp.org"
toPorts:
- ports:
- port: "123"
protocol: UDP
- description: "Egress to metadata server"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
egress:
- toCIDR:
- 169.254.169.254/32
toPorts:
- ports:
- port: "80"
protocol: TCP
- description: "Egress to DNS"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
egress:
- {{ toYaml .Values.datadog.networkPolicy.cilium.dnsSelector | nindent 8 }}
toPorts:
- ports:
- port: "53"
protocol: ANY
rules:
dns:
- matchPattern: "*"
- description: "Egress to Datadog intake"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
egress:
- toFQDNs:
{{- if $.Values.datadog.dd_url}}
- matchName: {{ trimPrefix "https://" $.Values.datadog.dd_url }}
{{- end}}
{{- if $.Values.datadog.site}}
- matchPattern: "*-app.agent.{{ $.Values.datadog.site }}"
- matchName: "app.{{ $.Values.datadog.site }}"
- matchName: "api.{{ $.Values.datadog.site }}"
- matchName: "agent-intake.logs.{{ $.Values.datadog.site }}"
- matchName: "agent-http-intake.logs.{{ $.Values.datadog.site }}"
- matchName: "contimage-intake.{{ $.Values.datadog.site }}"
- matchName: "contlcycle-intake.{{ $.Values.datadog.site }}"
- matchName: "process.{{ $.Values.datadog.site }}"
- matchName: "orchestrator.{{ $.Values.datadog.site }}"
- matchName: "instrumentation-telemetry-intake.{{ $.Values.datadog.site }}"
- matchName: "intake.profile.{{ $.Values.datadog.site }}"
- matchName: "ndm-intake.{{ $.Values.datadog.site }}"
- matchName: "snmp-traps-intake.{{ $.Values.datadog.site }}"
- matchName: "ndmflow-intake.{{ $.Values.datadog.site }}"
- matchName: "config.{{ $.Values.datadog.site }}"
- matchName: "dbm-metrics-intake.{{ $.Values.datadog.site }}"
- matchName: "dbquery-intake.{{ $.Values.datadog.site }}"
{{- else}}
- matchPattern: "*-app.agent.datadoghq.com"
- matchName: "app.datadoghq.com"
- matchName: "api.datadoghq.com"
- matchName: "agent-intake.logs.datadoghq.com"
- matchName: "agent-http-intake.logs.datadoghq.com"
- matchName: "contimage-intake.datadoghq.com"
- matchName: "contlcycle-intake.datadoghq.com"
- matchName: "process.datadoghq.com"
- matchName: "orchestrator.datadoghq.com"
- matchName: "instrumentation-telemetry-intake.datadoghq.com"
- matchName: "intake.profile.datadoghq.com"
- matchName: "ndm-intake.datadoghq.com"
- matchName: "snmp-traps-intake.datadoghq.com"
- matchName: "ndmflow-intake.datadoghq.com"
- matchName: "config.datadoghq.com"
- matchName: "dbm-metrics-intake.datadoghq.com"
- matchName: "dbquery-intake.datadoghq.com"
{{- end}}
toPorts:
- ports:
- port: "443"
protocol: TCP
- port: "10516"
protocol: TCP
- description: "Egress to Kubelet"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
egress:
- toEntities:
- host
toPorts:
- ports:
- port: "10250"
protocol: TCP
{{- if $.Values.datadog.dogstatsd.port }}
- description: "Ingress for dogstatsd"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
ingress:
- fromEndpoints:
- {}
toPorts:
- ports:
- port: "{{ $.Values.datadog.dogstatsd.port }}"
protocol: UDP
{{- end }}
{{- if eq (include "trace-agent-use-tcp-port" .) "true" }}
- description: "Ingress for APM trace"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
ingress:
- fromEndpoints:
- {}
toPorts:
- ports:
- port: "{{ $.Values.datadog.apm.port }}"
protocol: TCP
{{- end }}
# The agents are susceptible to an issue connecting to any pod that
# is annotated with auto-discovery annotations.
#
# When a user wants to add a check on such a pod, they need to
# * annotate the pod
# * add an ingress policy from the agent on its own pod
# In order to not ask end-users to inject NetworkPolicy on the agent in
# the agent namespace, the agent must be allowed to probe any pod.
- description: "Egress to anything for checks"
endpointSelector:
matchLabels:
app: {{ template "datadog.fullname" . }}
{{- if .Values.agents.podLabels }}
{{ toYaml .Values.agents.podLabels | indent 8 }}
{{- end }}
egress:
- toEndpoints:
- matchExpressions:
- key: k8s:io.kubernetes.pod.namespace
operator: Exists
{{- end }}