-
Notifications
You must be signed in to change notification settings - Fork 0
/
kubetemplates.jsonnet
67 lines (64 loc) · 2.34 KB
/
kubetemplates.jsonnet
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
local kube = import "libkube.jsonnet";
local util = import "util.jsonnet";
{
RC(config):: {
local default_config = {
namespace: "default",
labels: {
name: "%s-%s" % [config.name, config.env],
version: config.version,
},
container: {
envvars: {
KUBE_ENV: config.env,
},
resources: {
memory_limit: "100m",
memory_requested: "100m",
cpu_limit: "1000",
cpu_requested: "1000",
},
}
},
local _config = util.merge(default_config, config),
version: "v1",
type: "ReplicationController",
metadata: {
name: _config.name,
namespace: _config.namespace,
labels: _config.labels,
},
spec: {
replicas: 1,
selector: _config.labels,
template: {
metadata: {
labels: _config.labels,
},
spec: {
containers: [
{
name: config.name,
image: "%s/%s:%s" % [ config.container.image.repository,
config.container.image.name,
config.container.image.tag ],
env: util.pair_list(_config.container.envvars),
mounts: kube.v1.VolumeMounts(_config.container.mounts),
resources: {
limits: {
memory: _config.container.resources.memory_limit,
cpu: _config.container.resources.cpu_limit,
},
requests: {
memory: _config.container.resources.memory_requested,
cpu: _config.container.resources.cpu_requested,
}
},
},
],
volumes: kube.v1.VolumeSources(_config.volumes),
},
},
},
},
}