Skip to content

Latest commit

 

History

History
 
 

dns-service-discovery

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

HAProxy DNS Service Discovery

This example uses dns service discovery for service named web

Prerequisites

This document has the following prerequisites:

Using DNS Service Discovery

Example - using internal kubernetes resources

Note: Configure IP address of your cluster DNS server

$ kubectl apply -f haproxy-config-map.yml
  • configmap with all options displayed configmap
$ kubectl apply -f all-options-haproxy-config-map.yml

Note: If using kube-dns, the cache ttl defaults to 30s. Add --max-ttl and --max-cache-ttl to the dns container to a proper value, otherwise the HAProxy backend could take up to 30s to update

$ kubectl apply -f web-rc.yml
  • Configure ingress
$ kubectl annotate ingress/app --overwrite ingress.kubernetes.io/use-resolver=kubernetes

Two important settings:

  • ingress.kubernetes.io/use-resolver: kubernetes: resolver with name kubernetes
  • clusterIP: None: service must be headless. See also dns headless doc.

Configmap options

  • cluster-dns-domain can be used if kubedns does not points to cluster.local

  • dns-resolvers multiline list of DNS resolvers

    • DNS resolver can be written in multiple ways:
      • resolver=ip
      • resolver=ip:port
      • resolver=ip[:port],ip[:port] where port is optional
  • dns-timeout-retry default: 1s

  • dns-hold-obsoletedefault: 0s

  • dns-hold-valid default: 1s

  • dns-accepted-payload-size default: 8192

Annotations

ingress.kubernetes.io/use-resolver: resolvername