1
1
local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet' ;
2
2
3
3
{
4
- local gateway = self ,
4
+ local api = self ,
5
5
6
6
config:: {
7
7
name: error 'must provide name' ,
@@ -14,15 +14,15 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
14
14
writeEndpoint: error 'must provide writeEndpoint' ,
15
15
16
16
commonLabels:: {
17
- 'app.kubernetes.io/name' : 'observatorium-api-gateway ' ,
18
- 'app.kubernetes.io/instance' : gateway .config.name,
19
- 'app.kubernetes.io/version' : gateway .config.version,
20
- 'app.kubernetes.io/component' : 'api-gateway ' ,
17
+ 'app.kubernetes.io/name' : 'observatorium-api' ,
18
+ 'app.kubernetes.io/instance' : api .config.name,
19
+ 'app.kubernetes.io/version' : api .config.version,
20
+ 'app.kubernetes.io/component' : 'api' ,
21
21
},
22
22
23
23
podLabelSelector:: {
24
- [labelName]: gateway .config.commonLabels[labelName]
25
- for labelName in std.objectFields (gateway .config.commonLabels)
24
+ [labelName]: api .config.commonLabels[labelName]
25
+ for labelName in std.objectFields (api .config.commonLabels)
26
26
if !std.setMember (labelName, ['app.kubernetes.io/version' ])
27
27
},
28
28
},
@@ -32,27 +32,27 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
32
32
local ports = service.mixin.spec.portsType;
33
33
34
34
service.new(
35
- gateway .config.name,
36
- gateway .config.podLabelSelector,
35
+ api .config.name,
36
+ api .config.podLabelSelector,
37
37
[
38
38
ports.newNamed('http' , 8080 , 8080 ),
39
39
],
40
40
) +
41
- service.mixin.metadata.withNamespace(gateway .config.namespace) +
42
- service.mixin.metadata.withLabels(gateway .config.commonLabels),
41
+ service.mixin.metadata.withNamespace(api .config.namespace) +
42
+ service.mixin.metadata.withLabels(api .config.commonLabels),
43
43
44
44
deployment:
45
45
local deployment = k.apps.v1.deployment;
46
46
local container = deployment.mixin.spec.template.spec.containersType;
47
47
local containerPort = container.portsType;
48
48
49
49
local c =
50
- container.new('observatorium-api-gateway ' , gateway .config.image) +
50
+ container.new('observatorium-api' , api .config.image) +
51
51
container.withArgs([
52
52
'--web.listen=0.0.0.0:8080' ,
53
- '--metrics.ui.endpoint=' + gateway .config.uiEndpoint,
54
- '--metrics.read.endpoint=' + gateway .config.readEndpoint,
55
- '--metrics.write.endpoint=' + gateway .config.writeEndpoint,
53
+ '--metrics.ui.endpoint=' + api .config.uiEndpoint,
54
+ '--metrics.read.endpoint=' + api .config.readEndpoint,
55
+ '--metrics.write.endpoint=' + api .config.writeEndpoint,
56
56
'--log.level=warn' ,
57
57
]) +
58
58
container.withPorts(
@@ -61,36 +61,36 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
61
61
container.mixin.livenessProbe +
62
62
container.mixin.livenessProbe.withPeriodSeconds(30 ) +
63
63
container.mixin.livenessProbe.withFailureThreshold(8 ) +
64
- container.mixin.livenessProbe.httpGet.withPort(gateway .service.spec.ports[0 ].port) +
64
+ container.mixin.livenessProbe.httpGet.withPort(api .service.spec.ports[0 ].port) +
65
65
container.mixin.livenessProbe.httpGet.withScheme('HTTP' ) +
66
66
container.mixin.livenessProbe.httpGet.withPath('/-/healthy' ) +
67
67
container.mixin.readinessProbe +
68
68
container.mixin.readinessProbe.withPeriodSeconds(5 ) +
69
69
container.mixin.readinessProbe.withFailureThreshold(20 ) +
70
- container.mixin.readinessProbe.httpGet.withPort(gateway .service.spec.ports[0 ].port) +
70
+ container.mixin.readinessProbe.httpGet.withPort(api .service.spec.ports[0 ].port) +
71
71
container.mixin.readinessProbe.httpGet.withScheme('HTTP' ) +
72
72
container.mixin.readinessProbe.httpGet.withPath('/-/ready' );
73
73
74
- deployment.new(gateway .config.name, gateway .config.replicas, c, gateway .config.commonLabels) +
75
- deployment.mixin.metadata.withNamespace(gateway .config.namespace) +
76
- deployment.mixin.metadata.withLabels(gateway .config.commonLabels) +
77
- deployment.mixin.spec.selector.withMatchLabels(gateway .config.podLabelSelector) +
74
+ deployment.new(api .config.name, api .config.replicas, c, api .config.commonLabels) +
75
+ deployment.mixin.metadata.withNamespace(api .config.namespace) +
76
+ deployment.mixin.metadata.withLabels(api .config.commonLabels) +
77
+ deployment.mixin.spec.selector.withMatchLabels(api .config.podLabelSelector) +
78
78
deployment.mixin.spec.strategy.rollingUpdate.withMaxSurge(0 ) +
79
79
deployment.mixin.spec.strategy.rollingUpdate.withMaxUnavailable(1 ),
80
80
81
81
withServiceMonitor:: {
82
- local gateway = self ,
82
+ local api = self ,
83
83
84
84
serviceMonitor: {
85
85
apiVersion: 'monitoring.coreos.com/v1' ,
86
86
kind: 'ServiceMonitor' ,
87
87
metadata+: {
88
- name: gateway .config.name,
89
- namespace: gateway .config.namespace,
88
+ name: api .config.name,
89
+ namespace: api .config.namespace,
90
90
},
91
91
spec: {
92
92
selector: {
93
- matchLabels: gateway .config.commonLabels,
93
+ matchLabels: api .config.commonLabels,
94
94
},
95
95
endpoints: [
96
96
{ port: 'http' },
@@ -100,7 +100,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
100
100
},
101
101
102
102
withResources:: {
103
- local gateway = self ,
103
+ local api = self ,
104
104
105
105
config+:: {
106
106
resources: error 'must provide resources' ,
@@ -111,8 +111,8 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
111
111
template+: {
112
112
spec+: {
113
113
containers: [
114
- if c.name == 'observatorium-api-gateway ' then c {
115
- resources: gateway .config.resources,
114
+ if c.name == 'observatorium-api' then c {
115
+ resources: api .config.resources,
116
116
} else c
117
117
for c in super .containers
118
118
],
@@ -123,7 +123,7 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
123
123
},
124
124
125
125
withTLS:: {
126
- local gateway = self ,
126
+ local api = self ,
127
127
128
128
config+:: {
129
129
tls: {
@@ -139,12 +139,12 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
139
139
template+: {
140
140
spec+: {
141
141
containers: [
142
- if c.name == 'observatorium-api-gateway ' then c {
142
+ if c.name == 'observatorium-api' then c {
143
143
args+: [
144
- '--tls-cert-file=' + gateway .config.tls.certFile,
145
- '--tls-private-key-file=' + gateway .config.tls.privateKeyFile,
146
- '--tls-client-ca-file=' + gateway .config.tls.clientCAFile,
147
- '--tls-reload-interval=' + gateway .config.tls.reloadInterval,
144
+ '--tls-cert-file=' + api .config.tls.certFile,
145
+ '--tls-private-key-file=' + api .config.tls.privateKeyFile,
146
+ '--tls-client-ca-file=' + api .config.tls.clientCAFile,
147
+ '--tls-reload-interval=' + api .config.tls.reloadInterval,
148
148
],
149
149
} else c
150
150
for c in super .containers
0 commit comments