This example uses dns service discovery for service named web
This document has the following prerequisites:
- Deploy HAProxy Ingress controller
Example - using internal kubernetes resources
Note: Configure IP address of your cluster DNS server
- Update ingress with simple configmap
$ 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
- Install pods replication-controler
$ 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 kubernetesclusterIP: None
: service must be headless. See also dns headless doc.
-
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 resolver can be written in multiple ways:
-
dns-timeout-retry
default: 1s -
dns-hold-obsolete
default: 0s -
dns-hold-valid
default: 1s -
dns-accepted-payload-size
default: 8192
ingress.kubernetes.io/use-resolver: resolvername