forked from strimzi/strimzi-kafka-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openshift-template.yaml
325 lines (325 loc) · 10 KB
/
openshift-template.yaml
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
apiVersion: v1
kind: Template
metadata:
name: bananas-multiservice
annotations:
openshift.io/display-name: "Kafka Stateful Persistent Multiservice"
description: >-
This template installes Apache Zookeeper and Apache Kafka clusters. For more information
about using this template see https://github.com/strimzi/strimzi
tags: "messaging,datastore"
iconClass: "fa pficon-topology"
template.openshift.io/documentation-url: "https://github.com/strimzi/strimzi"
message: "Use 'kafka:9092' as bootstrap server in your application"
parameters:
- description: Number of Zookeper cluster nodes which will be deployed (odd number of nodes is recomended)
displayName: Number of Zookeper cluster nodes (odd number of nodes is recomended)
name: ZOOKEEPER_NODE_COUNT
required: true
value: "3"
- description: Number of Kafka cluster nodes which will be deployed
displayName: Number of Kafka cluster nodes
name: KAFKA_NODE_COUNT
required: true
value: "3"
- description: Volume space available for Zookeeper data, e.g. 512Mi, 2Gi.
displayName: Zookeeper Volume Capacity
name: ZOOKEEPER_VOLUME_CAPACITY
required: true
value: 1Gi
- description: Volume space available for Kafka data, e.g. 512Mi, 2Gi.
displayName: Kafka Volume Capacity
name: KAFKA_VOLUME_CAPACITY
required: true
value: 1Gi
- description: Image repository name
displayName: Repository Name
name: IMAGE_REPO_NAME
value: strimzi
- description: Kafka image name
displayName: Kafka image Name
name: KAFKA_IMAGE_NAME
value: kafka-statefulsets
- description: Kafka image tag
displayName: Kafka image tag
name: KAFKA_IMAGE_TAG
value: latest
- description: Zookeeper image name
displayName: Zookeeper image Name
name: ZOOKEEPER_IMAGE_NAME
value: zookeeper
- description: Zookeeper image tag
displayName: Zookeeper image tag
name: ZOOKEEPER_IMAGE_TAG
value: latest
- description: Number of seconds after the container has started before healthcheck probes are initiated.
displayName: Zookeeper healthcheck initial delay
name: ZOOKEEPER_HEALTHCHECK_DELAY
value: "15"
- description: Number of seconds after which the probe times out.
displayName: Zookeeper healthcheck timeout
name: ZOOKEEPER_HEALTHCHECK_TIMEOUT
value: "5"
- description: Number of seconds after the container has started before healthcheck probes are initiated.
displayName: Kafka healthcheck initial delay
name: KAFKA_HEALTHCHECK_DELAY
value: "15"
- description: Number of seconds after which the probe times out.
displayName: Kafka healthcheck timeout
name: KAFKA_HEALTHCHECK_TIMEOUT
value: "5"
- description: Default replication factor for newly created topics
displayName: Default replication factor
name: KAFKA_DEFAULT_REPLICATION_FACTOR
value: "1"
- description: Replication factor for offsets topic
displayName: Offsets replication factor
name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "3"
- description: Replication factor for transactions state log topic
displayName: Transaction state replication factor
name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
value: "3"
- description: true to enable metric collection from Kafka
displayName: Kafka metrics enabled
name: KAFKA_METRICS_ENABLED
value: "true"
- description: true to enable metric collection from Zookeeper
displayName: Zookeeper metrics enabled
name: ZOOKEEPER_METRICS_ENABLED
value: "true"
objects:
- apiVersion: v1
kind: Service
metadata:
name: kafka-${KAFKA_IMAGE_NAME}
spec:
ports:
- name: kafka
port: 9092
targetPort: 9092
protocol: TCP
selector:
name: kafka
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
name: kafka-headless-${KAFKA_IMAGE_NAME}
spec:
ports:
- name: kafka
port: 9092
targetPort: 9092
protocol: TCP
selector:
name: kafka
type: ClusterIP
clusterIP: None
- apiVersion: v1
kind: Service
metadata:
name: zookeeper-${ZOOKEEPER_IMAGE_NAME}
spec:
ports:
- name: clientport
port: 2181
targetPort: 2181
protocol: TCP
selector:
name: zookeeper
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
name: zookeeper-headless-${ZOOKEEPER_IMAGE_NAME}
spec:
ports:
- name: clientport
port: 2181
targetPort: 2181
protocol: TCP
- name: clustering
port: 2888
targetPort: 2888
protocol: TCP
- name: leaderelection
port: 3888
targetPort: 3888
protocol: TCP
selector:
name: zookeeper
type: ClusterIP
clusterIP: None
- apiVersion: v1
kind: ConfigMap
metadata:
name: kafka-metrics-config-${KAFKA_IMAGE_NAME}
data:
config.yml: |
lowercaseOutputName: true
rules:
- pattern: kafka.server<type=(.+), name=(.+)PerSec\w*><>Count
name: kafka_server_$1_$2_total
- pattern : kafka.server<type=(.+), name=(.+)PerSec\w*, topic=(.+)><>Count
name: kafka_server_$1_$2_total
labels:
topic: "$3"
- apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
labels:
name: kafka-${KAFKA_IMAGE_NAME}
name: kafka-${KAFKA_IMAGE_NAME}
spec:
replicas: ${KAFKA_NODE_COUNT}
selector:
matchLabels:
name: kafka-${KAFKA_IMAGE_NAME}
serviceName: kafka-headless-${ZOOKEEPER_IMAGE_NAME}
template:
metadata:
labels:
name: kafka-${KAFKA_IMAGE_NAME}
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "9404"
spec:
containers:
- name: kafka-${KAFKA_IMAGE_NAME}
image: ${IMAGE_REPO_NAME}/${KAFKA_IMAGE_NAME}:${KAFKA_IMAGE_TAG}
imagePullPolicy: Always
ports:
- name: kafka
containerPort: 9092
protocol: TCP
- name: kafkametrics
containerPort: 9404
protocol: TCP
env:
- name: KAFKA_DEFAULT_REPLICATION_FACTOR
value: "${KAFKA_DEFAULT_REPLICATION_FACTOR}"
- name: KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR
value: "${KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR}"
- name: KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR
value: "${KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR}"
- name: KAFKA_METRICS_ENABLED
value: "${KAFKA_METRICS_ENABLED}"
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/kafka/
name: kafka-storage
- mountPath: /opt/prometheus/config/
name: kafka-metrics-config
livenessProbe:
exec:
command:
- "/opt/kafka/kafka_healthcheck.sh"
initialDelaySeconds: ${ZOOKEEPER_HEALTHCHECK_DELAY}
timeoutSeconds: ${ZOOKEEPER_HEALTHCHECK_TIMEOUT}
readinessProbe:
exec:
command:
- "/opt/kafka/kafka_healthcheck.sh"
initialDelaySeconds: ${ZOOKEEPER_HEALTHCHECK_DELAY}
timeoutSeconds: ${ZOOKEEPER_HEALTHCHECK_TIMEOUT}
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
- name: kafka-metrics-config-${KAFKA_IMAGE_NAME}
configMap:
name: kafka-metrics-config-${KAFKA_IMAGE_NAME}
volumeClaimTemplates:
- metadata:
name: kafka-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "${KAFKA_VOLUME_CAPACITY}"
- apiVersion: v1
kind: ConfigMap
metadata:
name: zookeeper-metrics-config-${ZOOKEEPER_IMAGE_NAME}
data:
config.yml: |
lowercaseOutputName: true
- apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
labels:
name: zookeeper-${ZOOKEEPER_IMAGE_NAME}
name: zookeeper-${ZOOKEEPER_IMAGE_NAME}
spec:
replicas: ${ZOOKEEPER_NODE_COUNT}
selector:
matchLabels:
name: zookeeper-${ZOOKEEPER_IMAGE_NAME}
serviceName: zookeeper-headless-${ZOOKEEPER_IMAGE_NAME}
template:
metadata:
labels:
name: zookeeper-${ZOOKEEPER_IMAGE_NAME}
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "9404"
spec:
containers:
- name: zookeeper-${ZOOKEEPER_IMAGE_NAME}
image: ${IMAGE_REPO_NAME}/${ZOOKEEPER_IMAGE_NAME}:${ZOOKEEPER_IMAGE_TAG}
imagePullPolicy: Always
ports:
- name: clientport
containerPort: 2181
protocol: TCP
- name: clustering
containerPort: 2888
protocol: TCP
- name: leaderelection
containerPort: 3888
protocol: TCP
- name: kafkametrics
containerPort: 9404
protocol: TCP
env:
- name: ZOOKEEPER_NODE_COUNT
value: ${ZOOKEEPER_NODE_COUNT}
- name: ZOOKEEPER_METRICS_ENABLED
value: "${ZOOKEEPER_METRICS_ENABLED}"
volumeMounts:
- mountPath: /var/lib/zookeeper
name: zookeeper-storage
- mountPath: /opt/prometheus/config/
name: zookeeper-metrics-config
livenessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: ${KAFKA_HEALTHCHECK_DELAY}
timeoutSeconds: ${KAFKA_HEALTHCHECK_TIMEOUT}
readinessProbe:
exec:
command:
- "/opt/zookeeper/zookeeper_healthcheck.sh"
initialDelaySeconds: ${KAFKA_HEALTHCHECK_DELAY}
timeoutSeconds: ${KAFKA_HEALTHCHECK_TIMEOUT}
dnsPolicy: ClusterFirst
restartPolicy: Always
volumes:
- name: zookeeper-metrics-config-${ZOOKEEPER_IMAGE_NAME}
configMap:
name: zookeeper-metrics-config-${ZOOKEEPER_IMAGE_NAME}
volumeClaimTemplates:
- metadata:
name: zookeeper-storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "${ZOOKEEPER_VOLUME_CAPACITY}"