diff --git a/test/840_weave_kube_3_test.sh b/test/840_weave_kube_3_test.sh index e45fe476..a3cbfef8 100755 --- a/test/840_weave_kube_3_test.sh +++ b/test/840_weave_kube_3_test.sh @@ -134,6 +134,22 @@ spec: run: nettest EOF +# And a NodePort service so we can test virtual IP access +run_on $HOST1 "$KUBECTL create -f -" </dev/null" +# check access via virtual IP +VIRTUAL_IP=$($SSH $HOST1 $KUBECTL get service netvirt -o template --template={{.spec.clusterIP}}) +assert_raises "$SSH $HOST1 $KUBECTL exec $podName -- curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" +assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" + +# host should not be able to reach pods via service virtual IP or NodePort +assert_raises "! $SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" +assert_raises "! $SSH $HOST1 curl -s -S -f -m 2 http://$HOST2:31138/status >/dev/null" + # allow access for nettest-deny run_on $HOST1 "$KUBECTL apply -f -" </dev/null" +# Virtual IP and NodePort should now work +assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$VIRTUAL_IP/status >/dev/null" +assert_raises "$SSH $HOST1 curl -s -S -f -m 2 http://$HOST2:31138/status >/dev/null" + tear_down_kubeadm # Destroy our test ipset, and implicitly check it is still there