Skip to content

Commit

Permalink
Fix ingress configuration for path based routing and update go mod (k…
Browse files Browse the repository at this point in the history
…serve#3944)

Fix broken ingress test and update go mod

Signed-off-by: Sivanantham Chinnaiyan <sivanantham.chinnaiyan@ideas2it.com>
  • Loading branch information
sivanantha321 authored Sep 19, 2024
1 parent 536fc9b commit d97baa6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 32 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ require (
k8s.io/code-generator v0.30.4
k8s.io/klog v1.0.0
k8s.io/kube-openapi v0.0.0-20240827152857-f7e401e7b4c2
k8s.io/utils v0.0.0-20240821151609-f90d01438635
knative.dev/networking v0.0.0-20240815142417-37fdbdd0854b
knative.dev/pkg v0.0.0-20240815051656-89743d9bbf7c
knative.dev/serving v0.42.2
Expand Down Expand Up @@ -129,7 +130,6 @@ require (
k8s.io/apiextensions-apiserver v0.30.4 // indirect
k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20240821151609-f90d01438635 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
2 changes: 2 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ const (
NetworkVisibility = "networking.kserve.io/visibility"
ClusterLocalVisibility = "cluster-local"
ClusterLocalDomain = "svc.cluster.local"
IsvcNameHeader = "KServe-Isvc-Name"
IsvcNamespaceHeader = "KServe-Isvc-Namespace"
)

// StorageSpec Constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,9 @@ func createIngress(isvc *v1beta1.InferenceService, useDefault bool, config *v1be
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{
Set: map[string]string{
"Host": network.GetServiceHostname(expBackend, isvc.Namespace),
"KServe-Isvc-Name": isvc.Name,
"KServe-Isvc-Namespace": isvc.Namespace,
"Host": network.GetServiceHostname(expBackend, isvc.Namespace),
constants.IsvcNameHeader: isvc.Name,
constants.IsvcNamespaceHeader: isvc.Namespace,
},
},
},
Expand All @@ -459,9 +459,9 @@ func createIngress(isvc *v1beta1.InferenceService, useDefault bool, config *v1be
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{
Set: map[string]string{
"Host": network.GetServiceHostname(backend, isvc.Namespace),
"KServe-Isvc-Name": isvc.Name,
"KServe-Isvc-Namespace": isvc.Namespace,
"Host": network.GetServiceHostname(backend, isvc.Namespace),
constants.IsvcNameHeader: isvc.Name,
constants.IsvcNamespaceHeader: isvc.Namespace,
},
},
},
Expand Down Expand Up @@ -510,12 +510,14 @@ func createIngress(isvc *v1beta1.InferenceService, useDefault bool, config *v1be
},
},
Route: []*istiov1beta1.HTTPRouteDestination{
createHTTPRouteDestination(config.LocalGatewayServiceName),
createHTTPRouteDestination(config.KnativeLocalGatewayService),
},
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{
Set: map[string]string{
"Host": network.GetServiceHostname(expBackend, isvc.Namespace),
"Host": network.GetServiceHostname(expBackend, isvc.Namespace),
constants.IsvcNameHeader: isvc.Name,
constants.IsvcNamespaceHeader: isvc.Namespace,
},
},
},
Expand Down Expand Up @@ -559,9 +561,9 @@ func createIngress(isvc *v1beta1.InferenceService, useDefault bool, config *v1be
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{
Set: map[string]string{
"Host": network.GetServiceHostname(backend, isvc.Namespace),
"KServe-Isvc-Name": isvc.Name,
"KServe-Isvc-Namespace": isvc.Namespace,
"Host": network.GetServiceHostname(backend, isvc.Namespace),
constants.IsvcNameHeader: isvc.Name,
constants.IsvcNamespaceHeader: isvc.Namespace,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,14 +952,14 @@ func TestCreateVirtualService(t *testing.T) {
}, {
name: "found predictor and explainer status with path template",
ingressConfig: &v1beta1.IngressConfig{
IngressGateway: constants.KnativeIngressGateway,
IngressServiceName: "someIngressServiceName",
LocalGateway: constants.KnativeLocalGateway,
LocalGatewayServiceName: "knative-local-gateway.istio-system.svc.cluster.local",
UrlScheme: "http",
IngressDomain: "my-domain.com",
PathTemplate: "/serving/{{ .Namespace }}/{{ .Name }}",
DisableIstioVirtualHost: false,
IngressGateway: constants.KnativeIngressGateway,
KnativeLocalGatewayService: knativeLocalGatewayService,
LocalGateway: constants.KnativeLocalGateway,
LocalGatewayServiceName: knativeLocalGatewayService,
UrlScheme: "http",
IngressDomain: "my-domain.com",
PathTemplate: "/serving/{{ .Namespace }}/{{ .Name }}",
DisableIstioVirtualHost: false,
},
useDefault: false,
componentStatus: &v1beta1.InferenceServiceStatus{
Expand Down Expand Up @@ -1038,14 +1038,16 @@ func TestCreateVirtualService(t *testing.T) {
},
},
Route: []*istiov1beta1.HTTPRouteDestination{
{
Destination: &istiov1beta1.Destination{Host: constants.LocalGatewayHost, Port: &istiov1beta1.PortSelector{Number: constants.CommonDefaultHttpPort}},
Weight: 100,
{Destination: &istiov1beta1.Destination{Host: knativeLocalGatewayService, Port: &istiov1beta1.PortSelector{Number: constants.CommonDefaultHttpPort}},
Weight: 100,
},
},
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{Set: map[string]string{
"Host": network.GetServiceHostname(constants.ExplainerServiceName(serviceName), namespace)},
"Host": network.GetServiceHostname(constants.ExplainerServiceName(serviceName), namespace),
constants.IsvcNameHeader: serviceName,
constants.IsvcNamespaceHeader: namespace,
},
},
},
},
Expand All @@ -1069,14 +1071,15 @@ func TestCreateVirtualService(t *testing.T) {
},
},
Route: []*istiov1beta1.HTTPRouteDestination{
{
Destination: &istiov1beta1.Destination{Host: constants.LocalGatewayHost, Port: &istiov1beta1.PortSelector{Number: constants.CommonDefaultHttpPort}},
Weight: 100,
{Destination: &istiov1beta1.Destination{Host: knativeLocalGatewayService, Port: &istiov1beta1.PortSelector{Number: constants.CommonDefaultHttpPort}},
Weight: 100,
},
},
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{Set: map[string]string{
"Host": network.GetServiceHostname(constants.PredictorServiceName(serviceName), namespace)}},
"Host": network.GetServiceHostname(constants.PredictorServiceName(serviceName), namespace),
constants.IsvcNameHeader: serviceName,
constants.IsvcNamespaceHeader: namespace}},
},
},
{
Expand All @@ -1102,12 +1105,14 @@ func TestCreateVirtualService(t *testing.T) {
},
},
Route: []*istiov1beta1.HTTPRouteDestination{
createHTTPRouteDestination("knative-local-gateway.istio-system.svc.cluster.local"),
createHTTPRouteDestination(knativeLocalGatewayService),
},
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{
Set: map[string]string{
"Host": network.GetServiceHostname(constants.ExplainerServiceName(serviceName), namespace),
"Host": network.GetServiceHostname(constants.ExplainerServiceName(serviceName), namespace),
constants.IsvcNameHeader: serviceName,
constants.IsvcNamespaceHeader: namespace,
},
},
},
Expand Down Expand Up @@ -1145,12 +1150,14 @@ func TestCreateVirtualService(t *testing.T) {
Uri: "/",
},
Route: []*istiov1beta1.HTTPRouteDestination{
createHTTPRouteDestination("knative-local-gateway.istio-system.svc.cluster.local"),
createHTTPRouteDestination(knativeLocalGatewayService),
},
Headers: &istiov1beta1.Headers{
Request: &istiov1beta1.Headers_HeaderOperations{
Set: map[string]string{
"Host": network.GetServiceHostname(constants.PredictorServiceName(serviceName), namespace),
"Host": network.GetServiceHostname(constants.PredictorServiceName(serviceName), namespace),
constants.IsvcNameHeader: serviceName,
constants.IsvcNamespaceHeader: namespace,
},
},
},
Expand Down

0 comments on commit d97baa6

Please sign in to comment.