diff --git a/controllers/constants/constants.go b/controllers/constants/constants.go index dcca08a8..cd654cfd 100644 --- a/controllers/constants/constants.go +++ b/controllers/constants/constants.go @@ -1,6 +1,8 @@ package constants const ( - IstioNamespace = "istio-system" - IstioIngressService = "istio-ingressgateway" + IstioNamespace = "istio-system" + IstioIngressService = "istio-ingressgateway" + IstioIngressServiceHTTPPortName = "http2" + IstioIngressServiceHTTPSPortName = "https" ) diff --git a/controllers/reconcilers/kisvc_route_reconciler.go b/controllers/reconcilers/kisvc_route_reconciler.go index 2e1b960a..573d2f7a 100644 --- a/controllers/reconcilers/kisvc_route_reconciler.go +++ b/controllers/reconcilers/kisvc_route_reconciler.go @@ -96,6 +96,20 @@ func (r *kserveInferenceServiceRouteReconciler) createDesiredResource() (*v1.Rou annotations := utils.Filter(r.isvc.Annotations, func(key string) bool { return !utils.Includes(constants.ServiceAnnotationDisallowedList, key) }) + + urlScheme := ingressConfig.UrlScheme + var targetPort intstr.IntOrString + var tlsConfig *v1.TLSConfig + if urlScheme == "http" { + targetPort = intstr.FromString(constants2.IstioIngressServiceHTTPPortName) + } else { + targetPort = intstr.FromString(constants2.IstioIngressServiceHTTPSPortName) + tlsConfig = &v1.TLSConfig{ + Termination: v1.TLSTerminationPassthrough, + InsecureEdgeTerminationPolicy: v1.InsecureEdgeTerminationPolicyRedirect, + } + } + route := &v1.Route{ ObjectMeta: metav1.ObjectMeta{ Name: GetKServeRouteName(r.isvc), @@ -111,12 +125,9 @@ func (r *kserveInferenceServiceRouteReconciler) createDesiredResource() (*v1.Rou Weight: pointer.Int32(100), }, Port: &v1.RoutePort{ - TargetPort: intstr.FromString("https"), - }, - TLS: &v1.TLSConfig{ - Termination: v1.TLSTerminationPassthrough, - InsecureEdgeTerminationPolicy: v1.InsecureEdgeTerminationPolicyRedirect, + TargetPort: targetPort, }, + TLS: tlsConfig, WildcardPolicy: v1.WildcardPolicyNone, }, Status: v1.RouteStatus{