bind health listeners to the pod's loopback and probe them by exec
This commit is contained in:
parent
b7a8410769
commit
62cc95671d
1 changed files with 255 additions and 185 deletions
|
|
@ -484,8 +484,9 @@ pkgs.testers.runNixOSTest {
|
|||
with subtest("the pod is Ready on its health listener, has the volumes and ports the module renders, and no Secret"):
|
||||
spec = pod(machine, pod_name)["spec"]
|
||||
main = next(c for c in spec["containers"] if c["name"] == SERVICE)
|
||||
probe = main["readinessProbe"]["httpGet"]
|
||||
assert probe["path"] == "/readyz", probe
|
||||
probe = main["readinessProbe"]["exec"]["command"]
|
||||
assert probe[0] == "/bin/wget" and probe[-1] == "http://127.0.0.1:8080/readyz", probe
|
||||
assert not any(p["name"] == "health" for p in main["ports"]), main["ports"]
|
||||
api = next(p for p in main["ports"] if p["name"] == "api")
|
||||
assert api["containerPort"] == PORT and "hostPort" not in api and "hostIP" not in api, api
|
||||
assert [c["name"] for c in spec["initContainers"]] == ["tls-issue"], spec["initContainers"]
|
||||
|
|
@ -548,7 +549,7 @@ pkgs.testers.runNixOSTest {
|
|||
for _ in range(3):
|
||||
assert machine.execute(dials(other, ip, PORT))[0] != 0
|
||||
|
||||
with subtest("a client of the hive bridge and another pod cannot reach the controller's pod, and the node reads its health port"):
|
||||
with subtest("a client of the hive bridge and another pod cannot reach the controller's pod, and the health port answers on the pod's loopback only"):
|
||||
deny = json.loads(kube(machine, "get networkpolicy default-deny-ingress -o json"))["spec"]
|
||||
assert deny == {"podSelector": {}, "policyTypes": ["Ingress"]}, deny
|
||||
bridge_if = machine.succeed("ip -o -4 addr show | grep -F 'inet ${bridgeIp}/' | cut -d' ' -f2").strip()
|
||||
|
|
@ -559,8 +560,9 @@ pkgs.testers.runNixOSTest {
|
|||
"&& ip -n agent route add default via ${bridgeIp}"
|
||||
)
|
||||
pod_ip = kube(machine, f"get pod {pod_name} -o jsonpath='{{.status.podIP}}'").strip()
|
||||
code = machine.succeed(f"curl -s -o /dev/null -w '%{{http_code}}' --max-time 5 http://{pod_ip}:8080/healthz").strip()
|
||||
code = machine.succeed(f"nsenter --target {pod_pid(SERVICE)} --net -- curl -s -o /dev/null -w '%{{http_code}}' --max-time 5 http://127.0.0.1:8080/healthz").strip()
|
||||
assert code == "200", code
|
||||
assert machine.execute(f"curl -s -o /dev/null --max-time 5 http://{pod_ip}:8080/healthz")[0] == 7
|
||||
# The listener is reached by the node's own dial, the control that the
|
||||
# refusals below are the policy's.
|
||||
machine.succeed(f"timeout 5 bash -c '</dev/tcp/{pod_ip}/{PORT}'")
|
||||
|
|
|
|||
Loading…
Reference in a new issue