-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.nix
47 lines (42 loc) · 1.41 KB
/
timer.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{ lib, k8s, options, config, pkgs, ...}:
with lib;
let
convox-options = pkgs.callPackage ./options.nix {};
mkDeployment = pkgs.callPackage ./mkDeployment.nix { k8s = k8s; };
in {
kubernetes.moduleDefinitions.convox-timer.module = { name, config, ... }: {
imports = [];
options = (convox-options.timer { inherit name config; }).options;
config =
let
name = config.name;
labels = {
system = "convox-nix";
timer = name;
} // config.labels;
in {
kubernetes.resources.cronJobs.${name} = {
metadata.name = name;
metadata.labels = labels;
spec = {
schedule = config.schedule;
jobTemplate.spec.template = {
metadata.labels = labels;
spec.restartPolicy = "Never";
spec.serviceAccountName = mkIf (config.serviceOpts.serviceAccount != null) config.serviceOpts.serviceAccount;
spec.containers.${name} = (mkDeployment {
name = config.service;
config = config.serviceOpts;
labels = labels;
}).spec.template.spec.containers.${config.service} // {
command = mkIf (config.command != null) config.command;
ports = [];
readinessProbe = null;
livenessProbe = null;
};
};
};
};
};
};
}