k8s: deny ingress to every pod by default
This commit is contained in:
parent
f349137d73
commit
d579c54f82
1 changed files with 241 additions and 27 deletions
|
|
@ -687,6 +687,18 @@ pkgs.testers.runNixOSTest {
|
|||
machine.wait_until_fails(dials(other, ip, METRICS), timeout=120)
|
||||
for _ in range(3):
|
||||
assert machine.execute(dials(other, ip, METRICS))[0] != 0
|
||||
# The responder's health port answers the node with a status and is
|
||||
# closed to the same two sources: the namespace's default admits the
|
||||
# node and nobody else, and the pod's own policy names the client port
|
||||
# only.
|
||||
code = machine.succeed(f"curl -s -o /dev/null -w '%{{http_code}}' --max-time 5 http://{pod_ip}:8080/healthz").strip()
|
||||
assert code == "200", code
|
||||
machine.wait_until_fails(dials(other, pod_ip, 8080), timeout=120)
|
||||
for port in (8080, METRICS):
|
||||
assert machine.execute(dials(other, pod_ip, port))[0] != 0, port
|
||||
assert machine.execute(f"ip netns exec agent nc -z -w 4 {pod_ip} {port}")[0] != 0, port
|
||||
deny = json.loads(kube(machine, "get networkpolicy default-deny-ingress -o json"))["spec"]
|
||||
assert deny == {"podSelector": {}, "policyTypes": ["Ingress"]}, deny
|
||||
|
||||
with subtest("a leaf that has to be issued again is issued beside the running server, which reloads it for new connections"):
|
||||
uid = pod(machine, pod_name)["metadata"]["uid"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue