From 3d48d66c91f6b78e1326c937985f86054774cb1a Mon Sep 17 00:00:00 2001 From: megum1n Date: Wed, 15 Mar 2023 02:33:00 +0100 Subject: [PATCH 1/8] Add support for multiple gloo namespaces in one External DNS instance --- docs/tutorials/gloo-proxy.md | 4 +-- main.go | 2 +- pkg/apis/externaldns/types.go | 6 ++-- pkg/apis/externaldns/types_test.go | 8 ++--- source/gloo_proxy.go | 58 ++++++++++++++++-------------- source/store.go | 4 +-- 6 files changed, 43 insertions(+), 39 deletions(-) diff --git a/docs/tutorials/gloo-proxy.md b/docs/tutorials/gloo-proxy.md index 0ec63da803..b1fb8d162e 100644 --- a/docs/tutorials/gloo-proxy.md +++ b/docs/tutorials/gloo-proxy.md @@ -25,7 +25,7 @@ spec: image: registry.k8s.io/external-dns/external-dns:v0.13.2 args: - --source=gloo-proxy - - --gloo-namespace=custom-gloo-system # gloo system namespace. Omit to use the default (gloo-system) + - --gloo-namespaces=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) - --provider=aws - --registry=txt - --txt-owner-id=my-identifier @@ -93,7 +93,7 @@ spec: image: registry.k8s.io/external-dns/external-dns:v0.13.2 args: - --source=gloo-proxy - - --gloo-namespace=custom-gloo-system # gloo system namespace. Omit to use the default (gloo-system) + - --gloo-namespaces=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) - --provider=aws - --registry=txt - --txt-owner-id=my-identifier diff --git a/main.go b/main.go index ece1b02909..21e1964644 100644 --- a/main.go +++ b/main.go @@ -134,7 +134,7 @@ func main() { CFUsername: cfg.CFUsername, CFPassword: cfg.CFPassword, ContourLoadBalancerService: cfg.ContourLoadBalancerService, - GlooNamespace: cfg.GlooNamespace, + GlooNamespaces: cfg.GlooNamespaces, SkipperRouteGroupVersion: cfg.SkipperRouteGroupVersion, RequestTimeout: cfg.RequestTimeout, DefaultTargets: cfg.DefaultTargets, diff --git a/pkg/apis/externaldns/types.go b/pkg/apis/externaldns/types.go index 230610e7fa..85b75c651d 100644 --- a/pkg/apis/externaldns/types.go +++ b/pkg/apis/externaldns/types.go @@ -48,7 +48,7 @@ type Config struct { RequestTimeout time.Duration DefaultTargets []string ContourLoadBalancerService string - GlooNamespace string + GlooNamespaces string SkipperRouteGroupVersion string Sources []string Namespace string @@ -207,7 +207,7 @@ var defaultConfig = &Config{ RequestTimeout: time.Second * 30, DefaultTargets: []string{}, ContourLoadBalancerService: "heptio-contour/contour", - GlooNamespace: "gloo-system", + GlooNamespaces: "gloo-system", SkipperRouteGroupVersion: "zalando.org/v1", Sources: nil, Namespace: "", @@ -398,7 +398,7 @@ func (cfg *Config) ParseFlags(args []string) error { app.Flag("contour-load-balancer", "The fully-qualified name of the Contour load balancer service. (default: heptio-contour/contour)").Default("heptio-contour/contour").StringVar(&cfg.ContourLoadBalancerService) // Flags related to Gloo - app.Flag("gloo-namespace", "Gloo namespace. (default: gloo-system)").Default("gloo-system").StringVar(&cfg.GlooNamespace) + app.Flag("gloo-namespaces", "Coma separated list of gloo namespaces. (default: gloo-system)").Default("gloo-system").StringVar(&cfg.GlooNamespaces) // Flags related to Skipper RouteGroup app.Flag("skipper-routegroup-groupversion", "The resource version for skipper routegroup").Default(source.DefaultRoutegroupVersion).StringVar(&cfg.SkipperRouteGroupVersion) diff --git a/pkg/apis/externaldns/types_test.go b/pkg/apis/externaldns/types_test.go index 87647ee218..fb262b0f92 100644 --- a/pkg/apis/externaldns/types_test.go +++ b/pkg/apis/externaldns/types_test.go @@ -36,7 +36,7 @@ var ( KubeConfig: "", RequestTimeout: time.Second * 30, ContourLoadBalancerService: "heptio-contour/contour", - GlooNamespace: "gloo-system", + GlooNamespaces: "gloo-system", SkipperRouteGroupVersion: "zalando.org/v1", Sources: []string{"service"}, Namespace: "", @@ -136,7 +136,7 @@ var ( KubeConfig: "/some/path", RequestTimeout: time.Second * 77, ContourLoadBalancerService: "heptio-contour-other/contour-other", - GlooNamespace: "gloo-not-system", + GlooNamespaces: "gloo-not-system,gloo-second-system", SkipperRouteGroupVersion: "zalando.org/v2", Sources: []string{"service", "ingress", "connector"}, Namespace: "namespace", @@ -266,7 +266,7 @@ func TestParseFlags(t *testing.T) { "--kubeconfig=/some/path", "--request-timeout=77s", "--contour-load-balancer=heptio-contour-other/contour-other", - "--gloo-namespace=gloo-not-system", + "--gloo-namespaces=gloo-not-system,gloo-second-system", "--skipper-routegroup-groupversion=zalando.org/v2", "--source=service", "--source=ingress", @@ -391,7 +391,7 @@ func TestParseFlags(t *testing.T) { "EXTERNAL_DNS_KUBECONFIG": "/some/path", "EXTERNAL_DNS_REQUEST_TIMEOUT": "77s", "EXTERNAL_DNS_CONTOUR_LOAD_BALANCER": "heptio-contour-other/contour-other", - "EXTERNAL_DNS_GLOO_NAMESPACE": "gloo-not-system", + "EXTERNAL_DNS_GLOO_NAMESPACES": "gloo-not-system,gloo-second-system", "EXTERNAL_DNS_SKIPPER_ROUTEGROUP_GROUPVERSION": "zalando.org/v2", "EXTERNAL_DNS_SOURCE": "service\ningress\nconnector", "EXTERNAL_DNS_NAMESPACE": "namespace", diff --git a/source/gloo_proxy.go b/source/gloo_proxy.go index 845ccdee05..49f8000834 100644 --- a/source/gloo_proxy.go +++ b/source/gloo_proxy.go @@ -81,15 +81,16 @@ type proxyVirtualHostMetadataSource struct { type glooSource struct { dynamicKubeClient dynamic.Interface kubeClient kubernetes.Interface - glooNamespace string + glooNamespaces []string } // NewGlooSource creates a new glooSource with the given config -func NewGlooSource(dynamicKubeClient dynamic.Interface, kubeClient kubernetes.Interface, glooNamespace string) (Source, error) { +func NewGlooSource(dynamicKubeClient dynamic.Interface, kubeClient kubernetes.Interface, glooNamespaces string) (Source, error) { + return &glooSource{ dynamicKubeClient, kubeClient, - glooNamespace, + strings.Split(glooNamespaces, ","), }, nil } @@ -100,33 +101,36 @@ func (gs *glooSource) AddEventHandler(ctx context.Context, handler func()) { func (gs *glooSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, error) { endpoints := []*endpoint.Endpoint{} - proxies, err := gs.dynamicKubeClient.Resource(proxyGVR).Namespace(gs.glooNamespace).List(ctx, metav1.ListOptions{}) - if err != nil { - return nil, err - } - for _, obj := range proxies.Items { - proxy := proxy{} - jsonString, err := obj.MarshalJSON() - if err != nil { - return nil, err - } - err = json.Unmarshal(jsonString, &proxy) + for _, ns := range gs.glooNamespaces { + proxies, err := gs.dynamicKubeClient.Resource(proxyGVR).Namespace(ns).List(ctx, metav1.ListOptions{}) if err != nil { return nil, err } - log.Debugf("Gloo: Find %s proxy", proxy.Metadata.Name) - proxyTargets, err := gs.proxyTargets(ctx, proxy.Metadata.Name) - if err != nil { - return nil, err - } - log.Debugf("Gloo[%s]: Find %d target(s) (%+v)", proxy.Metadata.Name, len(proxyTargets), proxyTargets) - proxyEndpoints, err := gs.generateEndpointsFromProxy(ctx, &proxy, proxyTargets) - if err != nil { - return nil, err + for _, obj := range proxies.Items { + proxy := proxy{} + jsonString, err := obj.MarshalJSON() + if err != nil { + return nil, err + } + err = json.Unmarshal(jsonString, &proxy) + if err != nil { + return nil, err + } + log.Debugf("Gloo: Find %s proxy", proxy.Metadata.Name) + proxyTargets, err := gs.proxyTargets(ctx, proxy.Metadata.Name, ns) + if err != nil { + return nil, err + } + log.Debugf("Gloo[%s]: Find %d target(s) (%+v)", proxy.Metadata.Name, len(proxyTargets), proxyTargets) + proxyEndpoints, err := gs.generateEndpointsFromProxy(ctx, &proxy, proxyTargets) + if err != nil { + return nil, err + } + log.Debugf("Gloo[%s]: Generate %d endpoint(s)", proxy.Metadata.Name, len(proxyEndpoints)) + endpoints = append(endpoints, proxyEndpoints...) } - log.Debugf("Gloo[%s]: Generate %d endpoint(s)", proxy.Metadata.Name, len(proxyEndpoints)) - endpoints = append(endpoints, proxyEndpoints...) } + return endpoints, nil } @@ -168,8 +172,8 @@ func (gs *glooSource) annotationsFromProxySource(ctx context.Context, virtualHos return annotations, nil } -func (gs *glooSource) proxyTargets(ctx context.Context, name string) (endpoint.Targets, error) { - svc, err := gs.kubeClient.CoreV1().Services(gs.glooNamespace).Get(ctx, name, metav1.GetOptions{}) +func (gs *glooSource) proxyTargets(ctx context.Context, name string, namespace string) (endpoint.Targets, error) { + svc, err := gs.kubeClient.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { return nil, err } diff --git a/source/store.go b/source/store.go index 87ba403a2d..f37fb9462e 100644 --- a/source/store.go +++ b/source/store.go @@ -67,7 +67,7 @@ type Config struct { CFUsername string CFPassword string ContourLoadBalancerService string - GlooNamespace string + GlooNamespaces string SkipperRouteGroupVersion string RequestTimeout time.Duration DefaultTargets []string @@ -288,7 +288,7 @@ func BuildWithConfig(ctx context.Context, source string, p ClientGenerator, cfg if err != nil { return nil, err } - return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespace) + return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespaces) case "openshift-route": ocpClient, err := p.OpenShiftClient() if err != nil { From ac605fa4cea2421b74bc93db5fded24a83545796 Mon Sep 17 00:00:00 2001 From: megum1n Date: Thu, 13 Apr 2023 23:00:26 +0200 Subject: [PATCH 2/8] Rename gloo-namespace flag back to singular word --- docs/tutorials/gloo-proxy.md | 4 ++-- main.go | 2 +- pkg/apis/externaldns/types.go | 6 +++--- pkg/apis/externaldns/types_test.go | 8 ++++---- source/store.go | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/tutorials/gloo-proxy.md b/docs/tutorials/gloo-proxy.md index b1fb8d162e..a42fdae83a 100644 --- a/docs/tutorials/gloo-proxy.md +++ b/docs/tutorials/gloo-proxy.md @@ -25,7 +25,7 @@ spec: image: registry.k8s.io/external-dns/external-dns:v0.13.2 args: - --source=gloo-proxy - - --gloo-namespaces=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) + - --gloo-namespace=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) - --provider=aws - --registry=txt - --txt-owner-id=my-identifier @@ -93,7 +93,7 @@ spec: image: registry.k8s.io/external-dns/external-dns:v0.13.2 args: - --source=gloo-proxy - - --gloo-namespaces=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) + - --gloo-namespace=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) - --provider=aws - --registry=txt - --txt-owner-id=my-identifier diff --git a/main.go b/main.go index 21e1964644..ece1b02909 100644 --- a/main.go +++ b/main.go @@ -134,7 +134,7 @@ func main() { CFUsername: cfg.CFUsername, CFPassword: cfg.CFPassword, ContourLoadBalancerService: cfg.ContourLoadBalancerService, - GlooNamespaces: cfg.GlooNamespaces, + GlooNamespace: cfg.GlooNamespace, SkipperRouteGroupVersion: cfg.SkipperRouteGroupVersion, RequestTimeout: cfg.RequestTimeout, DefaultTargets: cfg.DefaultTargets, diff --git a/pkg/apis/externaldns/types.go b/pkg/apis/externaldns/types.go index 85b75c651d..9e58b94106 100644 --- a/pkg/apis/externaldns/types.go +++ b/pkg/apis/externaldns/types.go @@ -48,7 +48,7 @@ type Config struct { RequestTimeout time.Duration DefaultTargets []string ContourLoadBalancerService string - GlooNamespaces string + GlooNamespace string SkipperRouteGroupVersion string Sources []string Namespace string @@ -207,7 +207,7 @@ var defaultConfig = &Config{ RequestTimeout: time.Second * 30, DefaultTargets: []string{}, ContourLoadBalancerService: "heptio-contour/contour", - GlooNamespaces: "gloo-system", + GlooNamespace: "gloo-system", SkipperRouteGroupVersion: "zalando.org/v1", Sources: nil, Namespace: "", @@ -398,7 +398,7 @@ func (cfg *Config) ParseFlags(args []string) error { app.Flag("contour-load-balancer", "The fully-qualified name of the Contour load balancer service. (default: heptio-contour/contour)").Default("heptio-contour/contour").StringVar(&cfg.ContourLoadBalancerService) // Flags related to Gloo - app.Flag("gloo-namespaces", "Coma separated list of gloo namespaces. (default: gloo-system)").Default("gloo-system").StringVar(&cfg.GlooNamespaces) + app.Flag("gloo-namespace", "Coma separated list of gloo namespaces. (default: gloo-system)").Default("gloo-system").StringVar(&cfg.GlooNamespace) // Flags related to Skipper RouteGroup app.Flag("skipper-routegroup-groupversion", "The resource version for skipper routegroup").Default(source.DefaultRoutegroupVersion).StringVar(&cfg.SkipperRouteGroupVersion) diff --git a/pkg/apis/externaldns/types_test.go b/pkg/apis/externaldns/types_test.go index fb262b0f92..efa2df6eae 100644 --- a/pkg/apis/externaldns/types_test.go +++ b/pkg/apis/externaldns/types_test.go @@ -36,7 +36,7 @@ var ( KubeConfig: "", RequestTimeout: time.Second * 30, ContourLoadBalancerService: "heptio-contour/contour", - GlooNamespaces: "gloo-system", + GlooNamespace: "gloo-system", SkipperRouteGroupVersion: "zalando.org/v1", Sources: []string{"service"}, Namespace: "", @@ -136,7 +136,7 @@ var ( KubeConfig: "/some/path", RequestTimeout: time.Second * 77, ContourLoadBalancerService: "heptio-contour-other/contour-other", - GlooNamespaces: "gloo-not-system,gloo-second-system", + GlooNamespace: "gloo-not-system,gloo-second-system", SkipperRouteGroupVersion: "zalando.org/v2", Sources: []string{"service", "ingress", "connector"}, Namespace: "namespace", @@ -266,7 +266,7 @@ func TestParseFlags(t *testing.T) { "--kubeconfig=/some/path", "--request-timeout=77s", "--contour-load-balancer=heptio-contour-other/contour-other", - "--gloo-namespaces=gloo-not-system,gloo-second-system", + "--gloo-namespace=gloo-not-system,gloo-second-system", "--skipper-routegroup-groupversion=zalando.org/v2", "--source=service", "--source=ingress", @@ -391,7 +391,7 @@ func TestParseFlags(t *testing.T) { "EXTERNAL_DNS_KUBECONFIG": "/some/path", "EXTERNAL_DNS_REQUEST_TIMEOUT": "77s", "EXTERNAL_DNS_CONTOUR_LOAD_BALANCER": "heptio-contour-other/contour-other", - "EXTERNAL_DNS_GLOO_NAMESPACES": "gloo-not-system,gloo-second-system", + "EXTERNAL_DNS_GLOO_NAMESPACE": "gloo-not-system,gloo-second-system", "EXTERNAL_DNS_SKIPPER_ROUTEGROUP_GROUPVERSION": "zalando.org/v2", "EXTERNAL_DNS_SOURCE": "service\ningress\nconnector", "EXTERNAL_DNS_NAMESPACE": "namespace", diff --git a/source/store.go b/source/store.go index f37fb9462e..87ba403a2d 100644 --- a/source/store.go +++ b/source/store.go @@ -67,7 +67,7 @@ type Config struct { CFUsername string CFPassword string ContourLoadBalancerService string - GlooNamespaces string + GlooNamespace string SkipperRouteGroupVersion string RequestTimeout time.Duration DefaultTargets []string @@ -288,7 +288,7 @@ func BuildWithConfig(ctx context.Context, source string, p ClientGenerator, cfg if err != nil { return nil, err } - return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespaces) + return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespace) case "openshift-route": ocpClient, err := p.OpenShiftClient() if err != nil { From 63c826f62bbf20e28786c7a36f8111a67ca07045 Mon Sep 17 00:00:00 2001 From: megum1n Date: Thu, 20 Apr 2023 15:50:58 +0200 Subject: [PATCH 3/8] Remove whitespaces --- source/gloo_proxy.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/gloo_proxy.go b/source/gloo_proxy.go index 49f8000834..37d9401257 100644 --- a/source/gloo_proxy.go +++ b/source/gloo_proxy.go @@ -86,7 +86,6 @@ type glooSource struct { // NewGlooSource creates a new glooSource with the given config func NewGlooSource(dynamicKubeClient dynamic.Interface, kubeClient kubernetes.Interface, glooNamespaces string) (Source, error) { - return &glooSource{ dynamicKubeClient, kubeClient, @@ -130,7 +129,6 @@ func (gs *glooSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, erro endpoints = append(endpoints, proxyEndpoints...) } } - return endpoints, nil } From 028656d649a60935a3f7eb2de80dcd561abf842e Mon Sep 17 00:00:00 2001 From: Megum1n Date: Mon, 8 May 2023 12:08:00 +0200 Subject: [PATCH 4/8] Change variable type and description --- main.go | 2 +- pkg/apis/externaldns/types.go | 6 +++--- pkg/apis/externaldns/types_test.go | 9 +++++---- source/gloo_proxy.go | 5 +++-- source/gloo_proxy_test.go | 2 +- source/store.go | 4 ++-- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index ece1b02909..21e1964644 100644 --- a/main.go +++ b/main.go @@ -134,7 +134,7 @@ func main() { CFUsername: cfg.CFUsername, CFPassword: cfg.CFPassword, ContourLoadBalancerService: cfg.ContourLoadBalancerService, - GlooNamespace: cfg.GlooNamespace, + GlooNamespaces: cfg.GlooNamespaces, SkipperRouteGroupVersion: cfg.SkipperRouteGroupVersion, RequestTimeout: cfg.RequestTimeout, DefaultTargets: cfg.DefaultTargets, diff --git a/pkg/apis/externaldns/types.go b/pkg/apis/externaldns/types.go index 9e58b94106..4ebaf3e508 100644 --- a/pkg/apis/externaldns/types.go +++ b/pkg/apis/externaldns/types.go @@ -48,7 +48,7 @@ type Config struct { RequestTimeout time.Duration DefaultTargets []string ContourLoadBalancerService string - GlooNamespace string + GlooNamespaces []string SkipperRouteGroupVersion string Sources []string Namespace string @@ -207,7 +207,7 @@ var defaultConfig = &Config{ RequestTimeout: time.Second * 30, DefaultTargets: []string{}, ContourLoadBalancerService: "heptio-contour/contour", - GlooNamespace: "gloo-system", + GlooNamespaces: []string{"gloo-system"}, SkipperRouteGroupVersion: "zalando.org/v1", Sources: nil, Namespace: "", @@ -398,7 +398,7 @@ func (cfg *Config) ParseFlags(args []string) error { app.Flag("contour-load-balancer", "The fully-qualified name of the Contour load balancer service. (default: heptio-contour/contour)").Default("heptio-contour/contour").StringVar(&cfg.ContourLoadBalancerService) // Flags related to Gloo - app.Flag("gloo-namespace", "Coma separated list of gloo namespaces. (default: gloo-system)").Default("gloo-system").StringVar(&cfg.GlooNamespace) + app.Flag("gloo-namespace", "Set Gloo Proxy namespace; specify multiple times for multiple namespaces. (default: gloo-system)").Default("gloo-system").StringsVar(&cfg.GlooNamespaces) // Flags related to Skipper RouteGroup app.Flag("skipper-routegroup-groupversion", "The resource version for skipper routegroup").Default(source.DefaultRoutegroupVersion).StringVar(&cfg.SkipperRouteGroupVersion) diff --git a/pkg/apis/externaldns/types_test.go b/pkg/apis/externaldns/types_test.go index efa2df6eae..fa7567bdfc 100644 --- a/pkg/apis/externaldns/types_test.go +++ b/pkg/apis/externaldns/types_test.go @@ -36,7 +36,7 @@ var ( KubeConfig: "", RequestTimeout: time.Second * 30, ContourLoadBalancerService: "heptio-contour/contour", - GlooNamespace: "gloo-system", + GlooNamespaces: []string{"gloo-system"}, SkipperRouteGroupVersion: "zalando.org/v1", Sources: []string{"service"}, Namespace: "", @@ -136,7 +136,7 @@ var ( KubeConfig: "/some/path", RequestTimeout: time.Second * 77, ContourLoadBalancerService: "heptio-contour-other/contour-other", - GlooNamespace: "gloo-not-system,gloo-second-system", + GlooNamespaces: []string{"gloo-not-system", "gloo-second-system"}, SkipperRouteGroupVersion: "zalando.org/v2", Sources: []string{"service", "ingress", "connector"}, Namespace: "namespace", @@ -266,7 +266,8 @@ func TestParseFlags(t *testing.T) { "--kubeconfig=/some/path", "--request-timeout=77s", "--contour-load-balancer=heptio-contour-other/contour-other", - "--gloo-namespace=gloo-not-system,gloo-second-system", + "--gloo-namespace=gloo-not-system", + "--gloo-namespace=gloo-second-system", "--skipper-routegroup-groupversion=zalando.org/v2", "--source=service", "--source=ingress", @@ -391,7 +392,7 @@ func TestParseFlags(t *testing.T) { "EXTERNAL_DNS_KUBECONFIG": "/some/path", "EXTERNAL_DNS_REQUEST_TIMEOUT": "77s", "EXTERNAL_DNS_CONTOUR_LOAD_BALANCER": "heptio-contour-other/contour-other", - "EXTERNAL_DNS_GLOO_NAMESPACE": "gloo-not-system,gloo-second-system", + "EXTERNAL_DNS_GLOO_NAMESPACE": "gloo-not-system\ngloo-second-system", "EXTERNAL_DNS_SKIPPER_ROUTEGROUP_GROUPVERSION": "zalando.org/v2", "EXTERNAL_DNS_SOURCE": "service\ningress\nconnector", "EXTERNAL_DNS_NAMESPACE": "namespace", diff --git a/source/gloo_proxy.go b/source/gloo_proxy.go index 37d9401257..cf2ae2cd58 100644 --- a/source/gloo_proxy.go +++ b/source/gloo_proxy.go @@ -85,11 +85,12 @@ type glooSource struct { } // NewGlooSource creates a new glooSource with the given config -func NewGlooSource(dynamicKubeClient dynamic.Interface, kubeClient kubernetes.Interface, glooNamespaces string) (Source, error) { +func NewGlooSource(dynamicKubeClient dynamic.Interface, kubeClient kubernetes.Interface, + glooNamespaces []string) (Source, error) { return &glooSource{ dynamicKubeClient, kubeClient, - strings.Split(glooNamespaces, ","), + glooNamespaces, }, nil } diff --git a/source/gloo_proxy_test.go b/source/gloo_proxy_test.go index c1005fec2b..450f89e5d1 100644 --- a/source/gloo_proxy_test.go +++ b/source/gloo_proxy_test.go @@ -220,7 +220,7 @@ func TestGlooSource(t *testing.T) { proxyGVR: "ProxyList", }) - source, err := NewGlooSource(fakeDynamicClient, fakeKubernetesClient, defaultGlooNamespace) + source, err := NewGlooSource(fakeDynamicClient, fakeKubernetesClient, []string{defaultGlooNamespace}) assert.NoError(t, err) assert.NotNil(t, source) diff --git a/source/store.go b/source/store.go index 87ba403a2d..fd4690d8e6 100644 --- a/source/store.go +++ b/source/store.go @@ -67,7 +67,7 @@ type Config struct { CFUsername string CFPassword string ContourLoadBalancerService string - GlooNamespace string + GlooNamespaces []string SkipperRouteGroupVersion string RequestTimeout time.Duration DefaultTargets []string @@ -288,7 +288,7 @@ func BuildWithConfig(ctx context.Context, source string, p ClientGenerator, cfg if err != nil { return nil, err } - return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespace) + return NewGlooSource(dynamicClient, kubernetesClient, cfg.GlooNamespaces) case "openshift-route": ocpClient, err := p.OpenShiftClient() if err != nil { From 845b53cfa148eedde7259ee1c46e136e5c302f9c Mon Sep 17 00:00:00 2001 From: Megum1n Date: Sun, 25 Jun 2023 03:29:11 +0200 Subject: [PATCH 5/8] Update docs/tutorials/gloo-proxy.md Co-authored-by: John Gardiner Myers --- docs/tutorials/gloo-proxy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/gloo-proxy.md b/docs/tutorials/gloo-proxy.md index 816f5c6b27..482fec32b9 100644 --- a/docs/tutorials/gloo-proxy.md +++ b/docs/tutorials/gloo-proxy.md @@ -25,7 +25,7 @@ spec: image: registry.k8s.io/external-dns/external-dns:v0.13.5 args: - --source=gloo-proxy - - --gloo-namespace=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) + - --gloo-namespace=custom-gloo-system # gloo system namespace. Specify multiple times for multiple namespaces. Omit to use the default (gloo-system) - --provider=aws - --registry=txt - --txt-owner-id=my-identifier From c5af401026594af856c80ff99fbf3b10af7eb29d Mon Sep 17 00:00:00 2001 From: Megum1n Date: Sun, 25 Jun 2023 06:12:50 +0200 Subject: [PATCH 6/8] Update gloo docs --- docs/tutorials/gloo-proxy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/gloo-proxy.md b/docs/tutorials/gloo-proxy.md index 482fec32b9..52b1f830c0 100644 --- a/docs/tutorials/gloo-proxy.md +++ b/docs/tutorials/gloo-proxy.md @@ -93,7 +93,7 @@ spec: image: registry.k8s.io/external-dns/external-dns:v0.13.5 args: - --source=gloo-proxy - - --gloo-namespace=custom-gloo-system # comma separated gloo system namespace list. Omit to use the default (gloo-system) + - --gloo-namespace=custom-gloo-system # gloo system namespace. Specify multiple times for multiple namespaces. Omit to use the default (gloo-system) - --provider=aws - --registry=txt - --txt-owner-id=my-identifier From 30e34f8ae36a0e9fb0cee4cda7e01b4635aafc69 Mon Sep 17 00:00:00 2001 From: Megum1n Date: Mon, 26 Jun 2023 12:23:24 +0200 Subject: [PATCH 7/8] Update pkg/apis/externaldns/types.go Co-authored-by: John Gardiner Myers --- pkg/apis/externaldns/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/externaldns/types.go b/pkg/apis/externaldns/types.go index bd7c076ff0..8b9be29563 100644 --- a/pkg/apis/externaldns/types.go +++ b/pkg/apis/externaldns/types.go @@ -412,7 +412,7 @@ func (cfg *Config) ParseFlags(args []string) error { app.Flag("contour-load-balancer", "The fully-qualified name of the Contour load balancer service. (default: heptio-contour/contour)").Default("heptio-contour/contour").StringVar(&cfg.ContourLoadBalancerService) // Flags related to Gloo - app.Flag("gloo-namespace", "Set Gloo Proxy namespace; specify multiple times for multiple namespaces. (default: gloo-system)").Default("gloo-system").StringsVar(&cfg.GlooNamespaces) + app.Flag("gloo-namespace", "The Gloo Proxy namespace; specify multiple times for multiple namespaces. (default: gloo-system)").Default("gloo-system").StringsVar(&cfg.GlooNamespaces) // Flags related to Skipper RouteGroup app.Flag("skipper-routegroup-groupversion", "The resource version for skipper routegroup").Default(source.DefaultRoutegroupVersion).StringVar(&cfg.SkipperRouteGroupVersion) From dc261a879320a321fabc5be58526a1782a26880b Mon Sep 17 00:00:00 2001 From: Megum1n Date: Sat, 8 Jul 2023 22:56:19 +0200 Subject: [PATCH 8/8] Typo after merge from master --- pkg/apis/externaldns/types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/externaldns/types.go b/pkg/apis/externaldns/types.go index 8bedf4db81..ad0c0fa9c8 100644 --- a/pkg/apis/externaldns/types.go +++ b/pkg/apis/externaldns/types.go @@ -213,7 +213,7 @@ var defaultConfig = &Config{ KubeConfig: "", RequestTimeout: time.Second * 30, DefaultTargets: []string{}, - GlooNamespace: []string{"gloo-system"}, + GlooNamespaces: []string{"gloo-system"}, SkipperRouteGroupVersion: "zalando.org/v1", Sources: nil, Namespace: "",