-
Notifications
You must be signed in to change notification settings - Fork 4
/
configuration.nix
40 lines (36 loc) · 1.08 KB
/
configuration.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
{ type ? "dev" }:
let
kubeVersion = "1.11";
helloApp = rec {
label = "hello";
port = 3000;
cpu = if type == "dev" then "100m" else "1000m";
imagePolicy = if type == "dev" then "Never" else "IfNotPresent";
env = [{ name = "APP_PORT"; value = "${toString port}"; }];
};
in
{
kubernetes.version = kubeVersion;
kubernetes.resources.deployments."${helloApp.label}" = {
metadata.labels.app = helloApp.label;
spec = {
replicas = 1;
selector.matchLabels.app = helloApp.label;
template = {
metadata.labels.app = helloApp.label;
spec.containers."${helloApp.label}" = {
name = "${helloApp.label}";
image = "hello-app:latest";
imagePullPolicy = helloApp.imagePolicy;
env = helloApp.env;
resources.requests.cpu = helloApp.cpu;
ports."${toString helloApp.port}" = {};
};
};
};
};
kubernetes.resources.services."${helloApp.label}" = {
spec.selector.app = "${helloApp.label}";
spec.ports."${toString helloApp.port}".targetPort = helloApp.port;
};
}