Skip to content

Commit

Permalink
fix(trait): workaround Knative h2c port name
Browse files Browse the repository at this point in the history
Closes #6014
  • Loading branch information
squakez committed Jan 18, 2025
1 parent 34d8de6 commit 36a6389
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/trait/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (t *prometheusTrait) Apply(e *Environment) error {

// Add the PodMonitor resource
if ptr.Deref(t.PodMonitor, true) {
portName := containerPort.Name
portName := getPortName(containerPort.Name)
podMonitor, err := t.getPodMonitorFor(e, portName)
if err != nil {
return err
Expand All @@ -103,6 +103,15 @@ func (t *prometheusTrait) Apply(e *Environment) error {
return nil
}

func getPortName(portName string) string {
// This is a workaround to fix Knative behavior
// as described in https://github.com/apache/camel-k/issues/6014
if portName == defaultKnativeContainerPortName {
return "user-port"
}
return portName
}

func (t *prometheusTrait) getPodMonitorFor(e *Environment, portName string) (*monitoringv1.PodMonitor, error) {
labels, err := keyValuePairArrayAsStringMap(t.PodMonitorLabels)
if err != nil {
Expand Down

0 comments on commit 36a6389

Please sign in to comment.