Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 45231ef

Browse files
add readiness probe to kafka pod (#672)
1 parent 909a57c commit 45231ef

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

‎helm/openwhisk/templates/_readiness.tpl‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
{{/* Init container that waits for kafka to be ready */}}
3434
{{- define "openwhisk.readiness.waitForKafka" -}}
3535
- name: "wait-for-kafka"
36-
image: "{{- .Values.docker.registry.name -}}{{- .Values.busybox.imageName -}}:{{- .Values.busybox.imageTag -}}"
36+
image: "{{- .Values.docker.registry.name -}}{{- .Values.utility.imageName -}}:{{- .Values.utility.imageTag -}}"
3737
imagePullPolicy: "IfNotPresent"
38-
# TODO: I haven't found an easy external test to determine that kafka is up, so as a hack we wait for zookeeper and then sleep for 10 seconds and cross our fingers!
39-
command: ["sh", "-c", 'result=1; until [ $result -eq 0 ]; do OK=$(echo ruok | nc -w 1 {{ include "openwhisk.zookeeper_zero_host" . }} {{ .Values.zookeeper.port }}); if [ "$OK" == "imok" ]; then result=0; echo "zookeeper returned imok!"; else echo waiting for zookeeper to be ready; sleep 1; fi done; echo "Zookeeper is up; will wait for 10 seconds to give kafka time to initialize"; sleep 10;']
38+
command: ["sh", "-c", 'cacert="/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"; token="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)"; while true; do rc=$(curl -sS --cacert $cacert --header "Authorization: Bearer $token" https://kubernetes.default.svc/api/v1/namespaces/{{ .Release.Namespace }}/endpoints/{{ .Release.Name }}-kafka | jq -r ".subsets[].addresses | length"); echo "num ready kafka endpoints is $rc"; if [ $rc -gt 0 ]; then echo "Success: ready kafka endpoint!"; break; fi; echo "kafka not ready yet; sleeping for 3 seconds"; sleep 3; done;']
4039
{{- end -}}
4140

4241
{{/* Init container that waits for zookeeper to be ready */}}

‎helm/openwhisk/templates/kafka-pod.yaml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ spec:
7373
ports:
7474
- containerPort: {{ .Values.kafka.port }}
7575
name: kafka
76+
77+
livenessProbe:
78+
tcpSocket:
79+
port: {{ .Values.kafka.port }}
80+
initialDelaySeconds: {{ .Values.probes.kafka.livenessProbe.initialDelaySeconds }}
81+
periodSeconds: {{ .Values.probes.kafka.livenessProbe.periodSeconds }}
82+
timeoutSeconds: {{ .Values.probes.kafka.livenessProbe.timeoutSeconds }}
83+
readinessProbe:
84+
initialDelaySeconds: {{ .Values.probes.kafka.readinessProbe.initialDelaySeconds }}
85+
periodSeconds: {{ .Values.probes.kafka.readinessProbe.periodSeconds }}
86+
timeoutSeconds: {{ .Values.probes.kafka.readinessProbe.timeoutSeconds }}
87+
exec:
88+
command:
89+
- /opt/kafka/bin/kafka-topics.sh
90+
- localhost:{{ .Values.kafka.port }}
91+
- --version
7692
env:
7793
- name: "HOSTNAME_COMMAND"
7894
value: "hostname -f"

‎helm/openwhisk/values.yaml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ probes:
446446
initialDelaySeconds: 5
447447
periodSeconds: 10
448448
timeoutSeconds: 1
449+
kafka:
450+
livenessProbe:
451+
initialDelaySeconds: 5
452+
periodSeconds: 10
453+
timeoutSeconds: 1
454+
readinessProbe:
455+
initialDelaySeconds: 5
456+
periodSeconds: 10
457+
timeoutSeconds: 5
449458
controller:
450459
livenessProbe:
451460
initialDelaySeconds: 10

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /