From 98dc0610001f8ec88e0a44370b139d469fc48d86 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Wed, 1 Aug 2018 14:35:23 -0400 Subject: [PATCH 1/3] Update VirtualSerivce to pass Istio validation The Istio validator was rejecting VirtualServices created for Channels. Adding the PortSelector made the validator happy again. Fixes #302 --- pkg/controller/channel/controller.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pkg/controller/channel/controller.go b/pkg/controller/channel/controller.go index 24c23bbefd1..eaea29bdc2c 100644 --- a/pkg/controller/channel/controller.go +++ b/pkg/controller/channel/controller.go @@ -39,11 +39,11 @@ import ( "k8s.io/client-go/tools/record" "k8s.io/client-go/util/workqueue" - "github.com/knative/eventing/pkg/system" clientset "github.com/knative/eventing/pkg/client/clientset/versioned" channelscheme "github.com/knative/eventing/pkg/client/clientset/versioned/scheme" informers "github.com/knative/eventing/pkg/client/informers/externalversions" listers "github.com/knative/eventing/pkg/client/listers/channels/v1alpha1" + "github.com/knative/eventing/pkg/system" servingclientset "github.com/knative/serving/pkg/client/clientset/versioned" servinginformers "github.com/knative/serving/pkg/client/informers/externalversions" @@ -539,19 +539,18 @@ func newVirtualService(channel *channelsv1alpha1.Channel) *istiov1alpha3.Virtual controller.ServiceHostName(controller.ChannelServiceName(channel.Name), channel.Namespace), controller.ChannelHostName(channel.Name, channel.Namespace), }, - Http: []istiov1alpha3.HTTPRoute{ - { - Rewrite: &istiov1alpha3.HTTPRewrite{ - Authority: controller.ChannelHostName(channel.Name, channel.Namespace), - }, - Route: []istiov1alpha3.DestinationWeight{ - { - Destination: istiov1alpha3.Destination{ - Host: destinationHost, - }, - }, - }, + Http: []istiov1alpha3.HTTPRoute{{ + Rewrite: &istiov1alpha3.HTTPRewrite{ + Authority: controller.ChannelHostName(channel.Name, channel.Namespace), }, + Route: []istiov1alpha3.DestinationWeight{{ + Destination: istiov1alpha3.Destination{ + Host: destinationHost, + Port: istiov1alpha3.PortSelector{ + Number: 80, + }, + }}, + }}, }, }, } From 4db88765667bc1c3759acac5ad64bf59f3ee3b1a Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Wed, 1 Aug 2018 15:43:24 -0400 Subject: [PATCH 2/3] Use common PortName and PortNumber vars --- pkg/controller/channel/controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/controller/channel/controller.go b/pkg/controller/channel/controller.go index eaea29bdc2c..7874e2021a6 100644 --- a/pkg/controller/channel/controller.go +++ b/pkg/controller/channel/controller.go @@ -547,7 +547,8 @@ func newVirtualService(channel *channelsv1alpha1.Channel) *istiov1alpha3.Virtual Destination: istiov1alpha3.Destination{ Host: destinationHost, Port: istiov1alpha3.PortSelector{ - Number: 80, + Name: PortName, + Number: PortNumber, }, }}, }}, From cbb15d5260b128cc9d9923699d1ce4fe78a82853 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Wed, 1 Aug 2018 20:51:29 -0400 Subject: [PATCH 3/3] Remove PortSelector Name ...it causes 503s --- pkg/controller/channel/controller.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/controller/channel/controller.go b/pkg/controller/channel/controller.go index 7874e2021a6..04103d7d06a 100644 --- a/pkg/controller/channel/controller.go +++ b/pkg/controller/channel/controller.go @@ -547,7 +547,6 @@ func newVirtualService(channel *channelsv1alpha1.Channel) *istiov1alpha3.Virtual Destination: istiov1alpha3.Destination{ Host: destinationHost, Port: istiov1alpha3.PortSelector{ - Name: PortName, Number: PortNumber, }, }},