sigs.k8s.io/external-dns@v0.14.1/docs/sources/service.md (about)

     1  # Service source
     2  
     3  The service source creates DNS entries based on `Service` resources.
     4  
     5  ## Filtering the Services considered
     6  
     7  The `--service-type-filter` flag filters Service resources by their `spec.type`.
     8  The flag may be specified multiple times to allow multiple service types.
     9  
    10  This source supports the `--label-filter` flag, which filters Service resources
    11  by a set of labels.
    12  
    13  ## Domain names
    14  
    15  The domain names of the DNS entries created from a Service are sourced from the following places:
    16  
    17  1. Adds the domain names from any `external-dns.alpha.kubernetes.io/hostname` and/or
    18  `external-dns.alpha.kubernetes.io/internal-hostname` annotation.
    19  This behavior is suppressed if the `--ignore-hostname-annotation` flag was specified.
    20  
    21  2. If no DNS entries were produced for a Service by the previous steps
    22  and the `--compatibility` flag was specified, then adds DNS entries per the
    23  selected compatibility mode.
    24  
    25  3. If no DNS entries were produced for a Service by the previous steps
    26  or the `--combine-fqdn-annotation` flag was specified, then adds domain names
    27  generated from any`--fqdn-template` flag.
    28  
    29  ### Domain names for headless service pods
    30  
    31  If a headless Service (without an `external-dns.alpha.kubernetes.io/target` annotation) creates DNS entries with targets from
    32  a Pod that has a non-empty `spec.hostname` field, additional DNS entries are created for that Pod, containing the targets from that Pod.
    33  For each domain name created for the Service, the additional DNS entry for the Pod has that domain name prefixed with
    34  the value of the Pod's `spec.hostname` field and a `.`.
    35  
    36  ## Targets
    37  
    38  If the Service has an `external-dns.alpha.kubernetes.io/target` annotation, uses 
    39  the values from that. Otherwise, the targets of the DNS entries created from a service are sourced depending
    40  on the Service's `spec.type`:
    41  
    42  ### LoadBalancer
    43  
    44  1. If the hostname came from an `external-dns.alpha.kubernetes.io/internal-hostname` annotation, uses
    45  the Service's `spec.clusterIP` field. If that field has the value `None`, does not generate
    46  any targets for the hostname.
    47  
    48  2. Otherwise, if the Service has one or more `spec.externalIPs`, uses the values in that field.
    49  
    50  3. Otherwise, iterates over each `status.loadBalancer.ingress`, adding any non-empty `ip` and/or `hostname`.
    51  
    52  If the `--resolve-service-load-balancer-hostname` flag was specified, any non-empty `hostname`
    53  is queried through DNS and any resulting IP addresses are added instead.
    54  A DNS query failure results in zero targets being added for that load balancer's ingress hostname.
    55  
    56  ### ClusterIP (headless)
    57  
    58  Iterates over all of the Service's Endpoints's `subsets.addresses`.
    59  If the Service's `spec.publishNotReadyAddresses` is `true` or the `--always-publish-not-ready-addresses` flag is specified,
    60  also iterates over the Endpoints's `subsets.notReadyAddresses`.
    61  
    62  1. If an address does not target a `Pod` that matches the Service's `spec.selector`, it is ignored.
    63  
    64  2. If the target pod has an `external-dns.alpha.kubernetes.io/target` annotation, uses 
    65  the values from that.
    66  
    67  3. Otherwise, if the Service has an `external-dns.alpha.kubernetes.io/endpoints-type: NodeExternalIP`
    68  annotation, uses the addresses from the Pod's Node's `status.addresses` that are either of type
    69  `ExternalIP` or IPv6 addresses of type `InternalIP`.
    70  
    71  4. Otherwise, if the Service has an `external-dns.alpha.kubernetes.io/endpoints-type: HostIP` annotation
    72  or the `--publish-host-ip` flag was specified, uses the Pod's `status.hostIP` field.
    73  
    74  5. Otherwise uses the `ip` field of the address from the Endpoints.
    75  
    76  ### ClusterIP (not headless)
    77  
    78  1. If the hostname came from an `external-dns.alpha.kubernetes.io/internal-hostname` annotation
    79  or the `--publish-internal-services` flag was specified, uses the `spec.ServiceIP`.
    80  
    81  2. Otherwise, does not create any targets.
    82  
    83  ### NodePort
    84  
    85  If `spec.ExternalTrafficPolicy` is `Local`, iterates over each Node that both matches the Service's `spec.selector`
    86  and has a `status.phase` of `Running`. Otherwise iterates over all Nodes, of any phase.
    87  
    88  Iterates over each relevant Node's `status.addresses`:
    89  
    90  1. If there is an `external-dns.alpha.kubernetes.io/access: public` annotation on the Service, uses both addresses with 
    91  a `type` of `ExternalIP` and IPv6 addresses with a `type` of `InternalIP`.
    92  
    93  2. Otherwise, if there is an `external-dns.alpha.kubernetes.io/access: private` annotation on the Service, uses addresses with  
    94  a `type` of `InternalIP`.
    95  
    96  3. Otherwise, if there is at least one address with a `type` of `ExternalIP`, uses both addresses with 
    97  a `type` of `ExternalIP` and IPv6 addresses with a `type` of `InternalIP`.
    98  
    99  4. Otherwise, uses addresses with a `type` of `InternalIP`.
   100  
   101  Also iterates over the Service's `spec.ports`, creating a SRV record for each port which has a `nodePort`.
   102  The SRV record has a service of the Service's `name`, a protocol taken from the port's `protocol` field,
   103  a priority of `0` and a weight of `50`.
   104  In order for SRV records to be created, the `--managed-record-types`must have been specified, including `SRV`
   105  as one of the values.
   106  
   107  ### ExternalName
   108  
   109  1. If the Service has one or more `spec.externalIPs`, uses the values in that field.
   110  2. Otherwise, creates a target with the value of the Service's `externalName` field.
   111