Skip to content

Commit d7bde4e

Browse files
authored
Merge pull request #26 from uswitch/airship-4631/node-problem-detector
Airship 4631: Rewrite to avoid imds
2 parents f353804 + 3470d6d commit d7bde4e

5 files changed

Lines changed: 19 additions & 71 deletions

File tree

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
FROM registry.k8s.io/node-problem-detector/node-problem-detector:v1.35.1
1+
FROM registry.k8s.io/node-problem-detector/node-problem-detector:v1.35.2
22

33
RUN set -eux; \
44
apt-get update; \
55
apt-get install -y --no-install-recommends \
66
# required by plugin/spot_termination.sh
77
curl \
8-
# required by plugin/launch_config_drift.sh
9-
awscli \
8+
# required by plugin/local_dns_resolver.sh
109
jq \
1110
# required by local_dns_resolver.sh and upstream_dns_resolver.sh plugins
1211
dnsutils \
1312
; \
1413
rm -rf /var/lib/apt/lists/*;
1514

16-
COPY config /config
15+
COPY config /config

config/aws-ec2-asg-lc-drift-plugin-monitor.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

config/local-dns-resolver-config.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
"type": "permanent",
2020
"condition": "NodeLocalDnsResolutionFailure",
2121
"reason": "NodeLocalDnsResolutionFailing",
22-
"path": "./config/plugin/local_dns_resolver.sh",
23-
"args": [
24-
"kube-dns-upstream.kube-system.svc.cluster.local."
25-
]
22+
"path": "./config/plugin/local_dns_resolver.sh"
2623
}
2724
]
2825
}

config/plugin/launch_config_drift.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

config/plugin/local_dns_resolver.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ OK=0
44
NONOK=1
55
UNKNOWN=2
66

7-
readonly local_dns_resolver_ip="$1"
7+
if [ -z "${NODE_NAME}" ]; then
8+
exit $UNKNOWN
9+
fi
10+
11+
# Get the node-local-dns pod IP running on this node directly,
12+
# bypassing 169.254.20.10 which requires Cilium's eBPF path
13+
local_dns_resolver_ip="$(curl -s \
14+
-H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" \
15+
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt \
16+
"https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}/api/v1/namespaces/kube-system/pods?labelSelector=k8s-app%3Dnode-local-dns&fieldSelector=spec.nodeName%3D${NODE_NAME}" \
17+
2>/dev/null | jq -r '.items[0].status.podIP')"
18+
19+
if [ -z "${local_dns_resolver_ip}" ] || [ "${local_dns_resolver_ip}" = "null" ]; then
20+
exit $UNKNOWN
21+
fi
822

923
dig_cmd_out="$(dig -t TXT @"${local_dns_resolver_ip}" +tries=1 +retry=0 +time=33 +noqr +noall +comments kubernetes.default.svc. 2>&1)"
1024
dig_cmd_return_code="$?"

0 commit comments

Comments
 (0)