-
Notifications
You must be signed in to change notification settings - Fork 0
/
okd-app_example-simple.template.yml
333 lines (329 loc) · 10.7 KB
/
okd-app_example-simple.template.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
kind: Template
apiVersion: template.openshift.io/v1
metadata:
name: sxapi-example-simple-template
annotations:
openshift.io/display-name: SXAPI simple example application (embeded configmap)
description: Template for creating a simple SXAPI example where configuration
(embeded in template) is stored in a configMap object
for more information see https://hub.docker.com/r/startx/sxapi
iconClass: icon-nodejs
tags: sxapi,api,nodejs,startx,microservice
openshift.io/provider-display-name: STARTX
openshift.io/documentation-url: https://hub.docker.com/r/startx/sxapi
openshift.io/support-url: https://github.com/startxfr/sxapi-core/issues/new
labels:
template: sxapi-example-simple-template
provider: startx
technology: sxapi
message: |-
Your application ${APPLICATION_NAME} will be soon deployed in your project.
Monitor the deployement for application availability
Application : ${APPLICATION_NAME}
sxapi : ${IMAGE_NAME}:${IMAGE_VERSION}
config : configmap ${APPLICATION_NAME} (yaml)
Pods : ${REPLICAS_DATA} (${MEMORY_LIMIT})
service : ${APPLICATION_NAME} -> 8077
objects:
- kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
name: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Application image stream ${APPLICATION_NAME} based on ${IMAGE_NAME} ${IMAGE_VERSION}
openshift.io/generated-by: STARTX
spec:
tags:
- name: ${IMAGE_VERSION}
annotations:
openshift.io/display-name: SXAPI container image (${IMAGE_NAME} ${IMAGE_VERSION})
description: SXAPI image for the application ${APPLICATION_NAME} based on ${IMAGE_NAME} ${IMAGE_VERSION}
iconClass: icon-nodejs
tags: sxapi,api,nodejs,startx,microservice,${APPLICATION_NAME},${IMAGE_NAME}:${IMAGE_VERSION}
from:
kind: DockerImage
name: ${IMAGE_NAME}:${IMAGE_VERSION}
- kind: ConfigMap
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
labels:
app: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Sxapi configuration ${APPLICATION_NAME}
openshift.io/generated-by: STARTX
data:
sxapi.yml: |
name: sxapi-dev-simple
description: sxapi simple microservice API ({{{NODE_ENV}}}). You can find out more at http://startx.fr/api
termsOfService: http://startx.fr/api#termOfService
contactName: Dev STARTX
contactMail: [email protected]
licence: GPL v2.0
version: 0.0.1
debug: "{{{SX_DEBUG}}}"
session:
duration: 3600
auto_create: true
transport:
type: cookie
cookie_name: sxapi-sess
backend:
type: memory
sid_field: token_sess
fields:
stop: datefin_sess
resources:
serviceinfo-sample:
_class: serviceinfo
swagger-sample:
_class: swagger
websocket-sample:
_class: websocket-client
host: http://localhost:{{{APP_PORT}}}
log:
filters:
level: '0,1,2,3,4,5'
type: "{{#SX_DEBUG}}debug,{{/SX_DEBUG}}info,error,warn"
server:
port: '{{{APP_PORT}}}'
lib: "/conf/mylib"
static:
- path: "/test"
dir: "/test"
enableWebsockets: true
websockets:
events:
- event: example
handler: "$ws.websockets.onMessageDefaultCallback"
- event: exampleGlobal
handler: "$ws.lib.mySocketEndpointFunction"
- event: disconnect
handler: "$ws.websockets.onMessageDefaultCallback"
endpoints:
- path: "/"
description: Display welcome message (HTML)
body:
- "<html>"
- "<head><title>Application {{name}}</title></head>"
- <link rel="stylesheet" href="https://goo.gl/4kFNLH">
- <body><div class="container">
- <h1><span class="glyphicon glyphicon-eye-open"></span> Your API {{name}} is
live !</h1>
- <div class="alert alert-success" role="alert"><p>This API is {{description}}
running on <b>{{hostname}}</b> with current release <b>v{{version}}</b></p></div>
- <div class="alert alert-info" role="alert"><p>The application signature is <b>{{appsign}}</b>
and corespond to a blank project.</p></div>
- "<p>Default config file must be changed and replaced your <b>own sxapi.yml</b>
config file."
- You will then be able to build your own API resources and endpoints.<br>
- For more informations please visit <a href="https://github.com/startxfr/sxapi-core"
target="">sxapi project documentation</a>.</p>
- <nav class="navbar navbar-default navbar-fixed-bottom"><div class="container">
Microservice engine is <b>{{package.name}} v{{package.version}}</b>. {{package.description}}</div></nav>
- "</div></body>"
- "</html>"
- path: "/health"
description: Return health check for this API instance
resource: serviceinfo-sample
endpoint: health
- path: "/info"
description: Return information about this API instance
resource: serviceinfo-sample
endpoint: info
- path: "/swagger"
resource: swagger-sample
description: Return a swagger manifest for this API
endpoint: manifest
- path: "/ping"
description: Ping the application. Return a sample message in json
code: '200'
body: pong
- path: "/function"
description: Test and dedicated function. Return a sample message in json
handler: "$ws.dynamicRequestHandlerTest"
- path: "/function2"
description: Test user-defined fonction to get return and acces to low level resources
handler: "$ws.lib.myEndpointFunction"
param_sample: dev-config
mylib.js: |
/* global resConf, $log */
//'use strict';
var mylib = {
myEndpointFunction: function (config) {
return function (req, res) {
res.writeHead(200);
res.end("this text is an example param " + config.param_sample);
$log.tools.endpointDebug("defaultEndpoint", req, " return dynamic example content", 2);
return this;
};
},
mySocketEndpointFunction: function (client, config) {
return function (data) {
console.log("------mySocketEndpointFunction");
console.log(client.id, config, data);
client.broadcast.emit("example", data);
client.emit("example", data);
};
}
};
module.exports = mylib;
- kind: DeploymentConfig
apiVersion: apps.openshift.io/v1
metadata:
name: "${APPLICATION_NAME}"
labels:
app: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Deployement ${APPLICATION_NAME} application
openshift.io/generated-by: STARTX
spec:
replicas: 2
strategy:
type: Rolling
rollingParams:
updatePeriodSeconds: 1
intervalSeconds: 1
timeoutSeconds: 60
maxUnavailable: 25%
maxSurge: 25%
triggers:
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- "${APPLICATION_NAME}"
from:
kind: ImageStreamTag
name: "${APPLICATION_NAME}:${IMAGE_VERSION}"
- type: ConfigChange
test: false
selector:
app: "${APPLICATION_NAME}"
deploymentconfig: "${APPLICATION_NAME}"
template:
metadata:
labels:
app: "${APPLICATION_NAME}"
deploymentconfig: "${APPLICATION_NAME}"
annotations:
openshift.io/generated-by: STARTX
spec:
terminationGracePeriodSeconds: 5
containers:
- name: "${APPLICATION_NAME}"
image: " "
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 2
tcpSocket:
port: 8077
timeoutSeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
readinessProbe:
initialDelaySeconds: 2
tcpSocket:
port: 8077
timeoutSeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
lifecycle:
preStart:
exec:
command:
- npm
- audit
- fix
preStop:
exec:
command:
- npm
- stop
ports:
- name: sxapi-http
containerPort: 8077
env:
- name: APP_PORT
value: '8077'
resources:
requests:
cpu: 200m
memory: "${MEMORY_LIMIT}"
limits:
cpu: 2000m
memory: "${MEMORY_LIMIT}"
terminationMessagePath: "/dev/termination-log"
volumeMounts:
- mountPath: "/conf"
name: conf
restartPolicy: Always
volumes:
- name: conf
configMap:
name: "${APPLICATION_NAME}"
items:
- key: sxapi.yml
path: sxapi.yml
- key: mylib.js
path: mylib.js
- kind: Service
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
labels:
app: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Service ${APPLICATION_NAME}
openshift.io/generated-by: STARTX
spec:
clusterIP: None
ports:
- name: sxapi-http
protocol: TCP
port: 8077
targetPort: 8077
selector:
app: "${APPLICATION_NAME}"
deploymentconfig: "${APPLICATION_NAME}"
- kind: Route
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
labels:
app: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Route ${APPLICATION_NAME}
openshift.io/generated-by: STARTX
spec:
port:
targetPort: sxapi-http
to:
kind: Service
name: "${APPLICATION_NAME}"
weight: 100
wildcardPolicy: None
parameters:
- name: APPLICATION_NAME
displayName: Application Name
description: The name of the application.
value: sxapi-simple-example
required: true
- name: IMAGE_VERSION
value: "0.3.66"
required: true
- name: IMAGE_NAME
value: "startx/sxapi"
required: true
- name: REPLICAS_DATA
displayName: Desired Pod count for data nodes
description: How many data nodes should be provisioned? This value can be changed
later, by scaling up/down.
value: '2'
required: true
- name: MEMORY_LIMIT
displayName: Memory Limit for data nodes
description: Maximum amount of memory data container can use.
value: 128Mi