diff --git a/charts/external-dns/templates/clusterrole.yaml b/charts/external-dns/templates/clusterrole.yaml index 8fcc15dce..6961f05c1 100644 --- a/charts/external-dns/templates/clusterrole.yaml +++ b/charts/external-dns/templates/clusterrole.yaml @@ -70,6 +70,11 @@ rules: resources: ["tcpingresses"] verbs: ["get","watch","list"] {{- end }} +{{- if has "traefik-proxy" .Values.sources }} + - apiGroups: ["traefik.containo.us"] + resources: ["ingressroutes", "ingressroutestcps", "ingressroutesudps"] + verbs: ["get","watch","list"] +{{- end }} {{- if has "openshift-route" .Values.sources }} - apiGroups: ["route.openshift.io"] resources: ["routes"] diff --git a/source/store_test.go b/source/store_test.go index e2d15f3f2..0105b29cc 100644 --- a/source/store_test.go +++ b/source/store_test.go @@ -130,9 +130,24 @@ func (suite *ByNamesTestSuite) TestAllInitialized() { Version: "v1", Resource: "virtualservers", }: "VirtualServersList", + { + Group: "traefik.containo.us", + Version: "v1alpha1", + Resource: "ingressroutes", + }: "IngressRouteList", + { + Group: "traefik.containo.us", + Version: "v1alpha1", + Resource: "ingressroutetcps", + }: "IngressRouteTCPList", + { + Group: "traefik.containo.us", + Version: "v1alpha1", + Resource: "ingressrouteudps", + }: "IngressRouteUDPList", }), nil) - sources, err := ByNames(context.TODO(), mockClientGenerator, []string{"service", "ingress", "istio-gateway", "contour-httpproxy", "kong-tcpingress", "f5-virtualserver", "fake"}, minimalConfig) + sources, err := ByNames(context.TODO(), mockClientGenerator, []string{"service", "ingress", "istio-gateway", "contour-httpproxy", "kong-tcpingress", "f5-virtualserver", "traefik-proxy", "fake"}, minimalConfig) suite.NoError(err, "should not generate errors") suite.Len(sources, 7, "should generate all seven sources") } @@ -171,9 +186,6 @@ func (suite *ByNamesTestSuite) TestKubeClientFails() { _, err = ByNames(context.TODO(), mockClientGenerator, []string{"kong-tcpingress"}, minimalConfig) suite.Error(err, "should return an error if kubernetes client cannot be created") - - _, err = ByNames(context.TODO(), mockClientGenerator, []string{"f5-virtualserver"}, minimalConfig) - suite.Error(err, "should return an error if kubernetes client cannot be created") } func (suite *ByNamesTestSuite) TestIstioClientFails() { diff --git a/source/traefik_proxy.go b/source/traefik_proxy.go index 200f63e07..161977c33 100644 --- a/source/traefik_proxy.go +++ b/source/traefik_proxy.go @@ -144,6 +144,7 @@ func (ts *traefikSource) Endpoints(ctx context.Context) ([]*endpoint.Endpoint, e return endpoints, nil } +// ingressRouteEndpoints extracts endpoints from all IngressRoute objects func (ts *traefikSource) ingressRouteEndpoints() ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint @@ -196,6 +197,8 @@ func (ts *traefikSource) ingressRouteEndpoints() ([]*endpoint.Endpoint, error) { return endpoints, nil } + +// ingressRouteTCPEndpoints extracts endpoints from all IngressRouteTCP objects func (ts *traefikSource) ingressRouteTCPEndpoints() ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint @@ -248,6 +251,8 @@ func (ts *traefikSource) ingressRouteTCPEndpoints() ([]*endpoint.Endpoint, error return endpoints, nil } + +// ingressRouteUDPEndpoints extracts endpoints from all IngressRouteUDP objects func (ts *traefikSource) ingressRouteUDPEndpoints() ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint @@ -465,6 +470,8 @@ func (ts *traefikSource) endpointsFromIngressRoute(ingressRoute *traefikV1alpha1 return endpoints, nil } + +// endpointsFromIngressRouteTCP extracts the endpoints from a IngressRouteTCP object func (ts *traefikSource) endpointsFromIngressRouteTCP(ingressRoute *traefikV1alpha1.IngressRouteTCP, targets endpoint.Targets) ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint @@ -491,6 +498,8 @@ func (ts *traefikSource) endpointsFromIngressRouteTCP(ingressRoute *traefikV1alp return endpoints, nil } + +// endpointsFromIngressRouteUDP extracts the endpoints from a IngressRouteUDP object func (ts *traefikSource) endpointsFromIngressRouteUDP(ingressRoute *traefikV1alpha1.IngressRouteUDP, targets endpoint.Targets) ([]*endpoint.Endpoint, error) { var endpoints []*endpoint.Endpoint