diff --git a/charts/coredns/templates/bin/_probe.py.tpl b/charts/coredns/templates/bin/_probe.py.tpl index 9e3ac22f..d7e6ed0f 100644 --- a/charts/coredns/templates/bin/_probe.py.tpl +++ b/charts/coredns/templates/bin/_probe.py.tpl @@ -17,12 +17,24 @@ class httpHandler(BaseHTTPRequestHandler): failed = False res = requests.get("http://127.0.0.1:{}/health".format(args.check_port)) if res.status_code >= 400: + print('Failed /health check, status code = : {}'.format(res.status_code)) failed = True - res = subprocess.run( - ["dig", "+time=2", "+tries=1", "@127.0.0.1", "-f", args.filename], - stdout=subprocess.DEVNULL) - if res.returncode != 0: - failed = True + + with open(args.filename, 'r') as fh: + for host in fh.read().splitlines(): + # ignore blank lines + if not host: + continue + res = subprocess.run( + ["host", "-W=2", "-R=1", host, "127.0.0.1"], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + if res.returncode != 0: + print('Failed to resolve host: "{}"'.format(host)) + print(res.stdout) + failed = True + break + if failed: print('Check failed') self.send_response(500) diff --git a/charts/coredns/templates/configmap-list.yaml b/charts/coredns/templates/configmap-list.yaml index d3729944..88a0a869 100644 --- a/charts/coredns/templates/configmap-list.yaml +++ b/charts/coredns/templates/configmap-list.yaml @@ -4,5 +4,5 @@ kind: ConfigMap metadata: name: {{ .Values.service.name }}-list data: - names_to_resolve: | + names_to_resolve: |- {{ tuple "etc/_list.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} diff --git a/charts/coredns/templates/etc/_list.tpl b/charts/coredns/templates/etc/_list.tpl index 8df545b9..9fbaae00 100644 --- a/charts/coredns/templates/etc/_list.tpl +++ b/charts/coredns/templates/etc/_list.tpl @@ -1,3 +1,3 @@ -{{- range .Values.conf.test.names_to_resolve }} +{{- range .Values.conf.test.names_to_resolve -}} {{ . }} -{{- end }} +{{ end -}} diff --git a/charts/coredns/templates/pod-test.yaml b/charts/coredns/templates/pod-test.yaml index d456281b..6d7b5235 100644 --- a/charts/coredns/templates/pod-test.yaml +++ b/charts/coredns/templates/pod-test.yaml @@ -40,16 +40,26 @@ spec: - -c - | SUCCESS=1 - {{- range .Values.conf.test.names_to_resolve }} - if dig {{ . }}; then - echo "Successfully resolved {{ . }}" - else - echo "Failed to resolve {{ . }}" - SUCCESS=0 - fi - {{- end }} + while read host; do + if [ -n "$host" ]; then + if host "$host"; then + echo "Successfully resolved: \"$host\"" + else + echo "Failed to resolve: \"$host\"" + SUCCESS=0 + fi + fi + done < /tmp/etc/names_to_resolve if [ "$SUCCESS" != "1" ]; then echo "Test failed to resolve all names." exit 1 fi + volumeMounts: + - name: dns-names + mountPath: /tmp/etc + volumes: + - name: dns-names + configMap: + name: {{ $envAll.Values.service.name }}-list + defaultMode: 0555 {{- end }} diff --git a/examples/basic/armada-resources.yaml b/examples/basic/armada-resources.yaml index fe11d98f..db19cd6c 100644 --- a/examples/basic/armada-resources.yaml +++ b/examples/basic/armada-resources.yaml @@ -563,7 +563,6 @@ data: test: names_to_resolve: - calico-etcd.kube-system.svc.cluster.local - - kubernetes-etcd.kube-system.svc.cluster.local - kubernetes.default.svc.cluster.local images: tags: diff --git a/examples/complete/armada-resources.yaml b/examples/complete/armada-resources.yaml index 45f26cb9..2090b08c 100644 --- a/examples/complete/armada-resources.yaml +++ b/examples/complete/armada-resources.yaml @@ -584,7 +584,6 @@ data: test: names_to_resolve: - calico-etcd.kube-system.svc.cluster.local - - kubernetes-etcd.kube-system.svc.cluster.local - kubernetes.default.svc.cluster.local images: diff --git a/examples/containerd/armada-resources.yaml b/examples/containerd/armada-resources.yaml index 88b0bcec..f37bf3c5 100644 --- a/examples/containerd/armada-resources.yaml +++ b/examples/containerd/armada-resources.yaml @@ -459,7 +459,6 @@ data: - att.com - calico-etcd.kube-system.svc.cluster.local - google.com - - kubernetes-etcd.kube-system.svc.cluster.local - kubernetes.default.svc.cluster.local images: diff --git a/examples/gate/armada-resources.yaml b/examples/gate/armada-resources.yaml index 269884e8..4bc7b975 100644 --- a/examples/gate/armada-resources.yaml +++ b/examples/gate/armada-resources.yaml @@ -459,7 +459,6 @@ data: - att.com - calico-etcd.kube-system.svc.cluster.local - google.com - - kubernetes-etcd.kube-system.svc.cluster.local - kubernetes.default.svc.cluster.local images: