-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathokd-app_example-bot.template.yml
320 lines (316 loc) · 9.89 KB
/
okd-app_example-bot.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
kind: Template
apiVersion: template.openshift.io/v1
metadata:
name: sxapi-example-bot-template
annotations:
openshift.io/display-name: SXAPI bot example application (embeded configmap)
description: Template for creating an SXAPI bot 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-bot-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-bot
description: sxapi bot microservice API ({{{NODE_ENV}}}). You can find out more at http://startx.fr/api
termsOfService: http://startx.fr/api#termOfService
contactName: Dev STARTX
contactMail: dev@startx.fr
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
sqs-example:
_class: aws_sqs
send_options:
DelaySeconds: 2
MessageAttributes:
from:
DataType: String
StringValue: startx
QueueUrl: https://sqs.eu-west-3.amazonaws.com/11111111111111111/my-queue
ACCESS_ID: XXXXXXXXXXXXX
ACCESS_KEY: XXXXXXXXXXXXX
region: eu-west-3
twitter-example:
_class: twitter
consumer_key: XXXXXXXXXXXXX
consumer_secret: XXXXXXXXXXXXX
access_token_key: XXXXXXXXXXXXX
access_token_secret: XXXXXXXXXXXXX
log:
filters:
level: '0,1,2,3,4'
type: "{{#SX_DEBUG}}debug,{{/SX_DEBUG}}info,error,warn"
server:
port: '{{{APP_PORT}}}'
endpoints:
- path: "/"
description: Display welcome message (HTML)
body: "<html><head><title>sxapi-core API</title></head><body><h1>Your API is live
!</h1><p>This API is based on sxapi-core v0.3.66 and use default config file.
You can now start to configure your sxapi.yml config file in order to build
your own API </p></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
bot:
lib: "/conf/mylib"
cron:
- id: example-cront-task
name: Execute example cron task
schedule: "*/1 * * * *"
task: myCronFunction
readers:
sqs:
- resource: sqs-example
frequency: 5
config:
MaxNumberOfMessages: 2
VisibilityTimeout: 2
filters:
- id: example-sqs-task
event: event:type
task: myReaderFunction
twitter:
- resource: twitter-example
filters:
- id: example-twitter-startx
match: "#paris"
task: myTwitterFunction
- id: example-twitter-startx
match: "#london"
task: myTwitterFunction
mylib.js: |
/* global resConf, $log */
//'use strict';
var mylib = {
myCronFunction: function (config) {
var moment = require('moment');
$log.info("cron task " + config.id + " executed at " + moment().format('YYYY-MM-DD HH:mm:ss'));
},
myReaderFunction: function (data, message, config) {
var moment = require('moment');
$log.info("sqs reader " + config.id + " executed at " + moment().format('YYYY-MM-DD HH:mm:ss'));
console.log(data);
},
myTwitterFunction: function (data, message, config) {
var moment = require('moment');
$log.info("twitter reader " + config.id + " found tweet " + data.id_str);
// console.log(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}"
parameters:
- name: APPLICATION_NAME
displayName: Application Name
description: The name of the application.
value: sxapi-bot-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: '1'
required: true
- name: MEMORY_LIMIT
displayName: Memory Limit for data nodes
description: Maximum amount of memory data container can use.
value: 128Mi