-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix port merge of kubernetes services in sidecar #50840
Conversation
Signed-off-by: Rama Chavali <[email protected]>
Signed-off-by: Rama Chavali <[email protected]>
Signed-off-by: Rama Chavali <[email protected]>
@@ -2060,56 +2076,6 @@ func TestCreateSidecarScope(t *testing.T) { | |||
}, | |||
}, | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test not relevant. Kubernetes service in the same namespace should be merged. The existing changed test verifies this behaviour
@@ -2201,7 +2167,7 @@ func TestCreateSidecarScope(t *testing.T) { | |||
expectedServices: []*Service{ | |||
{ | |||
Hostname: "proxy", | |||
Ports: port7443, | |||
Ports: port744x, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again here, k8s service ports should be merged while taking precedence
This broke our existing deployments after upgrade. |
can you describe how you merge svces in the egress listeners. As we can see in xds generator, sometimes we use services in egress listenrs, some times we use services in sidecarScope |
See this example
It generates two listeners but only one cluster with outbound|7443||foo.svc.cluster.local. It does not generate cluster for 7442. This is broken in current release |
if existing.Attributes.ServiceRegistry == provider.Kubernetes { | ||
log.Debugf("Service %s/%s from registry %s ignored by %s/%s/%s", s.Attributes.Namespace, s.Hostname, s.Attributes.ServiceRegistry, | ||
// We do not merge k8s service with any other services from other registries | ||
if existing.Attributes.ServiceRegistry == provider.Kubernetes && s.Attributes.ServiceRegistry != provider.Kubernetes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how could this occur two services in k8s have same fqdn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
istio/pilot/pkg/model/sidecar.go
Line 426 in 044be69
sc.appendSidecarServices(servicesAdded, s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try with this sidecar #50840 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see how this occur, it is the egress listener with generate intermeditae svc with only one port from the original k8s svc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes and we need to merge at that end
log.Debugf("Service %s/%s from registry %s ignored by %s/%s/%s", existing.Attributes.Namespace, existing.Hostname, existing.Attributes.ServiceRegistry, | ||
// newly created Services cannot take ownership unexpectedly. However, the Service is from Kubernetes it should | ||
// take precedence over ones not. This prevents someone from "domain squatting" on the hostname before a Kubernetes Service is created. | ||
if existing.Attributes.ServiceRegistry != provider.Kubernetes && s.Attributes.ServiceRegistry == provider.Kubernetes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above comment apply here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add multiple sidecar egress listeners svc match test
if existing.Attributes.ServiceRegistry == provider.Kubernetes { | ||
log.Debugf("Service %s/%s from registry %s ignored by %s/%s/%s", s.Attributes.Namespace, s.Hostname, s.Attributes.ServiceRegistry, | ||
// We do not merge k8s service with any other services from other registries | ||
if existing.Attributes.ServiceRegistry == provider.Kubernetes && s.Attributes.ServiceRegistry != provider.Kubernetes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see how this occur, it is the egress listener with generate intermeditae svc with only one port from the original k8s svc.
We already have that test istio/pilot/pkg/model/sidecar_test.go Line 2214 in 044be69
|
@ramaraochavali The test has service resides in different namespaces |
Signed-off-by: Rama Chavali <[email protected]>
I do not think that really matters much because first service has all the ports and is in ns1 namespace- even that failed without this. Any way, I have added additional test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG now
In response to a cherrypick label: new pull request created: #50887 |
* upstream/master: fix release-notes kind (istio#50906) discovery fake: allow kube-client override (istio#50896) change #none to none for use-waypoint (istio#50842) Update iptables image SHA (istio#50898) Update BASE_VERSION to master-2024-05-07T22-48-43 (istio#50897) Add some more useful logging around iptables selection in ambient CNI (istio#50891) Automator: update ztunnel@master in istio/istio@master (istio#50890) stop default for istio.io/waypoint-for in istioctl (istio#50889) Update integration README by adding a missing command-line flag and fixing typos (istio#50866) Automator: update proxy@master in istio/istio@master (istio#50888) fix port merge of kubernetes services in sidecar (istio#50840) bump proxy and ambient test (istio#50882)
K8s servie merge in sidecar is broken since #48896. When a sidecar is defined with two egress listeners pointing to two ports, the port merge does not happen
With the above sidecar, the merged service will only have one port and hence only cluster is created.