diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go index f1d84db32e..619cb324cb 100644 --- a/pkg/trait/knative.go +++ b/pkg/trait/knative.go @@ -292,14 +292,14 @@ func (t *knativeTrait) extractNames(names string) []string { // buildServiceDefinitionFromStatus creates a CamelServiceDefinition from a Knative ServiceStatus func buildServiceDefinitionFromStatus(name string, serviceType knativeapi.CamelServiceType, status serving.ServiceStatus) (knativeapi.CamelServiceDefinition, error) { - // build it using the Route URL information if available - if status.URL != nil && status.URL.Host != "" { - return knativeapi.BuildCamelServiceDefinition(name, serviceType, url.URL(*status.URL)) - } - // fallback to using the addressable + // use cluster-local URL from the addressable if status.Address != nil { return buildServiceDefinition(name, serviceType, *status.Address) } + // fallback to using the public URL information if available + if status.URL != nil && status.URL.Host != "" { + return knativeapi.BuildCamelServiceDefinition(name, serviceType, url.URL(*status.URL)) + } return knativeapi.CamelServiceDefinition{}, errors.New("cannot determine service hostname") }