Repository: provectus/kafka-ui
Issue: Liveness and Readiness probes failing
Labels: type/bug
status/pending
status/accepted
scope/infrastructure
scope/k8s

Hello!

First of all, congrats to you all, kafka-ui is such a nice project!

We wrote a Helm Chart to deploy Kafka UI in a Kubernetes cluster, using version 0.3.0. 
We are facing the following issue when using liveness and readiness probes in the k8s deployment:
`Readiness probe failed: HTTP probe failed with statuscode: 404`

Even using different paths like `/actuator/health`, `/actuator/info` and `login` that are declared [here](https://github.com/provectus/kafka-ui/blob/master/kafka-ui-api/src/main/java/com/provectus/kafka/ui/config/auth/AbstractAuthSecurityConfig.java) the probes are failing. Also, we checked the Helm Chart [deployment](https://github.com/provectus/kafka-ui/blob/master/charts/kafka-ui/templates/deployment.yaml#L54-L73) you provided.

**Set up**
- Kafka UI - Version: 0.3.0
- Docker image: provectuslabs/kafka-ui:0.3.0
- The Helm Chart applied in the cluster has the following liveness and readiness probes:

```
ports:
   - name: view
     containerPort: 8080
     protocol: TCP
livenessProbe:
  httpGet:
    path: /actuator/health
    port: view
  initialDelaySeconds: 60
  periodSeconds: 30
  timeoutSeconds: 10
readinessProbe:
  httpGet:
    path: /actuator/health
    port: view
  initialDelaySeconds: 60
  periodSeconds: 30
  timeoutSeconds: 10
```

Removing the probes, it is possible to use Kafka UI normally in an integration environment in Kubernetes cluster, but we really need the probes before deploying in production.

Thanks a lot!



Issue comments:
Hello there nandacamargo! 👋

Thank you and congratulations 🎉 for opening your very first issue in this project! 💖

In case you want to claim this issue, please comment down below! We will try to get back to you as soon as we can. 👀
Hi, thanks for reaching out.
Does the app work itself? Which authentication mechanism (if any) are you using?
Hi!

Yes, the app works and an additional information that might help is that besides testing with Kafka-UI version 0.3.0, we currently have the same app working in the cluster running with version 0.2.0. It works using the old liveness/readiness probe:
`path: /index.html`.

Since there are some changes/fixes in Kafka-UI version 0.3.0, we decided to update our deployment to keep up to date. So initially we tried using the probes with `/index.html` path for version 0.3.0 as well, but they failed, so we tried with different [paths](https://github.com/provectus/kafka-ui/blob/master/kafka-ui-api/src/main/java/com/provectus/kafka/ui/config/auth/AbstractAuthSecurityConfig.java) mentioned previously, without success.

Regarding to the authentication mechanism, we are using environment variable `AUTH_TYPE`, with value `LOGIN_FORM`, passing an username and password.

Thanks!
@nandacamargo thanks much for the detailed feedback!
This is to be fixed within #1339 and we'll release a separate build shortly after.
Great! Thank you so much! 
@Haarolean Hi. I set `SERVER_SERVLET_CONTEXT_PATH: "/kafka-ui"` 

My logs:

```
2023-01-29 18:22:41,591 INFO  [background-preinit] o.h.v.i.u.Version: HV000001: Hibernate Validator 6.2.5.Final
2023-01-29 18:22:41,905 INFO  [main] c.p.k.u.KafkaUiApplication: Starting KafkaUiApplication using Java 17.0.5 on kafka-ui-5d458c5d-v2pfq with PID 1 (/kafka-ui-api.jar started by kafkaui in /)
2023-01-29 18:22:41,907 DEBUG [main] c.p.k.u.KafkaUiApplication: Running with Spring Boot v2.7.5, Spring v5.3.23
2023-01-29 18:22:43,028 INFO  [main] c.p.k.u.KafkaUiApplication: No active profile set, falling back to 1 default profile: "default"
2023-01-29 18:24:12,400 DEBUG [main] c.p.k.u.s.SerdesInitializer: Configuring serdes for cluster shortlink
```

I get:

```
Readiness probe failed: Get "http://10.233.102.248:8080/kafka-ui/actuator/health"
Liveness probe failed: Get "http://10.233.102.248:8080/kafka-ui/actuator/health":
```

What can we do about this problem?

source: https://github.com/shortlink-org/shortlink/blob/main/ops/Helm/addons/mq/kafka/values.yaml
@batazor hey, please raise a new discussion (or feel free to chat with me on [our discord](https://discord.gg/4DWzD7pGE5)), and provide the info regarding what you see/get when you visit the probe URLs

Pull request review comments:

Patch that resolved the issue:
diff --git a/kafka-ui-api/src/main/resources/application.yml b/kafka-ui-api/src/main/resources/application.yml
index a68453bf337..a6a4c8e9716 100644
--- a/kafka-ui-api/src/main/resources/application.yml
+++ b/kafka-ui-api/src/main/resources/application.yml
@@ -1,6 +1,7 @@
 auth:
   type: DISABLED
-  management:
+
+management:
   endpoint:
     info:
       enabled: true
@@ -10,6 +11,9 @@ auth:
     web:
       exposure:
         include: "info,health"
+  health:
+    ldap:
+      enabled: false
 
 logging:
   level:


Test patch: