-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkafka_and_zookeeper.yaml
255 lines (254 loc) · 6.45 KB
/
kafka_and_zookeeper.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
---
apiVersion: v1
kind: Service
metadata:
name: kafka-service
namespace: kafka
labels:
app: kafka
spec:
selector:
app: kafka
ports:
- name: http0
protocol: TCP
port: 920
targetPort: 920
- name: http1
protocol: TCP
port: 921
targetPort: 921
- name: http2
protocol: TCP
port: 922
targetPort: 922
- name: https0
protocol: TCP
port: 940
targetPort: 940
- name: https1
protocol: TCP
port: 941
targetPort: 941
- name: https2
protocol: TCP
port: 942
targetPort: 942
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: kafka-pdb
namespace: kafka
spec:
selector:
matchLabels:
app: kafka
maxUnavailable: 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kafka
namespace: kafka
spec:
replicas: 3
selector:
matchLabels:
app: kafka
template:
metadata:
labels:
app: kafka
spec:
volumes:
- name: secrets
secret:
secretName: "kafka-store"
items:
- key: kafka.keystore.jks
path: kafka.keystore.jks
- key: kafka.truststore.jks
path: kafka.truststore.jks
- key: key-creds
path: key-creds
- key: truststore-creds
path: truststore-creds
- key: keystore-creds
path: keystore-creds
initContainers:
- name: look-for-zookeeper-service
image: ubuntu:latest
command: ['sh', '-c', 'until getent hosts zookeeper-service.kafka.svc.cluster.local; do echo waiting for zookeeper; sleep 2; done;']
containers:
- name: kafka
volumeMounts:
- name: secrets
mountPath: /opt/kafka/config/certs
readOnly: true
image: ubuntu/kafka:edge
env:
- name: ZOOKEEPER_HOST
value: zookeeper-service.kafka.svc.cluster.local
args: ["/etc/kafka/server.properties", "--override", "inter.broker.listener.name=PLAINTEXT", "--override", "ssl.keystore.location=/opt/kafka/config/certs/kafka.keystore.jks", "--override", "ssl.keystore.password=password", "--override", "ssl.key.password=password", "--override", "ssl.truststore.location=/opt/kafka/config/certs/kafka.truststore.jks", "--override", "ssl.truststore.password=password", "--override", "ssl.enabled.protocols=TLSv1.2,TLSv1.1,TLSv1", "--override", "ssl.client.auth=required"]
ports:
- containerPort: 920
name: http0
protocol: TCP
- containerPort: 921
name: http1
protocol: TCP
- containerPort: 922
name: http2
protocol: TCP
- containerPort: 940
name: https0
protocol: TCP
- containerPort: 941
name: https1
protocol: TCP
- containerPort: 942
name: https2
protocol: TCP
lifecycle:
postStart:
exec:
command: ["bash", "-c", "Y=$(echo ${HOSTNAME} | awk -F '-' '{print $2}') ; echo \"broker.id=${Y}\" >> /etc/kafka/server.properties;echo \"listeners=PLAINTEXT://:92${Y},SSL://:94${Y}\" >> /etc/kafka/server.properties;echo \"advertised.listeners=SSL://${INGRESS_IP}:94${Y}, PLAINTEXT://kafka-service.kafka.svc.cluster.local:92${Y}\" >> /etc/kafka/server.properties"]
---
apiVersion: v1
kind: Service
metadata:
name: zookeeper-headless-service
namespace: kafka
labels:
app: zookeeper
spec:
ports:
- port: 2888
name: server
- port: 3888
name: leader-election
clusterIP: None
selector:
app: zookeeper
---
apiVersion: v1
kind: Service
metadata:
name: zookeeper-service
namespace: kafka
labels:
app: zookeeper
spec:
ports:
- port: 2181
name: client
selector:
app: zookeeper
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: zookeeper-pdb
namespace: kafka
spec:
selector:
matchLabels:
app: zookeeper
maxUnavailable: 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: zookeeper
namespace: kafka
spec:
selector:
matchLabels:
app: zookeeper
serviceName: zookeeper-headless-service
replicas: 3
updateStrategy:
type: RollingUpdate
podManagementPolicy: OrderedReady
template:
metadata:
labels:
app: zookeeper
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- zookeeper
topologyKey: "kubernetes.io/hostname"
containers:
- name: kubernetes-zookeeper
imagePullPolicy: Always
image: "registry.k8s.io/kubernetes-zookeeper:1.0-3.4.10"
resources:
requests:
memory: "1Gi"
cpu: "0.5"
ports:
- containerPort: 2181
name: client
- containerPort: 2888
name: server
- containerPort: 3888
name: leader-election
command:
- sh
- -c
- "start-zookeeper \
--servers=3 \
--data_dir=/var/lib/zookeeper/data \
--data_log_dir=/var/lib/zookeeper/data/log \
--conf_dir=/opt/zookeeper/conf \
--client_port=2181 \
--election_port=3888 \
--server_port=2888 \
--tick_time=2000 \
--init_limit=10 \
--sync_limit=5 \
--heap=512M \
--max_client_cnxns=60 \
--snap_retain_count=3 \
--purge_interval=12 \
--max_session_timeout=40000 \
--min_session_timeout=4000 \
--log_level=INFO"
readinessProbe:
exec:
command:
- sh
- -c
- "zookeeper-ready 2181"
initialDelaySeconds: 10
timeoutSeconds: 5
livenessProbe:
exec:
command:
- sh
- -c
- "zookeeper-ready 2181"
initialDelaySeconds: 10
timeoutSeconds: 5
volumeMounts:
- name: datadir
mountPath: /var/lib/zookeeper
securityContext:
runAsUser: 1000
fsGroup: 1000
volumeClaimTemplates:
- metadata:
name: datadir
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 10Gi