-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdaemonSet-dns-availability-check.yaml
More file actions
49 lines (49 loc) · 1.84 KB
/
daemonSet-dns-availability-check.yaml
File metadata and controls
49 lines (49 loc) · 1.84 KB
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
# Disclaimer:
# The provided YAML file is shared "as is" without any guarantees or warranties. Use it at your own risk.
# # This is an example and is provided as-is. Review and validate before deploying.
# This DaemonSet tests DNS resolution latency for mcr.microsoft.com against 3 DNS servers.
# Update the DNS server IPs on line 29 (DNS_SERVERS) to customise for your specific usage.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: dns-availability-check
labels:
app: dns-check
spec:
selector:
matchLabels:
app: dns-check
template:
metadata:
labels:
app: dns-check
spec:
containers:
- name: dns-check
image: mcr.microsoft.com/azurelinux/base/core:3.0
command:
- /bin/sh
- -c
- |
curl -o /etc/yum.repos.d/azurelinux-prod-base.repo -L https://packages.microsoft.com/azurelinux/3.0/prod/base/x86_64/config.repo
tdnf update -y
tdnf install bind-utils gawk -y --nogpgcheck
echo "Starting DNS availability check..."
DNS_SERVERS="10.121.131.13 10.121.131.14 10.121.131.15"
while true; do
for dns in $DNS_SERVERS; do
output=$(dig +stats +timeout=4 +tries=2 mcr.microsoft.com @"$dns" 2>&1)
query_time=$(echo "$output" | grep "Query time" | awk '{print $4}')
if [ -z "$query_time" ] || echo "$output" | grep -qi "timed out\|no servers\|connection refused"; then
echo "$(date '+%Y-%m-%d %H:%M') TIMEOUT dns=$dns query_time=4000msec"
elif [ "$query_time" -gt 2700 ]; then
echo "$(date '+%Y-%m-%d %H:%M') SLOW dns=$dns query_time=${query_time}msec"
fi
done
sleep 45
done
resources:
requests:
cpu: 50m
memory: 32Mi
restartPolicy: Always