diff --git a/network/README.md b/network/README.md new file mode 100644 index 0000000..4cdfec3 --- /dev/null +++ b/network/README.md @@ -0,0 +1,16 @@ +network +------- + +This contains tools to check the network communication in the cluster is ok. + +``` +$ kubectl create -f overlay-test.yml +$ kubectl rollout status ds/overlaytest -w +# ^ wait until daemon set "overlaytest" successfully rolled out. +$ ./test-internode-communication.sh +# If no FAIL within the output log, then everything is fine +$ kubectl delete -f overlay-test.yml +``` +``` +source: https://rancher.com/docs/rancher/v2.5/en/troubleshooting/networking/ + diff --git a/network/overlay-test.yml b/network/overlay-test.yml new file mode 100644 index 0000000..96b3dc6 --- /dev/null +++ b/network/overlay-test.yml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: overlaytest +spec: + selector: + matchLabels: + name: overlaytest + template: + metadata: + labels: + name: overlaytest + spec: + tolerations: + - operator: Exists + containers: + - image: rancherlabs/swiss-army-knife + imagePullPolicy: Always + name: overlaytest + command: ["sh", "-c", "tail -f /dev/null"] + terminationMessagePath: /dev/termination-log diff --git a/network/test-internode-communication.sh b/network/test-internode-communication.sh new file mode 100755 index 0000000..bfae9c5 --- /dev/null +++ b/network/test-internode-communication.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo "=> Start network overlay test" + kubectl get pods -l name=overlaytest -o jsonpath='{range .items[*]}{@.metadata.name}{" "}{@.spec.nodeName}{"\n"}{end}' | + while read spod shost + do kubectl get pods -l name=overlaytest -o jsonpath='{range .items[*]}{@.status.podIP}{" "}{@.spec.nodeName}{"\n"}{end}' | + while read tip thost + do kubectl --request-timeout='10s' exec $spod -c overlaytest -- /bin/sh -c "ping -c2 $tip > /dev/null 2>&1" + RC=$? + if [ $RC -ne 0 ] + then echo FAIL: $spod on $shost cannot reach pod IP $tip on $thost + else echo $shost can reach $thost + fi + done + done +echo "=> End network overlay test"