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
|
|
@ -53,22 +53,51 @@ let
|
|||
};
|
||||
};
|
||||
|
||||
# `wget` and nothing else of busybox: the smallest HTTP client an image can
|
||||
# hold. A health listener binds to the pod's loopback, so the kubelet probes
|
||||
# it from inside the container with this.
|
||||
wgetOnly = pkgs.runCommand "wget-only" { } ''
|
||||
mkdir -p $out/bin
|
||||
ln -s ${pkgs.pkgsStatic.busybox}/bin/busybox $out/bin/wget
|
||||
'';
|
||||
|
||||
# An `exec` probe that GETs `path` on the loopback `port`. `wget` exits
|
||||
# non-zero on any non-2xx status, so a 503 fails the probe.
|
||||
loopbackProbe = port: path: {
|
||||
exec.command = [
|
||||
"/bin/wget"
|
||||
"-q"
|
||||
"-O"
|
||||
"/dev/null"
|
||||
"http://127.0.0.1:${toString port}${path}"
|
||||
];
|
||||
periodSeconds = 10;
|
||||
timeoutSeconds = 5;
|
||||
};
|
||||
|
||||
daemon =
|
||||
name:
|
||||
extraContents: name:
|
||||
mkServiceImage {
|
||||
inherit name;
|
||||
inherit name extraContents;
|
||||
package = packages.${name};
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit mkServiceImage registryHost serviceUser;
|
||||
inherit
|
||||
mkServiceImage
|
||||
registryHost
|
||||
serviceUser
|
||||
wgetOnly
|
||||
loopbackProbe
|
||||
;
|
||||
|
||||
images = lib.genAttrs [
|
||||
"swarm-controller"
|
||||
"swarm-nats-auth"
|
||||
"swarm-logs-auth"
|
||||
"swarm-metrics-auth"
|
||||
"swarm-notify-router"
|
||||
"swarm-ci-metrics"
|
||||
] daemon;
|
||||
images =
|
||||
lib.genAttrs [
|
||||
"swarm-controller"
|
||||
"swarm-nats-auth"
|
||||
"swarm-logs-auth"
|
||||
"swarm-metrics-auth"
|
||||
"swarm-notify-router"
|
||||
] (daemon [ wgetOnly ])
|
||||
// lib.genAttrs [ "swarm-ci-metrics" ] (daemon [ ]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue