Skip to content

Commit

Permalink
Added fix for istio gateway and vs heterogenous deployment (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahtr authored Aug 3, 2023
1 parent ceba31b commit fc05690
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions charts/external-dns/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ spec:
{{- if .Values.triggerLoopOnEvent }}
- --events
{{- end }}
{{- if .Values.awsPreferCname }}
- --aws-prefer-cname
{{- end }}
{{- if .Values.watchNamespaces }}
- --namespace={{ .Values.watchNamespaces | join "," }}
{{- end }}
Expand Down
9 changes: 5 additions & 4 deletions source/istio_virtualservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (sc *virtualServiceSource) targetsFromVirtualService(ctx context.Context, v
if !virtualServiceBindsToGateway(virtualService, gateway, vsHost) {
continue
}
tgs, err := sc.targetsFromGateway(gateway)
tgs, err := sc.targetsFromGateway(ctx, gateway)
if err != nil {
return targets, err
}
Expand Down Expand Up @@ -431,19 +431,20 @@ func parseGateway(gateway string) (namespace, name string, err error) {
return
}

func (sc *virtualServiceSource) targetsFromGateway(gateway *networkingv1alpha3.Gateway) (targets endpoint.Targets, err error) {
func (sc *virtualServiceSource) targetsFromGateway(ctx context.Context, gateway *networkingv1alpha3.Gateway) (targets endpoint.Targets, err error) {
targets = getTargetsFromTargetAnnotation(gateway.Annotations)
if len(targets) > 0 {
return
}

services, err := sc.serviceInformer.Lister().Services(sc.namespace).List(labels.Everything())
// Use kubeclient instead of informers to fetch services from gateway namespace
services, err := sc.kubeClient.CoreV1().Services(gateway.Namespace).List(ctx, metav1.ListOptions{})
if err != nil {
log.Error(err)
return
}

for _, service := range services {
for _, service := range services.Items {
if !gatewaySelectorMatchesServiceSelector(gateway.Spec.Selector, service.Spec.Selector) {
continue
}
Expand Down

0 comments on commit fc05690

Please sign in to comment.