Watch
0
0
Fork
You've already forked hyperhive
0

bind health listeners to the pod's loopback and probe them by exec

This commit is contained in:
atlas 2026-11-27 23:45:00 +01:00
commit 62cc95671d

View file

@ -60,7 +60,12 @@ let
# `serviceUser` is the user every image runs its daemon as. Mounted files are
# group-owned by its group through `fsGroup`.
inherit (import ../../images { inherit pkgs lib; }) mkServiceImage serviceUser;
inherit (import ../../images { inherit pkgs lib; })
mkServiceImage
serviceUser
wgetOnly
loopbackProbe
;
# `DRAIN` in swarm-secret-client/src/shutdown.rs: how long a daemon keeps
# finishing in-flight work after SIGTERM before it exits on its own. The
@ -444,7 +449,7 @@ let
# runs in the cluster, because the `hostPort` they bind is forwarded to them
# before the policy sees the packet. The policy selects every pod of the
# service for ingress too and allows none, so only the node's own traffic
# (the kubelet's probes, which the policy engine always admits) reaches it.
# (which the policy engine always admits) reaches it.
networkPolicyOf =
name: reaches:
let
@ -686,7 +691,7 @@ let
// lib.optionalAttrs (runtimeDir != null) { RUNTIME_DIRECTORY = runtimeDir; }
// lib.optionalAttrs (stateDir != null) { STATE_DIRECTORY = stateDir; }
// lib.optionalAttrs (svc.healthEnv != null) {
${svc.healthEnv} = "0.0.0.0:${toString healthPort}";
${svc.healthEnv} = "127.0.0.1:${toString healthPort}";
};
mountRoots = [
@ -713,9 +718,11 @@ let
inherit name;
inherit (svc) package;
bin = daemon;
extraContents = lib.optional (storeValues != [ ]) (
pkgs.writeTextDir "share/hyperhive/${name}.env-refs" (lib.concatLines storeValues)
);
extraContents =
lib.optional (storeValues != [ ]) (
pkgs.writeTextDir "share/hyperhive/${name}.env-refs" (lib.concatLines storeValues)
)
++ lib.optional (svc.healthEnv != null) wgetOnly;
};
# A systemd `%d` in an argument is the credential directory, as in the
@ -896,16 +903,12 @@ let
cpu = "0";
};
# The listener's Service targets this port by its name.
ports =
lib.optional (svc.healthEnv != null) {
name = "health";
containerPort = healthPort;
}
++ lib.optional (listener != { }) {
name = "api";
containerPort = listener.port;
};
# The listener's Service targets this port by its name. The health
# listener is not a port: it binds to the pod's loopback.
ports = lib.optional (listener != { }) {
name = "api";
containerPort = listener.port;
};
container = {
inherit name volumeMounts;
@ -962,20 +965,8 @@ let
};
}
// lib.optionalAttrs (svc.healthEnv != null) {
livenessProbe = {
httpGet = {
path = "/healthz";
port = "health";
};
periodSeconds = 10;
};
readinessProbe = {
httpGet = {
path = "/readyz";
port = "health";
};
periodSeconds = 10;
};
livenessProbe = loopbackProbe healthPort "/healthz";
readinessProbe = loopbackProbe healthPort "/readyz";
};
# The listener's leaf: issued before the daemon starts, renewed beside it.
@ -1253,7 +1244,7 @@ in
# anyone, so a pod is reachable from the node alone until a policy of its own
# admits more. The cluster's policy engine takes the union of the policies
# that select a pod and always admits the node's own addresses, so the
# kubelet's probes and the host's gateway still reach every pod. A port a pod
# host's gateway still reaches every pod. A port a pod
# opens later is closed to the other pods and to the hive bridge without a
# line here.
// {