This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 38e1d2ae9633dfe2da9c4e9c368e6641b9829b7e Author: Antonin Stefanutti <[email protected]> AuthorDate: Fri May 29 18:58:55 2020 +0200 fix(prometheus): Do not declare Prometheus container port when Knative is enabled --- pkg/trait/prometheus.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go index e1e1f9e..c20f054 100644 --- a/pkg/trait/prometheus.go +++ b/pkg/trait/prometheus.go @@ -121,9 +121,16 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) { options := []string{strconv.Itoa(t.Port), path.Join(prometheusJmxExporterConfigMountPath, prometheusJmxExporterConfigFileName)} container.Args = append(container.Args, "-javaagent:dependencies/io.prometheus.jmx.jmx_prometheus_javaagent-0.3.1.jar="+strings.Join(options, ":")) - // Add the container port + // Configure the Prometheus container port containerPort := t.getContainerPort() - container.Ports = append(container.Ports, *containerPort) + controller, err := e.DetermineControllerStrategy(t.Ctx, t.Client) + if err != nil { + return err + } + // Skip declaring the Prometheus port when Knative is enabled, as only one container port is supported + if controller != ControllerStrategyKnativeService { + container.Ports = append(container.Ports, *containerPort) + } condition.Message = fmt.Sprintf("%s(%s/%d)", container.Name, containerPort.Name, containerPort.ContainerPort) // Retrieve the service or create a new one if the service trait is enabled
