npc: Extend NetworkPolicy test cases in 840
- Add a test case for default allow all ingress traffic. - Fix misleading comment.
This commit is contained in:
1 parent
89e5d935a6
commit
cacc190764
1 file changed
+23
-2
@@ -170,12 +170,12 @@ assert_raises 'wait_for_x check_all_pods_communicate pods'
|
|||||||
# nettest-deny should still not be able to reach nettest pods
|
# nettest-deny should still not be able to reach nettest pods
|
||||||
assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
|
assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
|
||||||
|
|
||||||
# allow access for all
|
# allow access for nettest-deny
|
||||||
run_on $HOST1 "$KUBECTL apply -f -" <<EOF
|
run_on $HOST1 "$KUBECTL apply -f -" <<EOF
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
kind: NetworkPolicy
|
kind: NetworkPolicy
|
||||||
metadata:
|
metadata:
|
||||||
name: nettest-misc
|
name: allow-nettest-deny
|
||||||
namespace: default
|
namespace: default
|
||||||
spec:
|
spec:
|
||||||
podSelector:
|
podSelector:
|
||||||
@@ -190,6 +190,27 @@ EOF
|
|||||||
|
|
||||||
assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
|
assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
|
||||||
|
|
||||||
|
# remove the access for nettest-deny
|
||||||
|
run_on $HOST1 "$KUBECTL delete netpol allow-nettest-deny"
|
||||||
|
|
||||||
|
# nettest-deny should still not be able to reach nettest pods
|
||||||
|
assert_raises "! $SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
|
||||||
|
|
||||||
|
# allow access for all
|
||||||
|
run_on $HOST1 "$KUBECTL apply -f -" <<EOF
|
||||||
|
apiVersion: networking.k8s.io/v1
|
||||||
|
kind: NetworkPolicy
|
||||||
|
metadata:
|
||||||
|
name: allow-nettest-deny
|
||||||
|
namespace: default
|
||||||
|
spec:
|
||||||
|
podSelector: {}
|
||||||
|
ingress:
|
||||||
|
- {}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
assert_raises "$SSH $HOST1 $KUBECTL exec $denyPodName -- curl -s -S -f -m 2 http://$DOMAIN:8080/status >/dev/null"
|
||||||
|
|
||||||
tear_down_kubeadm
|
tear_down_kubeadm
|
||||||
|
|
||||||
# Destroy our test ipset, and implicitly check it is still there
|
# Destroy our test ipset, and implicitly check it is still there
|
||||||
|
|||||||
Reference in new issue
Block a user