This is an automated email from the ASF dual-hosted git repository.

dgrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-deploy-kube.git


The following commit(s) were added to refs/heads/master by this push:
     new 45231ef  add readiness probe to kafka pod (#672)
45231ef is described below

commit 45231eff61718b858f34d65a63e8b0f81ee89380
Author: David Grove <[email protected]>
AuthorDate: Tue Mar 16 15:20:59 2021 -0400

    add readiness probe to kafka pod (#672)
---
 helm/openwhisk/templates/_readiness.tpl |  5 ++---
 helm/openwhisk/templates/kafka-pod.yaml | 16 ++++++++++++++++
 helm/openwhisk/values.yaml              |  9 +++++++++
 3 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/helm/openwhisk/templates/_readiness.tpl 
b/helm/openwhisk/templates/_readiness.tpl
index e5bc7d5..da6a0fe 100644
--- a/helm/openwhisk/templates/_readiness.tpl
+++ b/helm/openwhisk/templates/_readiness.tpl
@@ -33,10 +33,9 @@
 {{/* Init container that waits for kafka to be ready */}}
 {{- define "openwhisk.readiness.waitForKafka" -}}
 - name: "wait-for-kafka"
-  image: "{{- .Values.docker.registry.name -}}{{- .Values.busybox.imageName 
-}}:{{- .Values.busybox.imageTag -}}"
+  image: "{{- .Values.docker.registry.name -}}{{- .Values.utility.imageName 
-}}:{{- .Values.utility.imageTag -}}"
   imagePullPolicy: "IfNotPresent"
-  # 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!
-  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;']
+  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 endpoin [...]
 {{- end -}}
 
 {{/* Init container that waits for zookeeper to be ready */}}
diff --git a/helm/openwhisk/templates/kafka-pod.yaml 
b/helm/openwhisk/templates/kafka-pod.yaml
index f49d30f..82265e7 100644
--- a/helm/openwhisk/templates/kafka-pod.yaml
+++ b/helm/openwhisk/templates/kafka-pod.yaml
@@ -73,6 +73,22 @@ spec:
         ports:
         - containerPort: {{ .Values.kafka.port }}
           name: kafka
+
+        livenessProbe:
+          tcpSocket:
+            port: {{ .Values.kafka.port }}
+          initialDelaySeconds: {{ 
.Values.probes.kafka.livenessProbe.initialDelaySeconds }}
+          periodSeconds: {{ .Values.probes.kafka.livenessProbe.periodSeconds }}
+          timeoutSeconds: {{ .Values.probes.kafka.livenessProbe.timeoutSeconds 
}}
+        readinessProbe:
+          initialDelaySeconds: {{ 
.Values.probes.kafka.readinessProbe.initialDelaySeconds }}
+          periodSeconds: {{ .Values.probes.kafka.readinessProbe.periodSeconds 
}}
+          timeoutSeconds: {{ 
.Values.probes.kafka.readinessProbe.timeoutSeconds }}
+          exec:
+            command:
+            - /opt/kafka/bin/kafka-topics.sh
+            - localhost:{{ .Values.kafka.port }}
+            - --version
         env:
         - name: "HOSTNAME_COMMAND"
           value: "hostname -f"
diff --git a/helm/openwhisk/values.yaml b/helm/openwhisk/values.yaml
index 9997320..e4ca1a3 100644
--- a/helm/openwhisk/values.yaml
+++ b/helm/openwhisk/values.yaml
@@ -446,6 +446,15 @@ probes:
       initialDelaySeconds: 5
       periodSeconds: 10
       timeoutSeconds: 1
+  kafka:
+    livenessProbe:
+      initialDelaySeconds: 5
+      periodSeconds: 10
+      timeoutSeconds: 1
+    readinessProbe:
+      initialDelaySeconds: 5
+      periodSeconds: 10
+      timeoutSeconds: 5
   controller:
     livenessProbe:
       initialDelaySeconds: 10

Reply via email to