eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
755 stars 500 forks source link

prometheus labels should use springboot/quarkus http port #328

Open survivant opened 4 years ago

survivant commented 4 years ago

I check the example : https://katacoda.com/jkubeio/courses/getting-started/spring-boot-quickstart

I didn't see any prometheus port but I see that the generated files use the port prometheus port.. but why not using the application port : 8080 ?

example : if I use actuator in Spring boot or Microprofile metrics.. the metrics are on the same port than the application http port. So the metrics so be on 8080.

So the labels should use that port

manusa commented 4 years ago

I'm not sure if I'm following.

If you add the spring boot actuator dependency:

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

JKube will detect this and add the appropriate healthchecks for your deployment:

# ...
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /actuator/health
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 10
            successThreshold: 1
# ...

Prometheus enricher is enabled by default because the effective Spring-Boot's base image has Prometheus support ("backwards" compatibility with Fabric8 Maven Plugin). In case you don't want these labels you can disable the Prometheus Enricher by:

          <plugin>
            <groupId>org.eclipse.jkube</groupId>
            <artifactId>kubernetes-maven-plugin</artifactId>
            <configuration>
              <!-- ... -->
              <enricher>
                <!-- ... -->
                <excludes>
                  <exclude>jkube-prometheus</exclude>
                </excludes>
              </enricher>
            </configuration>
          </plugin>

Or maybe just tune the configuration so that the application port is used instead:

<properties>
  <jkube.enricher.jkube-prometheus.prometheusPort>8080</jkube.enricher.jkube-prometheus.prometheusPort>
  <!-- ... -->
</proprties>

Or are you suggesting we should change/override the prometheus.io/port value in SpringBootHealtCheckEnricher in case the actuator is enabled? I see this as something problematic since other users may still expect the prometheus port to be 9779.

survivant commented 4 years ago

I was talking about prometheus.io/port I think it should use the port used by Springboot and if it's not the right port, it can be overridden in the pom.xml. At the end.. it should use the port where the metrics are.