Inforedaster
Inforedaster

Reputation: 1330

how to use --label-filter with external-dns to filter the ingress in kubernetes

I had many dns records in my dns-zone in azure and i need to use External-dns to automate dns record creation/deletion but i need to filter by labels when external-dns found other label in the aks ingrees than this one below it mustn't touch it :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sample-rule
  labels:
    ingress: externaldns
  annotations:
    kubernetes.io/ingress.class: "nginx"
    ingress: "externaldns"

the Helm command :

helm install external-dns-frontend-sint bitnami/external-dns \                                                                                                                      
    --wait \
    --namespace externaldns \
    --set txtOwnerId=az-frontend-aks\
    --set provider=azure \
    --set azure.resourceGroup=az-tools \
    --set txtOwnerId=az-frontend-ak \
    --set azure.tenantId=xxxxxxxxxxxxxxxxxxxxxxx \
    --set azure.subscriptionId=xxxxxxxxxxxxxxxxxxxxxxxx \
    --set azure.aadClientId=xxxxxxxxxxxxxxxxx \
    --set azure.aadClientSecret=xxxxxxxxxxxxxxx \
    --set azure.cloud=AzurePublicCloud \
    --set policy=sync \
    --set labelfilter=”ingre=externaldns” \
    --set annotationfilter=”ingress=externaldns” \
    --set domainFilters={azdns.test.com}

i need to know how can i use this argument with Bitnami/external-dns chart to activate the label filter please. any help please

Last : the filter doesn't work, it created all record from the ingress in the same namespace

Upvotes: 1

Views: 3744

Answers (2)

Inforedaster
Inforedaster

Reputation: 1330

there was two issues :

  1. mistake in the annotation filter, filter must be in capital letter

    annotationFilter: “ingress: externaldns”

  2. The label filter is a new feature must be used in the new Helm chart version 5.5.1

Upvotes: 0

Kartik Bhiwapurkar
Kartik Bhiwapurkar

Reputation: 5167

• You can use the label filter command with bitnami external dns charts as below to filter out the labels which are not passed as aks ingress in external dns.

‘ $helm install my-release -f values.yaml bitnami/external-dns ‘

In the values.yaml file, specify the label filter and annotation filter parameters as below: -

 labelfilter: “ingress: ‘externaldns’”
 annotationfilter: “ingress: ‘externaldns’”

OR

‘ $helm install my-release \
  --set-labelfilter=”ingress=externaldns” \
  --set-annotationfilter=”ingress=externaldns” \
   bitnami/external-dns ’

Also, please take into consideration that ‘annotation filter’ filters sources managed by external-dns via annotation using label selector while the ‘label filter’ only selects sources managed by external-dns using the label selector. Thus, filtering based on annotation means that the external-dns controller will receive all resources of that kind and then filter on the client-side. In larger clusters with many resources which change frequently this can cause performance issues. If only some resources need to be managed by an instance of external-dns then label filtering can be used instead of annotation filtering. This means that only those resources which match the selector specified in ‘--label-filter’ will be passed to the controller.

Please find the below links for reference: -

https://github.com/kubernetes-sigs/external-dns/blob/master/docs/faq.md#running-an-internal-and-external-dns-service

https://github.com/bitnami/charts/tree/master/bitnami/external-dns/#external-dns-parameters

Upvotes: 4

Related Questions