-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdeployment.yaml
More file actions
289 lines (267 loc) · 11.9 KB
/
deployment.yaml
File metadata and controls
289 lines (267 loc) · 11.9 KB
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
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "debezium.fullname" . }}-connect
labels:
{{- include "debezium.labels.connect" . | nindent 4 }}
spec:
{{- if not .Values.connect.autoscaling.enabled }}
replicas: {{ .Values.connect.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "debezium.selectorLabels.connect" . | nindent 6 }}
template:
metadata:
{{- with .Values.connect.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "debezium.selectorLabels.connect" . | nindent 8 }}
spec:
{{- with .Values.connect.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "debezium.name" . }}-connect
defaultMode: 0744
containers:
- name: {{ .Chart.Name }}-connect
image: "{{ .Values.connect.image.repository }}:{{ .Values.connect.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.connect.image.pullPolicy }}
ports:
- name: {{ .Values.connect.service.name }}
containerPort: {{ .Values.connect.service.port }}
protocol: {{ .Values.connect.service.protocol }}
resources:
{{- toYaml .Values.connect.resources | nindent 12 }}
{{- if not .Values.connect.properties.probe }}
livenessProbe:
initialDelaySeconds: 600 # Wait 180s after container starts before first check
periodSeconds: 20 # Check every 20s
timeoutSeconds: 5 # Timeout for each check
failureThreshold: 3 # Mark container unhealthy after 3 consecutive failures
exec:
command:
- /bin/sh
- -c
- |
# Get the list of all connectors from Debezium REST API
connectors=($(curl --request GET "http://127.0.0.1:8083/connectors"))
# Clean the array string and load into array
echo "Clean the array string and load into array"
cleaned_connector_names=$(sed 's/[][]//g; s/"//g' <<< "$connectors")
IFS=',' read -r -a my_array <<< "$cleaned_connector_names"
# If no connectors found, container is not ready
if (( ${#my_array[@]} == 0 )); then
echo "No connectors found, container is not healthy"
exit 1
fi
# Loop through each connector to check its state
for connector in "${my_array[@]}"; do
echo "Getting Connector task status : $connector"
status=$(curl --request GET http://localhost:8083/connectors/$connector/status)
# Check the main connector state
connector_state=$(echo "$status" | grep -o '"state":"[^"]*"' | head -n1 | cut -d':' -f2 | tr -d '"')
if [ "$connector_state" != "RUNNING" ]; then
exit 1
fi
# Check states of all tasks for this connector
task_states=$(echo "$status" | grep -o '"state":"[^"]*"' | tail -n +2 | cut -d':' -f2 | tr -d '"')
for task_state in $task_states; do
if [ "$task_state" != "RUNNING" ]; then
exit 1
fi
done
done
# If all connectors and tasks are running, container is healthy
exit 0
{{- end }}
# Readiness probe: Checks if container is ready to accept traffic
{{- if not .Values.connect.properties.probe }}
readinessProbe:
initialDelaySeconds: 600
periodSeconds: 20
timeoutSeconds: 5
failureThreshold: 3
exec:
command:
- /bin/sh
- -c
- |
# Get the list of all connectors from Debezium REST API
connectors=($(curl --request GET "http://127.0.0.1:8083/connectors"))
# Clean the array string and load into array
echo "Clean the array string and load into array"
cleaned_connector_names=$(sed 's/[][]//g; s/"//g' <<< "$connectors")
IFS=',' read -r -a my_array <<< "$cleaned_connector_names"
# If no connectors found, container is not ready
if (( ${#my_array[@]} == 0 )); then
echo "No connectors found, container is not healthy"
exit 1
fi
# Loop through each connector to check its state
for connector in "${my_array[@]}"; do
echo "Getting Connector task status : $connector"
status=$(curl --request GET http://localhost:8083/connectors/$connector/status)
# Check the main connector state
connector_state=$(echo "$status" | grep -o '"state":"[^"]*"' | head -n1 | cut -d':' -f2 | tr -d '"')
if [ "$connector_state" != "RUNNING" ]; then
exit 1
fi
# Check states of all tasks for this connector
task_states=$(echo "$status" | grep -o '"state":"[^"]*"' | tail -n +2 | cut -d':' -f2 | tr -d '"')
for task_state in $task_states; do
if [ "$task_state" != "RUNNING" ]; then
exit 1
fi
done
done
# If all connectors and tasks are running, container is ready
exit 0
{{- end }}
volumeMounts:
- name: config
mountPath: /etc/debezium/connector-odse.json
subPath: connector-odse.json
- name: config
mountPath: /etc/debezium/connector-srte.json
subPath: connector-srte.json
- name: config
mountPath: /etc/debezium/connector-meta.json
subPath: connector-meta.json
- name: config
mountPath: /kafka/config/log4j.properties
subPath: log4j.properties
- name: config
mountPath: /kafka/config/connect-distributed.properties
subPath: connect-distributed.properties
{{- with .Values.connect.env }}
env:
{{- toYaml . | nindent 12}}
{{- end}}
command: ['/kafka/bin/connect-distributed.sh', '/kafka/config/connect-distributed.properties']
lifecycle:
postStart:
exec:
#command: [ '/bin/sh', '-c', 'sleep 60; curl --request POST --header "Accept:application/json" --header "Content-Type:application/json" "http://127.0.0.1:8083/connectors/" --data "@/etc/debezium/connector.json"' ]
command:
- "/bin/sh"
- "-c"
- |
#0. Sleeping for 1 min
echo "Sleeping for 1 min"
sleep 60;
#1. Get the running connectors
echo "Get the running connectors"
connectors=($(curl --request GET "http://127.0.0.1:8083/connectors"))
#2. Clean the array string
echo "Clean the array string"
cleaned_connector_names=$(sed 's/[][]//g; s/"//g' <<< "$connectors")
# 3. Iterate and delete running debezium connector tasks
echo "Iterate and delete running debezium connector tasks"
IFS=',' read -r -a my_array <<< "$cleaned_connector_names"
for task in "${my_array[@]}"; do
echo "Deleting Connector task : $task"
curl --request DELETE "http://127.0.0.1:8083/connectors/$task"
done
#4. Starting SRTE task if enabled
if [ "{{ lower .Values.connect.connector_enable.nbs_srte }}" == "enabled" ]; then
echo "Starting SRTE task with SRTE configuration"
curl --request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data '@/etc/debezium/connector-srte.json' \
"http://127.0.0.1:8083/connectors/" || echo "Failed to start SRTE connector";
fi
#5. Starting ODSE task if enabled
if [ "{{ lower .Values.connect.connector_enable.nbs_odse }}" == "enabled" ]; then
echo "Starting ODSE task with ODSE configuration"
curl --request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data '@/etc/debezium/connector-odse.json' \
"http://127.0.0.1:8083/connectors/" || echo "Failed to start ODSE connector";
fi
#6. Starting ODSE_META task if enabled
if [ "{{ lower .Values.connect.connector_enable.nbs_odse_meta }}" == "enabled" ]; then
echo "Starting ODSE-META task with config: $(cat /etc/debezium/connector-meta.json)"
curl --request POST \
--header "Accept:application/json" \
--header "Content-Type:application/json" \
--data '@/etc/debezium/connector-meta.json' \
"http://127.0.0.1:8083/connectors/";
fi
connectors=($(curl --request GET "http://127.0.0.1:8083/connectors"))
echo "Successfully running connectors: $connectors"
{{- with .Values.connect.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.connect.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.connect.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
---
{{- if .Values.ui.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "debezium.fullname" . }}-ui
labels:
{{- include "debezium.labels.ui" . | nindent 4 }}
spec:
{{- if not .Values.ui.autoscaling.enabled }}
replicas: {{ .Values.ui.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "debezium.selectorLabels.ui" . | nindent 6 }}
template:
metadata:
{{- with .Values.ui.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "debezium.selectorLabels.ui" . | nindent 8 }}
spec:
{{- with .Values.ui.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-ui
image: "{{ .Values.ui.image.repository }}:{{ .Values.ui.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.ui.image.pullPolicy }}
ports:
- name: {{ .Values.ui.service.name}}
containerPort: 80
protocol: TCP
resources:
{{- toYaml .Values.ui.resources | nindent 12 }}
{{- with .Values.ui.env }}
env:
{{- toYaml . | nindent 12}}
{{- end}}
{{- with .Values.ui.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ui.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.ui.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end}}