1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.heapster;
7in {
8 options.services.heapster = {
9 enable = mkOption {
10 description = "Whether to enable heapster monitoring";
11 default = false;
12 type = types.bool;
13 };
14
15 source = mkOption {
16 description = "Heapster metric source";
17 example = "kubernetes:https://kubernetes.default";
18 type = types.string;
19 };
20
21 sink = mkOption {
22 description = "Heapster metic sink";
23 example = "influxdb:http://localhost:8086";
24 type = types.string;
25 };
26
27 extraOpts = mkOption {
28 description = "Heapster extra options";
29 default = "";
30 type = types.string;
31 };
32
33 package = mkOption {
34 description = "Package to use by heapster";
35 default = pkgs.heapster;
36 defaultText = "pkgs.heapster";
37 type = types.package;
38 };
39 };
40
41 config = mkIf cfg.enable {
42 systemd.services.heapster = {
43 wantedBy = ["multi-user.target"];
44 after = ["cadvisor.service" "kube-apiserver.service"];
45
46 serviceConfig = {
47 ExecStart = "${cfg.package}/bin/heapster --source=${cfg.source} --sink=${cfg.sink} ${cfg.extraOpts}";
48 User = "heapster";
49 };
50 };
51
52 users.extraUsers = singleton {
53 name = "heapster";
54 uid = config.ids.uids.heapster;
55 description = "Heapster user";
56 };
57 };
58}