external-dns/source
Kyle 38178940a3
feat: add annotation and label filters to Ambassador Host Source (#2633)
* Add annotation filter to Ambassador Host Source

This change makes the Ambassador Host source respect the External-DNS annotationFilter allowing for an Ambassador Host resource to specify what External-DNS deployment to use when there are multiple External-DNS deployments within the same cluster. Before this change if you had two External-DNS deployments within the cluster and used the Ambassador Host source the first External-DNS to process the resource will create the record and not the one that was specified in the filter annotation.

I added the `filterByAnnotations` function so that it matched the same way the other sources have implemented annotation filtering. I didn't add the controller check only because I wanted to keep this change to implementing the annotationFilter.

Example: Create two External-DNS deployments 1 public and 1 private and set the Ambassador Host to use the public External-DNS using the annotation filter.

```
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: external-dns-private
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: external-dns-private
  template:
    metadata:
      labels:
        app: external-dns-private
      annotations:
        iam.amazonaws.com/role: {ARN} # AWS ARN role
    spec:
      serviceAccountName: external-dns
      containers:
      - name: external-dns
        image: k8s.gcr.io/external-dns/external-dns:latest
        args:
        - --source=ambassador-host
        - --domain-filter=example.net # will make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones
        - --provider=aws
        - --policy=upsert-only # would prevent ExternalDNS from deleting any records, omit to enable full synchronization
        - --aws-zone-type=private # only look at public hosted zones (valid values are public, private or no value for both)
        - --registry=txt
        - --txt-owner-id= {Hosted Zone ID} # Insert Route53 Hosted Zone ID here
        - --annotation-filter=kubernetes.io/ingress.class in (private)
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: external-dns-public
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: external-dns-public
  template:
    metadata:
      labels:
        app: external-dns-public
      annotations:
        iam.amazonaws.com/role: {ARN} # AWS ARN role
    spec:
      serviceAccountName: external-dns
      containers:
      - name: external-dns
        image: k8s.gcr.io/external-dns/external-dns:latest
        args:
        - --source=ambassador-host
        - --domain-filter=example.net # will make ExternalDNS see only the hosted zones matching provided domain, omit to process all available hosted zones
        - --provider=aws
        - --policy=upsert-only # would prevent ExternalDNS from deleting any records, omit to enable full synchronization
        - --aws-zone-type= # only look at public hosted zones (valid values are public, private or no value for both)
        - --registry=txt
        - --txt-owner-id= {Hosted Zone ID} # Insert Route53 Hosted Zone ID here
        - --annotation-filter=kubernetes.io/ingress.class in (public)
---
apiVersion: getambassador.io/v3alpha1
  kind: Host
  metadata:
    name: your-hostname
    annotations:
      external-dns.ambassador-service: emissary-ingress/emissary
      kubernetes.io/ingress.class: public
  spec:
		acmeProvider:
      authority: none
		hostname: your-hostname.example.com
```

Fixes kubernetes-sigs/external-dns#2632

* Add Label filltering for Ambassador Host source

Currently the `--label-filter` flag can only be used to filter CRDs, Ingress, Service and Openshift Route objects which match the label selector passed through that flag. This change extends the functionality to the Ambassador Host type object.

When the flag is not specified the default value is `labels.Everything()` which is an empty string, the same as before. An annotation based filter is inefficient because the filtering has to be done in the controller instead of the API server like with label filtering. The Annotation based filtering has been left in for legacy reasons so the Ambassador Host source can be used inconjunction with the other sources that don't yet support label filltering.

It is possible to use label based filltering with annotation based filltering so you can initially filter by label then filter the returned hosts by annotation. This is not recomended

* Update Ambassador Host source docs

Add that the Ambassador Host source now supports both annotation and label filltering.
2024-08-28 18:02:57 +01:00
..
ambassador_host_test.go feat: add annotation and label filters to Ambassador Host Source (#2633) 2024-08-28 18:02:57 +01:00
ambassador_host.go feat: add annotation and label filters to Ambassador Host Source (#2633) 2024-08-28 18:02:57 +01:00
cloudfoundry_test.go fix route/cloudfoundry test 2019-05-10 12:28:32 -04:00
cloudfoundry.go dependencies: Upgrade all k8s client-go dependent sources to v1.18.X 2020-07-03 11:29:37 +07:00
compatibility.go IPv6 internal node IPs are usable externally 2023-05-07 12:00:28 -07:00
connector_test.go gofumpt 2022-09-20 20:48:57 -07:00
connector.go dependencies: Upgrade all k8s client-go dependent sources to v1.18.X 2020-07-03 11:29:37 +07:00
contour_httpproxy_test.go fix(httpProxy): drop status==valid filter 2023-10-14 14:29:15 +02:00
contour_httpproxy.go fix(httpProxy): drop status==valid filter 2023-10-14 14:29:15 +02:00
crd_test.go fix: linter on unused parameter 2024-05-16 08:44:06 +02:00
crd.go Implement proposed change by mloiseleur 2024-02-09 17:23:29 +01:00
dedupsource_test.go source: name files consistently with their source name 2021-07-28 07:46:35 -07:00
dedupsource.go source: name files consistently with their source name 2021-07-28 07:46:35 -07:00
empty_test.go dependencies: Upgrade all k8s client-go dependent sources to v1.18.X 2020-07-03 11:29:37 +07:00
empty.go dependencies: Upgrade all k8s client-go dependent sources to v1.18.X 2020-07-03 11:29:37 +07:00
f5_virtualserver_test.go Implement target annotation for more sources 2023-09-27 23:16:14 -07:00
f5_virtualserver.go Refactor getTTLFromAnnotations() to not return error (#3939) 2023-10-02 03:56:45 -07:00
fake_test.go dependencies: Upgrade all k8s client-go dependent sources to v1.18.X 2020-07-03 11:29:37 +07:00
fake.go review: remove seed and init() func 2023-06-12 12:10:49 +02:00
gateway_grpcroute_test.go source/gateway-api: revert v1.Gateway to v1beta1.Gateway 2024-07-14 09:06:35 -07:00
gateway_grpcroute.go feat: update GRPCRoute client to stable 2024-06-20 13:30:18 +02:00
gateway_hostname.go gateway: enforce listener matching 2022-02-24 21:33:53 -08:00
gateway_httproute_test.go source/gateway-api: revert v1.HTTPRoute to v1beta1.HTTPRoute 2024-07-14 09:06:35 -07:00
gateway_httproute.go source/gateway-api: revert v1.HTTPRoute to v1beta1.HTTPRoute 2024-07-14 09:06:35 -07:00
gateway_tcproute_test.go source/gateway-api: revert v1.Gateway to v1beta1.Gateway 2024-07-14 09:06:35 -07:00
gateway_tcproute.go add initial support for gw apis 1.0.0 GA 2023-11-06 09:32:31 -05:00
gateway_test.go Fix Gateway API TLS TCP Route 2024-01-27 00:41:15 +01:00
gateway_tlsroute_test.go source/gateway-api: revert v1.Gateway to v1beta1.Gateway 2024-07-14 09:06:35 -07:00
gateway_tlsroute.go add initial support for gw apis 1.0.0 GA 2023-11-06 09:32:31 -05:00
gateway_udproute_test.go source/gateway-api: revert v1.Gateway to v1beta1.Gateway 2024-07-14 09:06:35 -07:00
gateway_udproute.go add initial support for gw apis 1.0.0 GA 2023-11-06 09:32:31 -05:00
gateway.go source/gateway-api: revert v1.Gateway to v1beta1.Gateway 2024-07-14 09:06:35 -07:00
gloo_proxy_test.go Implement target annotation for more sources 2023-09-27 23:16:14 -07:00
gloo_proxy.go Refactor getTTLFromAnnotations() to not return error (#3939) 2023-10-02 03:56:45 -07:00
ingress_test.go Merged from master and tested. 2024-03-19 13:27:17 +01:00
ingress.go Refactor getTTLFromAnnotations() to not return error (#3939) 2023-10-02 03:56:45 -07:00
istio_gateway_test.go fix(istio): support for ExternalIPs in Istio resources 2023-12-06 08:52:35 +01:00
istio_gateway.go fix(istio): support for ExternalIPs in Istio resources 2023-12-06 08:52:35 +01:00
istio_virtualservice_test.go fix(istio): support for ExternalIPs in Istio resources 2023-12-06 08:52:35 +01:00
istio_virtualservice.go fix(istio): support for ExternalIPs in Istio resources 2023-12-06 08:52:35 +01:00
kong_tcpingress_test.go Make --ignore-hostname-annotation flag more consistent 2023-10-02 23:51:43 -07:00
kong_tcpingress.go Make --ignore-hostname-annotation flag more consistent 2023-10-02 23:51:43 -07:00
multisource_test.go copy labels 2023-06-30 07:52:25 +02:00
multisource.go Refactor setting the "resource" label into endpointsForHostname 2023-08-29 11:36:27 -07:00
node_test.go Implement target annotation for more sources 2023-09-27 23:16:14 -07:00
node.go Refactor getTTLFromAnnotations() to not return error (#3939) 2023-10-02 03:56:45 -07:00
openshift_route_test.go Make unit tests more strict about record type 2023-03-30 17:47:59 -07:00
openshift_route.go Refactor getTTLFromAnnotations() to not return error (#3939) 2023-10-02 03:56:45 -07:00
pod_test.go Implement target annotation for more sources 2023-09-27 23:16:14 -07:00
pod.go Implement target annotation for more sources 2023-09-27 23:16:14 -07:00
service_test.go fix: use current local dns resolution 2024-04-19 17:35:27 +02:00
service.go fix(service): omit nil endpoints and prefer endpointsForHostname() 2024-03-04 17:38:29 +01:00
shared_test.go IPv6 internal node IPs are usable externally 2023-05-07 12:00:28 -07:00
skipper_routegroup_test.go Make unit tests more strict about record type 2023-03-30 17:47:59 -07:00
skipper_routegroup.go Make routegroup client IPv6 compatible 2023-11-27 11:53:42 +01:00
source_test.go Refactor getTTLFromAnnotations() to not return error (#3939) 2023-10-02 03:56:45 -07:00
source.go test 2024-05-10 20:11:38 +02:00
store_test.go Remove flags and documentation for removed contour-ingressroute source 2023-07-04 16:37:37 -07:00
store.go feat: add annotation and label filters to Ambassador Host Source (#2633) 2024-08-28 18:02:57 +01:00
targetfiltersource_test.go Simplify interface implementation test for targetFilterSource 2023-06-29 22:38:17 +02:00
targetfiltersource.go Fix: File is not goimports-ed with -local 2023-07-01 14:11:49 +02:00
traefik_proxy_test.go Add test cases for Traefik API group flags 2023-11-29 12:14:59 -06:00
traefik_proxy.go fix(traefik): Nil pointer exception if legacy traefik is disabled 2024-05-25 11:07:49 +02:00
unstructured_converter.go drop more concour 2021-08-12 14:12:44 +02:00