From 19c25dbd792a60c0444cc2eede7a950caac74e12 Mon Sep 17 00:00:00 2001 From: Chris Bartholomew Date: Thu, 9 Dec 2021 23:34:55 -0500 Subject: [PATCH] Function worker liveness probe works with token authentication enabled (#92) --- .../templates/function/function-statefulset.yaml | 12 +++++++++--- .../pulsar/templates/utils/health-configmap.yaml | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/helm-chart-sources/pulsar/templates/function/function-statefulset.yaml b/helm-chart-sources/pulsar/templates/function/function-statefulset.yaml index 9ccc637..247fe9c 100644 --- a/helm-chart-sources/pulsar/templates/function/function-statefulset.yaml +++ b/helm-chart-sources/pulsar/templates/function/function-statefulset.yaml @@ -124,6 +124,10 @@ spec: {{- end }} terminationGracePeriodSeconds: {{ .Values.function.gracePeriod }} volumes: + - name: health + configMap: + name: "{{ template "pulsar.fullname" . }}-health" + defaultMode: 0755 - name: config-volume configMap: name: "{{ template "pulsar.fullname" . }}-{{ .Values.function.component }}" @@ -196,9 +200,9 @@ spec: periodSeconds: {{ .Values.function.probe.period }} timeoutSeconds: {{ .Values.function.probe.timeout }} livenessProbe: - httpGet: - path: {{ .Values.function.probe.metricsPath | default "/metrics" }} - port: {{ .Values.function.probe.port }} + exec: + command: + - "/pulsar/health/function_worker_health_check.sh" initialDelaySeconds: {{ .Values.function.probe.initial }} periodSeconds: {{ .Values.function.probe.period }} timeoutSeconds: {{ .Values.function.probe.timeout }} @@ -252,6 +256,8 @@ spec: value: 'true' {{- end }} volumeMounts: + - name: health + mountPath: /pulsar/health {{- if .Values.enableTokenAuth }} - mountPath: "/pulsar/token-superuser" name: token-superuser diff --git a/helm-chart-sources/pulsar/templates/utils/health-configmap.yaml b/helm-chart-sources/pulsar/templates/utils/health-configmap.yaml index 2005b1e..9899bde 100644 --- a/helm-chart-sources/pulsar/templates/utils/health-configmap.yaml +++ b/helm-chart-sources/pulsar/templates/utils/health-configmap.yaml @@ -42,3 +42,11 @@ data: {{- else }} curl -s --max-time {{ .Values.broker.probe.timeout }} --fail http://localhost:8080/admin/v2/brokers/health {{- end }} + + function_worker_health_check.sh: | + #!/bin/bash + {{- if .Values.enableTokenAuth }} + curl -s --max-time {{ .Values.proxy.probe.timeout }} --fail -H "Authorization: Bearer $(cat /pulsar/token-superuser/superuser.jwt | tr -d '\r')" http://localhost:{{ .Values.function.probe.port }}/metrics/ > /dev/null + {{- else }} + curl -s --max-time {{ .Values.proxy.probe.timeout }} --fail http://localhost:{{ .Values.function.probe.port }}/metrics/ > /dev/null + {{- end }}