-
Notifications
You must be signed in to change notification settings - Fork 1
/
openshift_template.yml
216 lines (211 loc) · 5.74 KB
/
openshift_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
apiVersion: v1
kind: Template
metadata:
creationTimestamp: null
name: ${APPLICATION_NAME}_ocp_jenkins_build_template
objects:
# Used to build docker image with `oc start-build ${appName} --from-dir=. -n ${project}`
- kind: BuildConfig
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}
annotations:
pipeline.alpha.openshift.io/uses: '[{"name": "${APPLICATION_NAME}", "namespace": "", "kind": "DeploymentConfig"}]'
labels:
app: ${APPLICATION_NAME}
component: ${COMPONENT_NAME}
spec:
runPolicy: Serial
triggers: []
source:
type: Git
contextDir: ${WORKSPACE}
git:
name: bitbucket
ref: master
uri: ${GIT_URL}
sourceSecret:
name: bbpull
output:
to:
kind: ImageStreamTag
name: '${APPLICATION_NAME}:latest'
strategy:
type: Source
sourceStrategy:
from:
kind: ImageStreamTag
name: "nodejs-12:latest"
namespace: nodejsrestapi
# build config for the source code using jenkins pipeline
- kind: BuildConfig
apiVersion: v1
metadata:
annotations:
pipeline.alpha.openshift.io/uses: '[{"name": "${APPLICATION_NAME}", "namespace": "", "kind": "DeploymentConfig"}]'
labels:
app: ${APPLICATION_NAME}
component: ${COMPONENT_NAME}
name: ${APPLICATION_NAME}-pipeline
spec:
strategy:
type: JenkinsPipeline
jenkinsPipelineStrategy:
jenkinsfilePath: Jenkinsfile
env:
- name: APPLICATION_NAME
value: ${APPLICATION_NAME}
source:
type: Git
#contextDir: /
git:
name: bitbucket
ref: master
uri: ${GIT_URL}
sourceSecret:
name: bbpull
triggers:
- type: "Bitbucket"
bitbucket:
secret: FW4QqQ0VE2cVjsz9CK11oZJ3doat6mLZYQr3l265Emg
- kind: Secret
apiVersion: v1
metadata:
name: bbpull
namespace: nodejsrestapi
labels:
credential.sync.jenkins.openshift.io: 'true'
type: Opaque
data:
username: cDEzMzEyMzg=
password: TVRRMU5qUXdORGszTkRjMU9rdU1ENER0SXlGRjNuU1hhTldnK2hvUVZzYnM=
# image stream configuration
- apiVersion: v1
kind: ImageStream
metadata:
name: ${APPLICATION_NAME}
# deployment configuration
- apiVersion: v1
kind: DeploymentConfig
metadata:
name: ${APPLICATION_NAME}
labels:
component: ${COMPONENT_NAME}
app: ${APPLICATION_NAME}
spec:
replicas: 2
updateStrategy:
type: RollingUpdate
selector:
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}
strategy:
activeDeadlineSeconds: 21600
resources: {}
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
labels:
component: ${COMPONENT_NAME}
app: ${APPLICATION_NAME}
deploymentconfig: ${APPLICATION_NAME}
spec:
terminationGracePeriodSeconds: 10
containers:
- name: ${APPLICATION_NAME}
image: ${APPLICATION_NAME}
imagePullPolicy: Always
env:
- name: PORT
value: "8080"
- name: NODE_ENV
value: "default"
- name: LOGLEVEL
value: ${LOG_LEVEL}
- name: CONSUMER_TOPIC
value: ${APP_CONSUMER_TOPIC}
- name: PRODUCER_TOPIC
value: ${APP_PRODUCER_TOPIC}
- name: NSB_KAFKA_HOST
value: ${APPLICATION_KAFKA_HOST}
- name: JAEGER_SERVICE_NAME
value: ${JAEGER_SERVICE_NAME}
- name: JAEGER_ENDPOINT
value: ${JAEGER_ENDPOINT}
- name: JAEGER_SAMPLER_PARAM
value: ${JAEGER_SAMPLER_PARAM}
- name: ACTIVE_PROFILE
value: openshift
ports:
- containerPort: 8080
name: http
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 60
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 3
resources:
limits:
cpu: 250m
memory: 1024Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- ${APPLICATION_NAME}
from:
kind: ImageStreamTag
name: ${APPLICATION_NAME}:latest
type: ImageChange
# parameter for the openshift template
parameters:
- description: The component for the application.
name: COMPONENT_NAME
value: jenkins
- description: The name for the service of the application.
name: SERVICE_NAME
value: svc-nodejs-testrestapi
- description: The name for the application.
name: APPLICATION_NAME
value: nodejs-testrestapi
- description: Working Directory
name: WORKSPACE
value: /
- description: BitBucket repository URL.
name: GIT_URL
value: https://github.com/khteh/Node.JSRestAPI
- description: INFO or DEBUG log level.
name: LOG_LEVEL
value: DEBUG
- description: Active profile.
name: APPLICATION_ACTIVE_PROFILE
value: openshift