From 67f5edad2e57bbdad4f9a3ee41d23661a8fdca4d Mon Sep 17 00:00:00 2001
From: John Mazzitelli <mazz@redhat.com>
Date: Tue, 12 Nov 2024 07:56:22 -0500
Subject: [PATCH] make some changes for best practices (#298)

* add terminationMessagePolicy, set to FallbackToLogsOnError

* probes
---
 kiali-operator/templates/deployment.yaml | 19 +++++++++++++++++++
 kiali-server/templates/deployment.yaml   | 15 ++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/kiali-operator/templates/deployment.yaml b/kiali-operator/templates/deployment.yaml
index 14f4967..923055b 100644
--- a/kiali-operator/templates/deployment.yaml
+++ b/kiali-operator/templates/deployment.yaml
@@ -50,6 +50,25 @@ spec:
         - "--zap-log-level=info"
         - "--leader-election-id={{ include "kiali-operator.fullname" . }}"
         - "--watches-file=./$(WATCHES_FILE)"
+        - "--health-probe-bind-address=:6789"
+        terminationMessagePolicy: FallbackToLogsOnError
+        readinessProbe:
+          httpGet:
+            path: /readyz
+            port: 6789
+          periodSeconds: 30
+        livenessProbe:
+          httpGet:
+            path: /healthz
+            port: 6789
+          periodSeconds: 30
+        startupProbe:
+          httpGet:
+            path: /healthz
+            port: 6789
+          initialDelaySeconds: 30
+          periodSeconds: 10
+          failureThreshold: 6
         securityContext:
         {{- if .Values.securityContext }}
         {{- toYaml .Values.securityContext | nindent 10 }}
diff --git a/kiali-server/templates/deployment.yaml b/kiali-server/templates/deployment.yaml
index 2c39233..46f7c37 100644
--- a/kiali-server/templates/deployment.yaml
+++ b/kiali-server/templates/deployment.yaml
@@ -72,6 +72,7 @@ spec:
         - "/opt/kiali/kiali"
         - "-config"
         - "/kiali-configuration/config.yaml"
+        terminationMessagePolicy: FallbackToLogsOnError
         securityContext:
         {{- if .Values.deployment.security_context}}
         {{- toYaml .Values.deployment.security_context | nindent 10 }}
@@ -113,6 +114,18 @@ spec:
             {{- end }}
           initialDelaySeconds: 5
           periodSeconds: 30
+        startupProbe:
+          httpGet:
+            path: {{ include "kiali-server.server.web_root" . | trimSuffix "/"  }}/healthz
+            port: api-port
+            {{- if (include "kiali-server.identity.cert_file" .) }}
+            scheme: HTTPS
+            {{- else }}
+            scheme: HTTP
+            {{- end }}
+          initialDelaySeconds: 30
+          periodSeconds: 10
+          failureThreshold: 6
         env:
         - name: ACTIVE_NAMESPACE
           valueFrom:
@@ -227,4 +240,4 @@ spec:
       {{- toYaml .Values.deployment.node_selector | nindent 8 }}
       {{- end }}
 ...
-{{- end }}
\ No newline at end of file
+{{- end }}